{"id":43546085,"url":"https://github.com/rodion-arr/nestjs-starter-kit","last_synced_at":"2026-02-03T18:44:15.415Z","repository":{"id":36980234,"uuid":"352161921","full_name":"rodion-arr/nestjs-starter-kit","owner":"rodion-arr","description":"Nest.js starter kit with Postgres, Redis, Docker, TypeORM, JWT auth, and more!","archived":false,"fork":false,"pushed_at":"2025-04-07T16:16:50.000Z","size":3734,"stargazers_count":65,"open_issues_count":37,"forks_count":9,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-07T17:29:28.983Z","etag":null,"topics":["docker","jwt","nestjs","postgres","redis","typeorm"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rodion-arr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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,"publiccode":null,"codemeta":null},"funding":{"patreon":"rodion_arr"}},"created_at":"2021-03-27T19:42:24.000Z","updated_at":"2025-04-07T16:16:54.000Z","dependencies_parsed_at":"2023-11-06T11:24:18.662Z","dependency_job_id":"060420bf-be4c-43b8-bb5a-d31011dd9552","html_url":"https://github.com/rodion-arr/nestjs-starter-kit","commit_stats":null,"previous_names":[],"tags_count":0,"template":true,"template_full_name":null,"purl":"pkg:github/rodion-arr/nestjs-starter-kit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rodion-arr%2Fnestjs-starter-kit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rodion-arr%2Fnestjs-starter-kit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rodion-arr%2Fnestjs-starter-kit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rodion-arr%2Fnestjs-starter-kit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rodion-arr","download_url":"https://codeload.github.com/rodion-arr/nestjs-starter-kit/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rodion-arr%2Fnestjs-starter-kit/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29053274,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-03T15:43:47.601Z","status":"ssl_error","status_checked_at":"2026-02-03T15:43:46.709Z","response_time":96,"last_error":"SSL_read: 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":["docker","jwt","nestjs","postgres","redis","typeorm"],"created_at":"2026-02-03T18:44:14.855Z","updated_at":"2026-02-03T18:44:15.400Z","avatar_url":"https://github.com/rodion-arr.png","language":"TypeScript","funding_links":["https://patreon.com/rodion_arr"],"categories":[],"sub_categories":[],"readme":"# Nest.js starter kit\n\n[![Test](https://github.com/rodion-arr/nestjs-starter-kit/actions/workflows/test.yml/badge.svg)](https://github.com/rodion-arr/nestjs-starter-kit/actions/workflows/test.yml) [![codecov](https://codecov.io/gh/rodion-arr/nestjs-starter-kit/branch/main/graph/badge.svg?token=NGR0C23CMW)](https://codecov.io/gh/rodion-arr/nestjs-starter-kit)\n\nThis is a starter kit for typical Nest.js REST API project.\n\n## Motivation\n\nThe main goal of this project is to provide fully functional [Nest.js](https://nestjs.com/) app which can be used as a started kit for creating your own REST APIs.\n\nUsually it is not enough to just run `$ nest new project` and start writing required business logic. Nest.js provides a minimal application out of the box with only one controller and service. In most cases it is required to pull and setup a bunch of additional packages from Nest.js ecosystem like `typeorm`, `passport`, `cache-manager`, DTO validators etc.\n\nThis repo provides an already configured REST API project with commonly used Nest.js packages (full list below) so you can just copy it and start writing your business logic and not waste your time for boilerplate configuration.\n\n## Features\n\n- [Dockerized local development](#dockerized-local-development)\n- [Configuration via ENV variables](#configuration-via-env-variables)\n- [Validation via DTO](#validation-via-dto)\n- [DB migrations](#db-migrations)\n- [Redis cache](#redis-cache)\n- [JWT auth with passport.js](#jwt-auth-with-passportjs)\n- [Logger with TraceID generation](#logger-with-trace-id-generation)\n- [Graceful shutdown](#graceful-shutdown)\n- [Automatic APIs documentation with Swagger](#automatic-apis-documentation-with-swagger)\n- [Sending emails](#e-mail-service-with-local-mail-trap)\n- [Unit tests](#unit-tests)\n- [Health check](#health-check)\n\n### Dockerized local development\n\nYou are getting fully functional docker environment for development with Postgres DB, Redis and utility services such as local SMTP server. You can spin-up all server dependencies with only 1 command without need of setting up DB and Redis servers manually.\n\nCheck out [.docker-node-api](./.docker-node-api) folder and [installation guide](#installation) for more details.\n\n### Configuration via ENV variables\n\nAccording to [12 factor app](https://12factor.net/config) - it is recommended to store application config in Environment Variables. This technique allows you to build the bundle once and deploy it to multiple target server (e.g. QA, Staging, Prod) without code modifications. Each target environment will have different configuration values which application retrieves from environment variables.\n\nThis project provides a set of config values out of the box e.g. for connecting to DB and Cache server. Check out [app.module.ts](./api/src/app.module.ts#L14) and [configuration.ts](./api/src/services/app-config/configuration.ts) for more details.\n\n### Validation via DTO\n\nGlobal [ValidationPipeline](./api/src/main.ts) enabled and requests to APIs are validated via [DTOs](./api/src/user/dto).  \n\n### DB migrations\n\n`TypeORM` DB migrations are already set up for you in [./api/src/db/migrations](./api/src/db/migrations) folder.\n\nTo generate new migration run:\n\n```console\nnpm run migrations:new -- src/db/migrations/Roles\n```\n\nTo apply migrations run:\n\n```console\nnpm run migrations:up\n```\n\nTo revert migrations run:\n\n```console\nnpm run migrations:revert\n```\n\n### Redis cache\n\n[cache-manager](https://github.com/BryanDonovan/node-cache-manager#readme) package with Redis store is available in [app-cache.module.ts](./api/src/app-cache/app-cache.module.ts).\n\nSo it is possible to use [`CacheInterceptor`](./api/src/user/user.controller.ts#L50) above you controller methods or classes:\n\n```typescript\n  @UseInterceptors(CacheInterceptor)\n  @Get()\n  async getUsers() {}\n```\n\nOr inject `CacheManager` and use it directly:\n\n```typescript\nconstructor(@Inject(CACHE_MANAGER) private cacheManager: Cache) {}\n\nawait this.cacheManager.set('test', 'test', {\n  ttl: 10, // in seconds\n} as any);\n\nawait this.cacheManager.get('key');\n```\n\n### JWT auth with passport.js\n\nJWT authentication is configured and available to use.\n\nUser registration, login and JWT-protected API examples were added in [user.controller.ts](./api/src/user/user.controller.ts)  \n\n### Logger with Trace ID generation\n\n[Pino](https://github.com/pinojs/pino) added as application logger.\n\nEach request to API is signed with unique TraceID and passed to logger via [AsyncLocalStorage](https://nodejs.org/api/async_context.html#class-asynclocalstorage).\n\nCode can be found in [async-storage.middleware.ts](./api/src/global/middleware/async-storage/async-storage.middleware.ts) and [app-logger.service.ts](./api/src/logger/services/app-logger/app-logger.service.ts)\n\n\u003cimg width=\"799\" alt=\"TraceID in logs example\" src=\"https://user-images.githubusercontent.com/5843270/143482882-84c51e0e-0e54-407b-8ed7-cf7b8536f7e3.png\"\u003e\n\n### Graceful shutdown\n\nNest.js [shutdown hooks](https://docs.nestjs.com/fundamentals/lifecycle-events#application-shutdown) are enabled.\n\nThis starter kit subscribed to `OnModuleDestroy` event and [disconnects](./api/src/app-cache/app-cache.module.ts) from Redis gracefully.\n\n### Automatic APIs documentation with Swagger\n\nNest.js swagger module configured with the use of [Swagger CLI plugin](https://docs.nestjs.com/openapi/cli-plugin).\n\nAPI docs are generated with the start of app server automatically and available at [http://localhost:3000/api](http://localhost:3000/api):\n\n\u003cimg width=\"1485\" alt=\"Swagger doc generated\" src=\"https://user-images.githubusercontent.com/5843270/143483373-a0f3fd48-4f27-4d53-9b8f-6b80bc147d48.png\"\u003e\n\n### E-mail service with local mail trap\n\nMail service is available out of the box and can be used like this:\n\nInject in constructor:\n```typescript\nconstructor(\n  private readonly mailer: MailService,\n) {}\n```\n\nSend mail:\n```typescript\nawait this.mailer.send({\n  to: 'to-mail@example.com',\n  from: this.mailer.from(),\n  subject: 'User registered',\n  text: 'Mail body',\n});\n```\n\nYou can check sent mails by opening http://localhost:8025/ and browse MailHog UI.\n\n![MailHog UI](https://user-images.githubusercontent.com/5843270/143854275-1415cf0d-0003-4744-9f25-4649a1b406c9.png)\n\nPowered by [nodemailer](https://www.npmjs.com/package/nodemailer).\n\n### Unit tests\n\nAll code added in the project is covered with [unit tests](https://github.com/rodion-arr/nestjs-starter-kit/search?q=describe).\n\nYou can find useful tests examples of:\n\n- DB repository mock [(auth.service.spec.ts)](./api/src/user/services/auth/auth.service.spec.ts). Search for `getRepositoryToken`.\n- Controller test [(user.controller.spec.ts)](./api/src/user/user.controller.spec.ts)\n- Middleware test [(async-storage.middleware.spec.ts)](./api/src/global/middleware/async-storage/async-storage.middleware.spec.ts)\n- Service test [(jwt.service.spec.ts)](./api/src/user/services/jwt/jwt.service.spec.ts)\n\n## Health check\n\nHealth check endpoint is available at [http://localhost:3000/health](http://localhost:3000/health) and returns 200 OK if server is healthy. This endpoint also checks DB and Redis connections.\n\n## Installation\n\n### Prerequisites\n\n- Docker for Desktop\n- Node.js LTS\n\n### Getting started\n\n- Clone the repository \n```console\ngit clone https://github.com/rodion-arr/nestjs-starter-kit.git\n```\n\n- Run docker containers (DB, Redis, etc)\n```console\ncd nestjs-starter-kit/.docker-node-api\ndocker-compose up -d\n```\n\n- Go to api folder and copy env file\n```console\ncd ../api\ncp .env.example .env\n```\n\n- Update .env file with credentials if needed\n\n- Next install dependencies\n```console\nnpm ci\n```\n\n- Init config and run migrations\n```console\nnpm run migrations:up\n```\n\n- Run application\n```console\nnpm start\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frodion-arr%2Fnestjs-starter-kit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frodion-arr%2Fnestjs-starter-kit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frodion-arr%2Fnestjs-starter-kit/lists"}