Skip to content

NestJs Framework typescript boilerplate that implements orm, authentication and so on.

Notifications You must be signed in to change notification settings

bl4cktrum/nestjs-boilerplate

Repository files navigation

Nest Logo

Nest framework TypeScript starter repository based poiler plate.
(Based on Node.js 18.18.0 LTS)

Description

  • 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.

Typeorm Implementation

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

Environment Variables & Configuration Service

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.

! Do not forget the ignore env files from .gitignore

// .gitignore

**/*.env
!env/dev.env

License

Nest is MIT licensed.

About

NestJs Framework typescript boilerplate that implements orm, authentication and so on.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published