Nest framework TypeScript starter repository based poiler plate.
(Based on Node.js 18.18.0 LTS)
- Database connection handled by typeorm and @nestjs/typeorm module.
- Multiple environment configuration handled by cross-env and @nestjs/config module.
- Authentication features implemented by passport.js.
- Bcrypt has been used to hash and compare strings.
- Exceptions has been handled by filters, responses has been standardized by interceptors, custom decorators and class-transformer. Check out user controller, service and entity to see usage example.
Database informations
are specified in src/db/data-source.ts
file. Also entities'
path and migration folder
path are. If you change the location of this file, do not forget to update the script.
// package.json
// first one is placed to just handle data-source. So it is recommended to use migration:*
"scripts": {
...
"typeorm": "npm run build && typeorm -d dist/db/data-source.js",
"migration:generate": "ts-node src/utils/migration-generate.ts",
"migration:run": "npm run typeorm -- migration:run",
"migration:revert": "npm run typeorm -- migration:revert"
...
}
to generate a new migration npm run migration:generate <output_file_name>
$ npm run migration:generate -- CreateUserTable
Set vars in .env
files then add the new var in src/app.config.ts
to be able to use it from ConfigService.
If you want to create new environment
you have to create new scripts that sets NODE_ENV
to run app in your env.
// .gitignore
**/*.env
!env/dev.env
Nest is MIT licensed.