This starter kit has the following outline:
- Monolithic Project.
- REST API
This is a Github Template Repository, so it can be easily used as a starter template for other repositories.
To view sample implementations based on this starter-kit, please visit the nestjs-sample-solutions repository.
| Feature | Info | Progress |
|---|---|---|
| Authentication | JWT | Done |
| ORM Integration | TypeORM | Done |
| DB Migrations | TypeORM | Done |
| Logging | nestjs-pino | Done |
| Request Validation | class-validator | Done |
| Docker Ready | Dockerfile | Done |
| Continuous Code Quality | SonarQube | Done |
| Auto-generated OpenAPI | - | Done |
| Auto-generated ChangeLog | - | WIP |
$ npm installCreate a .env file from the template .env.template.
Generate public and private key pair for jwt authentication:
$ ssh-keygen -t rsa -b 2048 -m PEM -f jwtRS256.key
# Don't add passphrase
$ openssl rsa -in jwtRS256.key -pubout -outform PEM -out jwtRS256.key.pubYou may save these key files in ./local directory as it is ignored in git.
Encode keys to base64:
$ base64 -i local/jwtRS256.key
$ base64 -i local/jwtRS256.key.pubMust enter the base64 of the key files in .env:
JWT_PUBLIC_KEY_BASE64=BASE64_OF_JWT_PUBLIC_KEY
JWT_PRIVATE_KEY_BASE64=BASE64_OF_JWT_PRIVATE_KEY# development
$ npm run start
# watch mode
$ npm run start:dev
# production mode
$ npm run start:prod# unit tests
$ npm run test
# e2e tests
$ npm run test:e2e
# test coverage
$ npm run test:cov# generate migration (replace CreateUsers with name of the migration)
$ npm run migration:generate -- -n CreateUsers
# run migration
$ npm run migration:run
# revert migration
$ npm run migration:revert
To locally analyse your code it is enough to run
# build image
$ docker-compose up
# run container from image
$ docker-compose exec sonarscanner sonar-scanner
The results can be viewed in local instance of sonarqube http://localhost:9000/sonarqube/dashboard?id=nest-typescript-starter.
Local instance of sonarqube uses sonar-scanner.properties file.
# build image
$ docker build -t my-app .
# run container from image
$ docker run -p 3000:3000 --volume `pwd`:/usr/src/app --env-file .env my-app
# run using docker compose
$ docker-compose upLearn more about Docker conventions here. (WIP - Currently this is an internal org link.)