An open API service indexing awesome lists of open source software.

https://github.com/bl4cktrum/nestjs-boilerplate

NestJs Framework typescript boilerplate that implements orm, authentication and so on.
https://github.com/bl4cktrum/nestjs-boilerplate

authentication configuration nestjs typeorm typescript

Last synced: 2 months ago
JSON representation

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

Awesome Lists containing this project

README

          


Nest Logo

[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456

[circleci-url]: https://circleci.com/gh/nestjs/nest

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 ```

```bash
$ 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

```markdown
// .gitignore

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

## License

Nest is [MIT licensed](LICENSE).