Click here for the frontend. Built with Angular
Click here to view Angular code coverage
Click here to view Node code coverage
Before you begin, make sure your development environment inlcudes the following technologies:
We recommend you use the latest LTS version of node, which is currently 12.x
To get node, go to nodejs.org
To check your node version run the following in terminal:
node --version
Our Chosen ORM in Node is TypeORM. TypeORM suports most major databases
We prefer the very popular and open source postgres.
If desiered it should be relatively trivial to switch databases.
Note: db scripts at scripts/db/
have not been tested with any other databases besides postgres
To get postgres, go to postgresql.org or install via homebrew
Note: If you install via homebrew, don't forget to run brew services start postgresql
To check your postgres version run the following in terminal:
psql --version
To set up a new user in postgres type the following in terminal (It will prompt you for a password):
createuser newuser --pwprompt --createdb # newuser can be any username you choose
Test that you can log in to postgres:
psql -U newuser template1
Common postgres commands can be found in: NOTES/POSTGRES.md
git clone git@github.com:startbootstrap/sb-clean-blog-node.git
cd sb-clean-blog-node
cp .env.sample .env
Open .env
and change the values for:
DB_ROOT_USER_PASSWORD=CHANGE_ME__STRING # make up a password
TYPE_ORM_USERNAME=CHANGE_ME__STRING # postgres username
TYPE_ORM_PASSWORD=CHANGE_ME__STRING # postgres password
JWT_SECRET=CHANGE_ME__STRING # make up a random string
npm install
This command:
- drops the current database
- recreates the databse
- runs all migrations
- creates the root user
- seeds the db with random posts
npm run db:reset # See the next command if you have issues with this command
npm run db:uuid
This will add the extension uuid-ossp
to the template1 databse.
You will then need to run npm run db:reset
again
npm start
You should be able to hit http://localhost:8200/api/latest/health
Follow the README at sb-clean-blog-angular
Unit Tests are named *.test.ts
and are located in the same directory as the file they are testing.
npm run test
# To keep the test runner going as you devleop tests use:
npm run test:watch
To run a specific test, you can do:
npm run test:one -- -t=[string]
npm run serve:coverage
# typeOrm cli help
npm run cli -- -h
# Create a migration
npm run db:migration:generate -- -n my-migration
# Run migrations
npm run db:migration:run
SB Clean Blog Node comes with a Dockerfile and build scripts.
You can get Docker here
# Be sure to build the app first
npm run build
# Then build the docker image
npm run docker:build
# Then run the image
npm run docker:run
If you intend to use this in production, you will need to modify the run script:
scripts/docker/docker-run.ts
to change the .env variables to point to your production postgres instance.
You will also need to develop a way to initialize and run migrations on the production database. One option is to set you local .env to temporarily point to your production database and run the commands locally.
npm run lint
npm run lint:fix
npm run lint:check
npm run debug
node_modules/.bin/tsc --showConfig -p ./src/tsconfig.app.json
node_modules/.bin/tsc --showConfig -p ./src/tsconfig.spec.json