{"id":22821836,"url":"https://github.com/onix-systems/nest-js-boilerplate","last_synced_at":"2025-04-06T01:06:07.669Z","repository":{"id":38535244,"uuid":"293843285","full_name":"Onix-Systems/nest-js-boilerplate","owner":"Onix-Systems","description":"Nest.js boilerplate","archived":false,"fork":false,"pushed_at":"2023-05-30T06:47:39.000Z","size":3754,"stargazers_count":227,"open_issues_count":0,"forks_count":42,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-02-19T13:09:55.464Z","etag":null,"topics":["api","boilerplate","commitizen","docker","generator","google-auth","heroku","jwt","mongodb","mysql","nest-boilerplate","nestjs","passport","rest-api","starter","starter-kit","typescript","yeoman"],"latest_commit_sha":null,"homepage":"https://onix-systems.com/","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/Onix-Systems.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2020-09-08T14:57:56.000Z","updated_at":"2025-02-16T16:45:53.000Z","dependencies_parsed_at":"2024-09-18T11:42:46.973Z","dependency_job_id":"34577e4c-b164-457f-a079-8351ef99d209","html_url":"https://github.com/Onix-Systems/nest-js-boilerplate","commit_stats":{"total_commits":188,"total_committers":17,"mean_commits":"11.058823529411764","dds":0.7180851063829787,"last_synced_commit":"c29526e932423894c66d71498b048a184850b7f1"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Onix-Systems%2Fnest-js-boilerplate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Onix-Systems%2Fnest-js-boilerplate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Onix-Systems%2Fnest-js-boilerplate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Onix-Systems%2Fnest-js-boilerplate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Onix-Systems","download_url":"https://codeload.github.com/Onix-Systems/nest-js-boilerplate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247419859,"owners_count":20936012,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["api","boilerplate","commitizen","docker","generator","google-auth","heroku","jwt","mongodb","mysql","nest-boilerplate","nestjs","passport","rest-api","starter","starter-kit","typescript","yeoman"],"created_at":"2024-12-12T16:09:07.444Z","updated_at":"2025-04-06T01:06:07.651Z","avatar_url":"https://github.com/Onix-Systems.png","language":"TypeScript","funding_links":["https://www.buymeacoffee.com/chechavalerii"],"categories":[],"sub_categories":[],"readme":"[![\"Buy Me A Coffee\"](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/chechavalerii)\n\n# Nest.js boilerplate\n\n[![onix](https://img.shields.io/badge/onix-systems-blue.svg)](https://onix-systems.com/)\n[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)\n[![Downloads Month](https://img.shields.io/jsdelivr/npm/hm/generator-nestjs-boilerplate?style=flat\u0026color=green)](https://www.npmjs.com/package/generator-nest-js-boilerplate)\n[![Typescript for types](https://img.shields.io/npm/types/typescript)](https://www.typescriptlang.org/)\n[![Our rating](https://img.shields.io/librariesio/sourcerank/npm/generator-nest-js-boilerplate?color=green\u0026label=Rating)](https://www.npmjs.com/package/generator-nest-js-boilerplate)\n[![License](https://img.shields.io/npm/l/generator-nest-js-boilerplate)](https://www.npmjs.com/package/generator-nest-js-boilerplate)\n[![Issues](https://img.shields.io/github/issues/Onix-Systems/nest-js-boilerplate?color=green)](https://github.com/Onix-Systems/nest-js-boilerplate/issues)\n[![Latest package version](https://img.shields.io/npm/v/generator-nest-js-boilerplate)](https://www.npmjs.com/package/generator-nest-js-boilerplate)\n[![Dependencies](https://img.shields.io/librariesio/release/npm/@onix-systems/generator-nestjs-boilerplate)](https://www.npmjs.com/package/generator-nest-js-boilerplate)\n[![Organization stars](https://img.shields.io/github/stars/Onix-Systems?label=Onix%20Stars\u0026style=social)](https://github.com/Onix-Systems)\n[![Travis build passing](https://api.travis-ci.org/Onix-Systems/nest-js-boilerplate.svg?branch=master)](https://github.com/Onix-Systems/nest-js-boilerplate)\n\n\u003e Node.js Nest.js API. Supports MongoDB, Mysql, Redis\n\n## Related projects\n\nCurrently, we have 1 related project:\n\n[![Nest.js Prisma MongoDB](https://github-readme-stats.vercel.app/api/pin/?username=nodeteamdev\u0026repo=nestjs-prisma-mongodb)](https://github.com/nodeteamdev/nestjs-prisma-mongodb)\n\n\n## Description\n\nThis boilerplate will help you bootstrap your own Nest.JS/MongoDB/MySQL/Typescript API quickly with common enterprise configurations done for you.\n\n### Project Overview\n\n- Admin.js\n- Support ES6/ES7 features\n- Using Eslint followed [Airbnb JavaScript Style Guide](https://github.com/airbnb/javascript)\n- Husky\n- Commitizen\n- MIT license and Code of conduct\n- Docker\n- Prettier\n- Nest.JS 8\n\n## Features\n\n### Authentication\n\n- PassportJS local strategy\n- JWT authentication (using passport-jwt)\n- Passport OAuth 2.0 strategy (for Google)\n\n### AdminJS\n\nAdminJS is available to use if you select Mongo + JWT/Passport, on the route:\n\n```bash\nhttp://localhost:3000/admin\n```\n\nIf you are not logged in, you will be redirected to the admin login page.\n\n```bash\nhttp://localhost:3000/admin/login\n```\n\nTo login in the admin panel, you should have a **verified user** registered with the `admin` role.\n\nTo create a default admin user, run the provided migrations:\n\n```bash\nnpm install migrate-mongo\n\nnpx migrate-mongo up\n```\n\nThe migrations will create a default admin user in the database with following credentials:\n\n```bash\nlogin: admin@test.com\npassword: String_12345\n```\n\n![Alt Text2](https://media.giphy.com/media/HdWGgOGfQa0QRLNXME/giphy.gif)\n\n_Note: admin can be generated only with mongo + jwt/passport_\n\n### Roles\nFor now, we have implemented only two roles: `user` and `admin`\n\nUsage example:\n\n```typescript\n@Auth(RolesEnum.ADMIN, RolesEnum.USER)\n```\nor for all roles:\n\n```typescript\n@Auth()\n```\n\n_Note: before using it with sql databases, you must run migrations._\n\n### Serialization\nUse `@Serialize` decorator to process the objects before they are returned in the network response\nExample:\n\n```typescript\n @Serialize(UserResponseDto)\n```\nuse `@Exclude` decorator to exclude properties from serialization\n```typescript\n  @Exclude()\n  password: string = '';\n```\n\n### Session Storage\n\n- MongoDB\n- Redis\n- MySQL\n\n### Email Sending\n\n- Nodemailer\n\n## Requirements\n\n- node \u003e= 14\n- npm \u003e= 7\n- mongodb \u003e= 4.0\n- redis \u003e= 4.0\n- mysql \u003e= 2.0\n- typescript \u003e= 4.0.3\n\n## Installation\n\nFirst, install [Yeoman](http://yeoman.io) and generator-nest-js-boilerplate using [npm](https://www.npmjs.com/) (we assume you have pre-installed [node.js](https://nodejs.org/)).\n\n```bash\nnpm install -g yo\nnpm install -g generator-nest-js-boilerplate\n```\n\nThen generate your new project:\n\n```bash\nyo nest-js-boilerplate\n```\n\nExample App Skeleton (for Mongo + JWT)\n\n```bash\n├── docker\n│   └── App.Dockerfile\n├── src\n│   ├── constants\n│   │   └── common.constants.ts\n│   ├── decorators\n│   │   ├── auth-bearer.decorator.ts\n│   │   ├── auth.decorator.ts\n│   │   ├── roles.decorator.ts\n│   │   └── serialization.decorator.ts\n│   ├── exceptions\n│   │   └── validation.exceptions.ts\n│   ├── filters\n│   │   ├── all-exceptions.filter.ts\n│   │   ├── bad-request-exception.filter.ts\n│   │   ├── forbidden-exception.filter.ts\n│   │   ├── index.ts\n│   │   ├── not-found-exception.filter.ts\n│   │   ├── unauthorized-exception.filter.ts\n│   │   ├── validation-exceptions.filter.ts\n│   │   └── ws-exceptions.filter.ts\n│   ├── guards\n│   │   ├── jwt-access.guard.ts\n│   │   ├── jwt-refresh.guard.ts\n│   │   ├── jwt-ws-access.guard.ts\n│   │   └── roles.guard.ts\n│   ├── interceptors\n│   │   ├── serialization.interceptor.ts\n│   │   └── wrap-response.interceptor.ts\n│   ├── interfaces\n│   │   ├── exception-response.interface.ts\n│   │   ├── jwt-decode-response.interface.ts\n│   │   ├── paginatedEntity.interface.ts\n│   │   └── pagination-params.interface.ts\n│   ├── main.ts\n│   ├── modules\n│   │   ├── app\n│   │   │   ├── app.controller.ts\n│   │   │   ├── app.gateway.ts\n│   │   │   ├── app.module.ts\n│   │   │   └── app.service.ts\n│   │   └── v1\n│   │       ├── auth\n│   │       │   ├── auth-constants.ts\n│   │       │   ├── auth.controller.spec.ts\n│   │       │   ├── auth.controller.ts\n│   │       │   ├── auth.module.ts\n│   │       │   ├── auth.repository.ts\n│   │       │   ├── auth.service.spec.ts\n│   │       │   ├── auth.service.ts\n│   │       │   ├── dto\n│   │       │   │   ├── jwt-tokens.dto.ts\n│   │       │   │   ├── refresh-token.dto.ts\n│   │       │   │   ├── sign-in.dto.ts\n│   │       │   │   ├── sign-up.dto.ts\n│   │       │   │   └── verify-user.dto.ts\n│   │       │   ├── guards\n│   │       │   │   └── local-auth.guard.ts\n│   │       │   ├── interfaces\n│   │       │   │   ├── decoded-user.interface.ts\n│   │       │   │   ├── jwt-strategy-validate.interface.ts\n│   │       │   │   ├── login-payload.interface.ts\n│   │       │   │   └── validate-user-output.interface.ts\n│   │       │   └── strategies\n│   │       │       ├── jwt-access.strategy.ts\n│   │       │       ├── jwt-refresh.strategy.ts\n│   │       │       ├── jwt-ws-access.strategy.ts\n│   │       │       └── local.strategy.ts\n│   │       ├── users\n│   │       │   ├── dto\n│   │       │   │   ├── update-user.dto.ts\n│   │       │   │   └── user-response.dto.ts\n│   │       │   ├── interfaces\n│   │       │   │   └── user.interface.ts\n│   │       │   ├── schemas\n│   │       │   │   └── users.schema.ts\n│   │       │   ├── users-constants.ts\n│   │       │   ├── users.controller.spec.ts\n│   │       │   ├── users.controller.ts\n│   │       │   ├── users.module.ts\n│   │       │   ├── users.repository.ts\n│   │       │   ├── users.service.spec.ts\n│   │       │   └── users.service.ts\n│   │       └── v1.module.ts\n│   ├── pipes\n│   │   └── parse-object-id.pipe.ts\n│   └── templates\n│       └── verify-password.hbs\n├── tsconfig.build.json\n├── tsconfig.json\n├── typedoc.json\n├── index.js\n├── nest-cli.json\n├── package-lock.json\n├── package.json\n├── docker-compose.yml\n└──README.md\n\n```\n\n## Running the API\n\n### Development\n\nTo start the application in development mode, run:\n\n```bash\nnpm run start:dev\n```\n\nStart the application in production environment:\n\nInstall `pm2` and `typescript` to make pm2 work with typescript codebase:\n\n```bash\nnpm install -g pm2\npm2 install typescript\n```\n\nHere is an example command to start the process with 2 instances and a load-balancer\n\n```bash\npm2 start ./dist/main.js -i 2 --no-daemon\n```\n\nExpress server listening on http://localhost:3000, in development mode\n_In development mode will watch your changes then will transpile the TypeScript code and re-run the node application automatically._\n\n### Docker\n\n1. [Install Docker](https://docs.docker.com/get-docker/)\n2. [Install docker-compose](https://docs.docker.com/compose/install/)\n\nTo run your app in docker containers, choose \"Yes\" when the generator asks you about docker.\n\n#### Now, spin up your app in docker\n\n```bash\n  docker-compose up\n```\n\n## Set up environment\n\nIn root folder you can find `.env`. You can use this config as a template for your application.\n\n## Deploy\n\n### Heroku\n\nCheck all urls to databases if they are true, they must connect to dbs which located at them own servers like mongodb on Mlab\nWhen you'll run npm run deploy:heroku you'll need to sign in on heroku. You will be redirected to login form.\n\n**Check all database URLs to be valid. They should connect to their respective hosted instances (local or otherwise).**\n\n_Note: you may need to sign in on heroku (if not done already). You will be redirected to Heroku login, if required, by the cli._\n\n```bash\nnpm run deploy:heroku\n```\n\n### Jwt auth\n\n![Alt Text2](https://media.giphy.com/media/QUKuolFMyd0WsNFIUH/giphy.gif)\n\n### Oauth2 auth\n\n![Alt Text3](https://media.giphy.com/media/RiWDyLQwXaJXu972SM/giphy.gif)\n\nTo initiate the google sign-in, use http://localhost:3000/google. Once authorized, you will be redirected to http://localhost:3000/google/redirect.\n\n## Documentation\n\n### WebSocket API\n\n#### TypeDoc\n\nTypeDoc documentation will be available after entering the command:\n\n```bash\nnpm run docs\n```\n\nThis will build the documentation in a subfolder with `index.html` as the entrypoint. You can open the `index.html` in a web browser to explore the documentation or host the subdirectory using a simple http server like `lite-server` using the following command.\n\n```bash\nnpx lite-server ./path/to/documentation/\n```\n\n### REST API\n\n#### Swagger\n\nSwagger documentation will be available on route:\n\n```bash\nhttp://localhost:3000/api\n```\n\n\u003e Please note: \u003c/br\u003e\n\u003e Users are not verified by default. Please set ```\"verified\": true```, for sign-in request.\n\n\n![Alt Text1](https://media.giphy.com/media/XEUyeEL03IcaZYw6SB/giphy.gif)\n\n\n## Buy me a coffee\n\nYou can support by buying a coffee ☕️ here - [https://www.buymeacoffee.com/chechavalerii](https://www.buymeacoffee.com/chechavalerii)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fonix-systems%2Fnest-js-boilerplate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fonix-systems%2Fnest-js-boilerplate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fonix-systems%2Fnest-js-boilerplate/lists"}