{"id":39715221,"url":"https://github.com/md-redwan-hossain/nestjs-starter","last_synced_at":"2026-01-18T10:41:55.089Z","repository":{"id":206799632,"uuid":"716921945","full_name":"md-redwan-hossain/nestjs-starter","owner":"md-redwan-hossain","description":"A comprehensive starter repository designed for swiftly launching a NestJS project, with essential components at its core.","archived":false,"fork":false,"pushed_at":"2024-02-29T08:20:10.000Z","size":764,"stargazers_count":3,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-02-29T09:31:02.801Z","etag":null,"topics":["nestjs","nestjs-backend","nestjs-boilerplate","nodejs","rest-api"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/md-redwan-hossain.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2023-11-10T06:47:31.000Z","updated_at":"2023-11-30T11:00:34.000Z","dependencies_parsed_at":"2024-02-29T09:30:31.358Z","dependency_job_id":"c247a65c-590a-452b-bac5-3ed50d1d63dd","html_url":"https://github.com/md-redwan-hossain/nestjs-starter","commit_stats":null,"previous_names":["md-redwan-hossain/nestjs-starter"],"tags_count":0,"template":true,"template_full_name":null,"purl":"pkg:github/md-redwan-hossain/nestjs-starter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/md-redwan-hossain%2Fnestjs-starter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/md-redwan-hossain%2Fnestjs-starter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/md-redwan-hossain%2Fnestjs-starter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/md-redwan-hossain%2Fnestjs-starter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/md-redwan-hossain","download_url":"https://codeload.github.com/md-redwan-hossain/nestjs-starter/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/md-redwan-hossain%2Fnestjs-starter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28534615,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-18T10:13:46.436Z","status":"ssl_error","status_checked_at":"2026-01-18T10:13:11.045Z","response_time":98,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["nestjs","nestjs-backend","nestjs-boilerplate","nodejs","rest-api"],"created_at":"2026-01-18T10:41:54.868Z","updated_at":"2026-01-18T10:41:55.058Z","avatar_url":"https://github.com/md-redwan-hossain.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nestjs starter\n\n## features\n\n- Modular architecture adhering to SOLID principles for enhanced scalability and maintainability.\n\n- Complete Admin functionality with REST endpoints labelled as Stuff. Stuff can be three types: SuperAdmin, Admin, Moderator.\n\n- Postgresql as the primary Database with Drizzle ORM.\n\n- Structured logging with MongoDB, ensuring comprehensive system behavior analysis.\n\n- Redis-based cache management for swift data access and optimization.\n\n- Redis based API throttling.\n\n- Bullmq based redis queue.\n\n- Mailgun based email sending service.\n\n- Dockerized Postgresql, MongoDB, Redis.\n\n- Iron-strong server-side validation for robust data integrity and security.\n\n- Github Dependabot for always up-to-date npm packages.\n\n- JWT-based stateless authentication flow with Role based access control(RBAC) for secure and granular access control.\n\n- Redis based JWT token blacklist cache.\n\n- TOTP based Two Factor authentication.\n\n- Fully documented API with Swagger at http://127.0.0.1:3000/api-doc for comprehensive reference.\n\n## Note about SWC compiler:\n\n- To achieve 20X speed, this repo utilizes SWC compiler instead of the default TSC compiler to compile Typescript to Javascript.\n\n- In windows, You must install [Microsoft Visual C++ Redistributable](https://aka.ms/vs/17/release/vc_redist.x64.exe) to work with SWC compiler.\n\n- In any type of build error, remove `node_modules` folder and run `npm install` to install the dependencies again. This type of error can arise when you switch platform like linux to windows and vice-versa.\n\n## Configuring environment variables\n\n- Run `npm run make-env` to make the `.env.*` files from the example .env files.\n- then initilize them with proper values\n\n## Running Postgresql and Redis in Docker\n\n```bash\n# Normal mode\ndocker compose up\n\n# Background mode\ndocker compose up -d\n\n# Stopping containers\ndocker compose stop\n```\n\n## Database Migration\n\n- Migrations are managed by [DbMate.](https://github.com/amacneil/dbmate)\n\n- Migrations will be applied and rollbacked sequentially.\n\n- If you are running the database for the first time, you need to apply the migrations to the database.\n\n- Drizzle ORM is preferred for doing queries in the application.\n\n- To pull all database tables as Drizzle schema, run `npx drizzle-kit introspect:pg` for postgresql.\n\n- Using Drizzle or any kind of ORM for migrations is not recommended since they lack support of many DB specific features.\n\n```bash\n# list of all migrations with status\nnpm run migrator:list\n\n# apply a migration\nnpm run migrator:apply\n\n# rollback a migration\nnpm run migrator:rollback\n\n# create a new blank migration\n# write sql in the generated migration file\nnpm run migrator:new\n\n# force push the db schema\nnpm run migrator:schema-force-push\n```\n\n## Json Web Token (JWT) authentication\n\n- To apply jwt authentication on a controller or route handler method, simply add the `@UseGuards(JwtAuthGuard)` decorator.\n\n- You can customize `JwtAuthGuard` class with your custom logic. Currently, It is utilizing `access_token` in the request header. It also maintains a token blacklist cache through redis. The blacklist cache ensures that after logout, the same token can't be used again to make requests.\n\n## Role Based Access Control (RBAC)\n\n- To apply jwt authentication on a controller or route handler method, simply add the following decorators. Populate the array in `@AllowedRoles` decorator with approprite values.\n\n- You can add more values in `USER_ROLE` enum on demand.\n\n```typescript\n@AllowedRoles([USER_ROLE.ADMIN, USER_ROLE.MODERATOR])\n@UseGuards(RoleGuard)\n```\n\n## Custom Decorators\n\n**To reduce boilerplate codes, various Custom Decorators are provided.**\n\n**`@JwtRbacAuth(roles: USER_ROLE[])`**: This custom decorator takes the same arguments as `AllowedRoles`. It wraps up JWT and RBAC along with proper response decorators. Simply call it on top of any controller route handler method.\n\n```typescript\n  @JwtRbacAuth([USER_ROLE.SUPER_ADMIN, USER_ROLE.ADMIN])\n  @Get(\"profile\")\n  @ApiOperation({ summary: \"stuff profile\" })\n  @ApiOkResponse({ type: ResponseStuffDto })\n  @ApiNotFoundResponse()\n  @ApiBadRequestResponse()\n  async findOne(@UserId() id: string, @Res() response: Response) {}\n```\n\nThe implementation of this decorator is given below:\n\n```typescript\nexport function JwtRbacAuth(roles: USER_ROLE[]) {\n  return applyDecorators(\n    AllowedRoles(roles),\n    UseGuards(JwtAuthGuard),\n    UseGuards(RoleGuard),\n    ApiBearerAuth(),\n    ApiUnauthorizedResponse(),\n    ApiForbiddenResponse()\n  );\n}\n```\n\n**`@UserId()`**: This custom decorator doesnot take any argument. It must be used with `JwtRbacAuth` or `UseGuards(JwtAuthGuard)` because it fetches `user.id` from `request` object. Simply call it in any controller route handler method argument. Example:\n\n```typescript\nasync findOne(@UserId() id: string) { }\n```\n\n**`@UserData(data: \"id\"|\"role\")`**: This custom decorator takes `\"id\"` or `\"role\"` as argument. It must be used with `JwtRbacAuth` or `UseGuards(JwtAuthGuard)` because it fetches `\"id\"` or `\"role\"` from `request.user` object. Simply call it in any controller route handler method argument. Example:\n\n```typescript\nasync findOne(@UserData(\"role\") role: string) { }\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmd-redwan-hossain%2Fnestjs-starter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmd-redwan-hossain%2Fnestjs-starter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmd-redwan-hossain%2Fnestjs-starter/lists"}