DEV Community

Mehdi Hassan Jony
Mehdi Hassan Jony

Posted on

I built a CLI that installs a production-ready Auth system into any NestJS project in < 5 mins

Image showing the contrast between 'manual auth configuration' and 'instant one-command setup'

The "Day One" NestJS Fatigue

Every time I start a new NestJS project, I get a brief moment of excitement... followed by the realization that I have to build Auth again.

We’ve all been there. You spend 3 days setting up:

  • JWT strategies and refresh token rotation.
  • Password hashing with Bcrypt or Argon2.
  • Passport strategies for Google/GitHub.
  • Database schemas for Users and Roles.
  • Docker Compose for Redis and Postgres.
  • Swagger docs so the frontend team stops asking for endpoints.

It’s the same 80% of code every time. So, I decided to automate it.

Introducing @mehdijony/nestjs-user-service

I built a CLI tool that doesn't just scaffold a new project—it installs a complete, high-performance user management engine into your existing project.

⚡️ The 5-Minute Setup

In your terminal, just run:

npx @mehdijony/nestjs-user-service init
Enter fullscreen mode Exit fullscreen mode

The CLI kicks off an interactive session. It’s smart enough to detect your stack:

  • Package Manager: npm, yarn, pnpm, or bun.
  • ORM: Prisma, TypeORM, Mongoose, or Drizzle.
  • Environment: It reads your .env and docker-compose.yml to ensure zero conflicts.

🛠 What's under the hood?

I didn't want this to be "just another boilerplate." It’s built for senior-level requirements:

1. The Modular Architecture

It generates a src/user-service/ directory with a clean separation of concerns. It even injects the UserServiceModule into your AppModule automatically.

2. Multi-Driver Support

Whether you are a Prisma fan or a TypeORM veteran, the CLI generates the correct entities and repositories for your chosen database (Postgres, MySQL, MongoDB, etc.).

3. Safety First (The Rollback Engine)

This is my favorite feature. Modifying source code is scary.
Before the CLI touches a single line, it creates a Restore Point.

If you don't like the result, or something goes wrong:

npx @mehdijony/nestjs-user-service rollback
Enter fullscreen mode Exit fullscreen mode

It uninstalls the packages, deletes the generated files, and restores your app.module.ts and .env to their exact original state. Zero footprint.


📦 Feature Checklist

Category Features
Auth JWT, Refresh Tokens, Magic Links, OTP, Social OAuth
Security 2FA (TOTP), RBAC, Rate Limiting, Account Lockout
Infra Redis Caching, BullMQ/Kafka, S3 File Uploads
DevOps Auto-Swagger, Health Checks, Docker Compose Merge

🚀 Why I built this

As a Backend Engineer, I want to spend my time on unique business logic, not re-writing the same AuthService for the 10th time. This tool is for the solo dev who needs to ship fast and the agency team that wants a standardized auth foundation across all projects.

Give it a spin

I'd love to get the community's feedback on this. If it saves you a few days of work, drop a star on GitHub!

NPM: [https://www.npmjs.com/package/@mehdijony/nestjs-user-service]
GitHub: [https://www.github.com/mehdijony/nestjs-user-service]

What feature should I add next? LDAP support? SAML? Let me know in the comments! 👇


Top comments (0)