{"_id":"@dylantovar/nestjs-auth-kit","_rev":"3-ab807a36e03275ab8f2817339fdc7269","name":"@dylantovar/nestjs-auth-kit","dist-tags":{"latest":"1.0.3"},"versions":{"1.0.0":{"name":"@dylantovar/nestjs-auth-kit","version":"1.0.0","keywords":["nestjs","auth","cli","scaffolder","jwt","typeorm"],"author":"Dylan Tovar","license":"MIT","_id":"@dylantovar/nestjs-auth-kit@1.0.0","maintainers":[{"name":"dylantovar","email":"dylantovar.stem@gmail.com"}],"bin":{"nestjs-auth-kit":"./dist/index.js"},"dist":{"shasum":"df2ef6dd2fc1e0600ef8a9cfc25f861c1cbde072","tarball":"https://registry.npmjs.org/@dylantovar/nestjs-auth-kit/-/nestjs-auth-kit-1.0.0.tgz","fileCount":45,"integrity":"sha512-cxC265T+TmXxoG7wZ/YOiPp99bTlgyUwJL117rmAIEQHg5KK9V82AwxRJZn2OVJ0kb1aLLpBnzvl5Pl+9fcSgw==","signatures":[{"sig":"MEUCIQDQGVbRWTz6+ZEWKJJql3td+ymMMu+2mZTxQmsfrOuEoAIgSSs4Fgo3s/cTkvOo6PGjndT4R1KkHHAQRITIDiZ4CSM=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":68249},"main":"./dist/index.js","type":"module","engines":{"node":">=18"},"scripts":{"build":"rm -rf dist && tsc && cp -R src/templates dist/templates","start":"node --loader ts-node/esm src/index.ts"},"_npmUser":{"name":"dylantovar","email":"dylantovar.stem@gmail.com"},"repository":{"url":"https://github.com/dylantovar/nestjs-auth-kit.git","type":"git"},"description":"CLI scaffolder that generates a production-ready auth module for NestJS","directories":{},"_nodeVersion":"22.17.0","dependencies":{"ejs":"^6.0.1","ora":"^9.4.0","chalk":"^5.6.2","fs-extra":"^11.3.5","inquirer":"^14.0.2","commander":"^15.0.0"},"_hasShrinkwrap":false,"devDependencies":{"ts-node":"^10.9.2","@types/ejs":"^3.1.5","typescript":"^6.0.3","@types/node":"^25.9.1","@types/fs-extra":"^11.0.4","@types/inquirer":"^9.0.9"},"_npmOperationalInternal":{"tmp":"tmp/nestjs-auth-kit_1.0.0_1780798721764_0.0790176115547172","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@dylantovar/nestjs-auth-kit","version":"1.0.2","keywords":["nestjs","auth","cli","scaffolder","jwt","typeorm"],"author":"Dylan Tovar","license":"MIT","_id":"@dylantovar/nestjs-auth-kit@1.0.2","maintainers":[{"name":"dylantovar","email":"dylantovar.stem@gmail.com"}],"bin":{"nestjs-auth-kit":"./dist/index.js"},"dist":{"shasum":"dfa79d8a8876b3c77d2127778b0aee42ee790939","tarball":"https://registry.npmjs.org/@dylantovar/nestjs-auth-kit/-/nestjs-auth-kit-1.0.2.tgz","fileCount":51,"integrity":"sha512-m5wowzc5wBBW8T2qEBlB1X8yWAcTWZhzv9zk4YF6adeJoGtSSzx+2ekIL+xVezc4LVXI7C19k0o/OYbaXmL36A==","signatures":[{"sig":"MEYCIQCCPbrrTTU9lQL7T3detaWshKstriVVjzNC+HsXK9dyOgIhAJMbHQnLyGZ8XSZIbObqu9XrhWJcOqjE4luwiHujU7eh","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":73436},"main":"./dist/index.js","type":"module","engines":{"node":">=18"},"scripts":{"build":"rm -rf dist && tsc && cp -R src/templates dist/templates","start":"node --loader ts-node/esm src/index.ts"},"_npmUser":{"name":"dylantovar","email":"dylantovar.stem@gmail.com"},"repository":{"url":"https://github.com/dylantovar/nestjs-auth-kit.git","type":"git"},"description":"CLI scaffolder that generates a production-ready auth module for NestJS","directories":{},"_nodeVersion":"22.17.0","dependencies":{"ejs":"^6.0.1","ora":"^9.4.0","chalk":"^5.6.2","fs-extra":"^11.3.5","inquirer":"^14.0.2","commander":"^15.0.0"},"_hasShrinkwrap":false,"devDependencies":{"ts-node":"^10.9.2","@types/ejs":"^3.1.5","typescript":"^6.0.3","@types/node":"^25.9.1","@types/fs-extra":"^11.0.4","@types/inquirer":"^9.0.9"},"_npmOperationalInternal":{"tmp":"tmp/nestjs-auth-kit_1.0.2_1780804885215_0.48355622898859774","host":"s3://npm-registry-packages-npm-production"}},"1.0.3":{"name":"@dylantovar/nestjs-auth-kit","version":"1.0.3","description":"CLI scaffolder that generates a production-ready auth module for NestJS","main":"./dist/index.js","bin":{"nestjs-auth-kit":"dist/index.js"},"engines":{"node":">=18"},"repository":{"type":"git","url":"git+https://github.com/dylan-tovar/nestjs-auth-kit.git"},"scripts":{"build":"rm -rf dist && tsc && cp -R src/templates dist/templates","start":"node --loader ts-node/esm src/index.ts","prepublishOnly":"pnpm build"},"keywords":["nestjs","auth","cli","scaffolder","jwt","typeorm"],"author":{"name":"Dylan Tovar"},"license":"MIT","packageManager":"pnpm@11.5.0","type":"module","dependencies":{"chalk":"^5.6.2","commander":"^15.0.0","ejs":"^6.0.1","fs-extra":"^11.3.5","inquirer":"^14.0.2","ora":"^9.4.0"},"devDependencies":{"@semantic-release/changelog":"^6.0.3","@semantic-release/git":"^10.0.1","@semantic-release/github":"^12.0.8","@semantic-release/npm":"^13.1.5","@types/ejs":"^3.1.5","@types/fs-extra":"^11.0.4","@types/inquirer":"^9.0.9","@types/node":"^25.9.1","semantic-release":"^25.0.3","ts-node":"^10.9.2","typescript":"^6.0.3"},"_id":"@dylantovar/nestjs-auth-kit@1.0.3","gitHead":"26fe33d51cb2b8a314e549a520fa0b8c0b4c9061","types":"./dist/index.d.ts","bugs":{"url":"https://github.com/dylan-tovar/nestjs-auth-kit/issues"},"homepage":"https://github.com/dylan-tovar/nestjs-auth-kit#readme","_nodeVersion":"22.22.3","_npmVersion":"10.9.8","dist":{"integrity":"sha512-+TxMkimX36J4bh4r2HX5HkxVpqoGc3u8+gsaHLL8WsJqo/Rc+lteobHax50JpMGxSJyfMugJXet7niHiq0nwTA==","shasum":"0f7e2fca463cfd0338f4d820c6a336681dfbfbf0","tarball":"https://registry.npmjs.org/@dylantovar/nestjs-auth-kit/-/nestjs-auth-kit-1.0.3.tgz","fileCount":51,"unpackedSize":76735,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIB9VJSrLpaBB4U5+YaD9r087D25RWG1L55a6oEQsHyQDAiAv92RhqiD7iLq786LhrJPQtRnx8GDiiKf7FSqG51nR1A=="}]},"_npmUser":{"name":"dylantovar","email":"dylantovar.stem@gmail.com"},"directories":{},"maintainers":[{"name":"dylantovar","email":"dylantovar.stem@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/nestjs-auth-kit_1.0.3_1781727622225_0.2603798995339226"},"_hasShrinkwrap":false}},"time":{"created":"2026-06-07T02:18:41.575Z","modified":"2026-06-17T20:20:22.460Z","1.0.0":"2026-06-07T02:18:41.885Z","1.0.2":"2026-06-07T04:01:25.391Z","1.0.3":"2026-06-17T20:20:22.364Z"},"author":{"name":"Dylan Tovar"},"license":"MIT","keywords":["nestjs","auth","cli","scaffolder","jwt","typeorm"],"repository":{"type":"git","url":"git+https://github.com/dylan-tovar/nestjs-auth-kit.git"},"description":"CLI scaffolder that generates a production-ready auth module for NestJS","maintainers":[{"name":"dylantovar","email":"dylantovar.stem@gmail.com"}],"readme":"<p align=\"center\">\n  <img src=\"https://img.shields.io/npm/v/@dylantovar/nestjs-auth-kit?color=E0234E&label=npm&logo=npm\" alt=\"npm version\" />\n  <img src=\"https://img.shields.io/badge/Node.js-%3E%3D18-339933?logo=node.js&logoColor=white\" alt=\"Node.js\" />\n  <img src=\"https://img.shields.io/badge/NestJS-%3E%3D10-E0234E?logo=nestjs&logoColor=white\" alt=\"NestJS\" />\n  <img src=\"https://img.shields.io/badge/license-MIT-blue\" alt=\"License\" />\n</p>\n\n<h1 align=\"center\">nestjs-auth-kit</h1>\n\n<p align=\"center\">\n  CLI scaffolder that generates a complete authentication module inside an existing NestJS project.<br/>\n  No manual wiring required.\n</p>\n\n<p align=\"center\">\n  <a href=\"#installation\">Installation</a> ·\n  <a href=\"#interactive-flow\">Usage</a> ·\n  <a href=\"#what-it-generates\">What it generates</a> ·\n  <a href=\"#post-install-checklist\">Post-install</a> ·\n  <a href=\"#local-development\">Local development</a>\n</p>\n\n---\n\n## Installation\n\nFrom the **root of your NestJS project**:\n\n```bash\n# No global install required (recommended)\npnpm dlx @dylantovar/nestjs-auth-kit init\n\n# With npx\nnpx @dylantovar/nestjs-auth-kit init\n\n# Global\npnpm add -g @dylantovar/nestjs-auth-kit && nestjs-auth-kit init\n```\n\n**Requirements**\n\n- Node.js ≥ 18\n- NestJS project with an existing `src/app.module.ts`\n- PostgreSQL or any TypeORM-compatible database\n\n---\n\n## Interactive flow\n\nThe CLI asks up to 7 questions and adapts the output to your answers:\n\n```\n? Which ORM are you using?\n  ❯ TypeORM\n    Prisma (Coming soon)\n\n? Which JWT strategy do you want to implement?\n  ❯ Access + Refresh token rotation\n    Access token only\n\n? Add Role-Based Access Control (RBAC)?\n  ❯ Yes\n\n? Which roles will your system have?\n  default: ADMIN, USER\n\n? Add rate limiting to login endpoints?\n  ❯ Yes\n\n? Which storage backend for rate limiting?\n  ❯ In-Memory\n    Redis\n\n? Generate a docker-compose.yml for DB (and Redis if applicable)?\n  ❯ Yes\n```\n\nWhen finished, the CLI prints the exact dependency install command for your configuration and points to the `README-AUTH.md` generated in your project.\n\n---\n\n## What it generates\n\n```text\nyour-nestjs-project/\n├── .env.example                   # Environment variable reference\n├── README-AUTH.md                 # Step-by-step integration guide\n├── docker-compose.yml             # ← optional (PostgreSQL + Redis)\n│\n└── src/\n    ├── config/\n    │   ├── configuration.ts       # Typed env config\n    │   ├── env.validation.ts      # Joi validation on boot\n    │   └── database.config.ts     # TypeORM + DataSource for migrations\n    │\n    └── modules/\n        └── auth/\n            ├── auth.module.ts\n            ├── auth.controller.ts\n            ├── auth.service.ts\n            ├── account.entity.ts\n            ├── refresh-token.entity.ts        # ← Access + Refresh only\n            ├── dto/\n            │   ├── login.dto.ts\n            │   ├── register.dto.ts\n            │   └── refresh-token.dto.ts       # ← Access + Refresh only\n            ├── enums/\n            │   └── role.enum.ts               # ← RBAC only\n            ├── guards/\n            │   ├── jwt-auth.guard.ts\n            │   └── roles.guard.ts             # ← RBAC only\n            ├── decorators/\n            │   ├── current-user.decorator.ts\n            │   └── roles.decorator.ts         # ← RBAC only\n            └── strategies/\n                ├── jwt.strategy.ts\n                └── jwt-refresh.strategy.ts    # ← Access + Refresh only\n```\n\n### Endpoints\n\n| Method | Path             | Auth          | Notes                              |\n| ------ | ---------------- | ------------- | ---------------------------------- |\n| `POST` | `/auth/register` | —             | Creates account                    |\n| `POST` | `/auth/login`    | —             | Rate limited if enabled            |\n| `POST` | `/auth/refresh`  | Refresh token | Access + Refresh only              |\n| `POST` | `/auth/logout`   | JWT / Refresh | Revokes token if applicable        |\n| `POST` | `/auth/me`       | JWT           | Returns authenticated user payload |\n\n---\n\n## Features\n\n| Feature                  | Description                                                              |\n| ------------------------ | ------------------------------------------------------------------------ |\n| **Interactive CLI**      | Dynamic prompts; output adapts to your choices                           |\n| **TypeORM + PostgreSQL** | Entities, DB config and DataSource for migrations _(Prisma on roadmap)_  |\n| **Flexible JWT**         | Access token only or Access + Refresh with rotation and DB revocation    |\n| **RBAC**                 | Custom roles at setup, `@Roles()` decorator and exported `RolesGuard`    |\n| **Rate limiting**        | `@nestjs/throttler` on login — In-Memory or distributed Redis            |\n| **Docker Compose**       | PostgreSQL + Redis optional; does not overwrite an existing compose file |\n| **Typed config**         | `configuration.ts` + Joi validation on startup                           |\n| **`.env.example`**       | Auto-generated with variables based on your configuration                |\n| **`README-AUTH.md`**     | Integration guide with curl examples, Docker steps and RBAC example      |\n\n### Production-grade practices\n\nThe generated code is not a tutorial snippet:\n\n- `bcrypt` with `saltRounds: 12`\n- Refresh token rotation — every refresh revokes the previous token and issues a new one\n- DB revocation with `revokedAt` (records are marked, not deleted)\n- Uniform `INVALID_CREDENTIALS` error — does not reveal whether the email exists or the password is wrong\n- DTOs with `class-validator` and `@Transform` for input normalization\n\n---\n\n## Configuration options\n\n### JWT: Access + Refresh vs Access token only\n\n|                   | Access token only       | Access + Refresh                     |\n| ----------------- | ----------------------- | ------------------------------------ |\n| Complexity        | Minimal                 | Full                                 |\n| Expiry            | Long-lived token (~24h) | Short access (~15min) + long refresh |\n| Remote revocation | No                      | Yes — `revokedAt` in DB              |\n| Best for          | Internal APIs, MVPs     | SaaS, mobile apps, production        |\n\n### Rate limiting: In-Memory vs Redis\n\n|          | In-Memory                  | Redis                              |\n| -------- | -------------------------- | ---------------------------------- |\n| Setup    | Zero extra config          | Requires Redis                     |\n| Scaling  | Single instance            | Multiple instances + load balancer |\n| Best for | Single server, development | Horizontal production              |\n\n`ThrottlerGuard` is registered as `APP_GUARD` inside `AuthModule` — it applies to the entire app once you import `AuthModule`. Default limits: **5 req/min** on `/auth/login`, **10 req/min** everywhere else.\n\nTo exclude routes use `@SkipThrottle()`:\n\n```typescript\nimport { SkipThrottle } from '@nestjs/throttler';\n\n@Get('health')\n@SkipThrottle()\ncheck() { return { status: 'ok' }; }\n```\n\n---\n\n## Environment variables\n\nThe CLI generates `.env.example`. Copy it and fill in your values:\n\n```bash\ncp .env.example .env\n```\n\n```env\nNODE_ENV=development\nPORT=3000\nAPP_URL=http://localhost:3000\nFRONTEND_URL=http://localhost:3001\n\n# JWT — minimum 32 characters (validated on startup)\nJWT_ACCESS_SECRET=change_me_to_a_secret_with_at_least_32_chars\nJWT_ACCESS_EXPIRES=15m\n\n# Access + Refresh only\nJWT_REFRESH_SECRET=another_secret_with_at_least_32_characters\nJWT_REFRESH_EXPIRES=7d\n\n# Database\nDB_HOST=localhost\nDB_PORT=5432\nDB_USER=postgres\nDB_PASSWORD=postgres\nDB_NAME=postgres\n\n# Rate limiting + Redis only\nREDIS_HOST=localhost\nREDIS_PORT=6379\nREDIS_PASSWORD=change_me\n```\n\n---\n\n## Post-install checklist\n\n```bash\n# 1. Install dependencies (the CLI prints the exact command when it finishes)\npnpm add @nestjs/passport passport passport-jwt @nestjs/jwt ...\n\n# 2. Set up environment variables\ncp .env.example .env\n\n# 3. Import AuthModule and ConfigModule in app.module.ts\n\n# 4. Start the database\ndocker compose up -d\n\n# 5. Create the auth schema in PostgreSQL\ndocker compose exec postgres psql -U postgres -d postgres -c \"CREATE SCHEMA auth;\"\n\n# 6. Run migrations\npnpm typeorm migration:run\n\n# 7. Test\ncurl -X POST http://localhost:3000/auth/register \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"email\":\"test@example.com\",\"password\":\"password123\"}'\n```\n\n> Steps 3–7 are detailed with full code in the **`README-AUTH.md`** generated in your project.\n\n---\n\n## Local development\n\n```bash\ngit clone https://github.com/dylantovar/nestjs-auth-kit.git\ncd nestjs-auth-kit\npnpm install\npnpm build\n\n# Test against a clean NestJS project\ncd /path/to/your-nestjs-project\nnode /path/to/nestjs-auth-kit/dist/index.js init\n```\n\n### CLI stack\n\n| Dependency  | Role                |\n| ----------- | ------------------- |\n| `commander` | Command parsing     |\n| `inquirer`  | Interactive prompts |\n| `ejs`       | Template engine     |\n| `chalk`     | Colored output      |\n| `ora`       | Loading spinners    |\n| `fs-extra`  | File writing        |\n\n### Repository structure\n\n```text\nnestjs-auth-kit/\n├── src/\n│   ├── index.ts\n│   ├── commands/init.ts\n│   ├── prompts/questions.ts\n│   ├── generators/\n│   │   ├── template.renderer.ts   # Shared EJS engine\n│   │   ├── config.generator.ts    # src/config/* + .env.example\n│   │   ├── auth.generator.ts      # src/modules/auth/*\n│   │   └── docker.generator.ts    # docker-compose.yml\n│   └── templates/\n│       ├── config/\n│       ├── docker/\n│       ├── dto/\n│       ├── guards/\n│       ├── decorators/\n│       ├── strategies/\n│       ├── enums/\n│       └── orm/typeorm/\n├── package.json\n├── tsconfig.json\n└── README.md\n```\n\n---\n\n## Roadmap\n\n- [x] TypeORM + PostgreSQL\n- [x] JWT Access + Refresh with rotation and revocation\n- [x] RBAC with custom roles\n- [x] Rate limiting (In-Memory / Redis)\n- [x] Docker Compose\n- [x] `.env.example` + Joi validation\n- [ ] Prisma support\n- [ ] Automatic `app.module.ts` modifiers\n- [ ] Generation tests + CI\n- [ ] npm publish\n\n---\n\n## License\n\n[MIT](./LICENSE)\n","readmeFilename":"README.md","homepage":"https://github.com/dylan-tovar/nestjs-auth-kit#readme","bugs":{"url":"https://github.com/dylan-tovar/nestjs-auth-kit/issues"}}