NestJS auth API
Register, verify, log in, refresh with rotation and reuse detection, reset passwords and manage roles, on NestJS, Prisma and MySQL, tested end to end.
$10Version 1.0.0
How buying works: message me on WhatsApp, pay by OMT or Whish, and I send you the repository within one working day.
Screenshots
The reference is generated from the template’s own code, and the walkthrough is a recording of it running.
Walkthrough
The auth flow, request by request, recorded against the template running: every response in it is what the API answered. The video is silent; its steps are listed beside it.
What the video shows
- Register: the account is created and a verification link is emailed.
- Log in before verifying: refused, email_not_verified.
- The verification email, printed in the terminal in development.
- Verify the address with the token from the link.
- Log in: an access token and a refresh token.
- Call a protected route with the access token.
- Refresh: a new pair, and the old refresh token is used up.
- Replay the old refresh token: refresh_token_reused, and the whole session ends.
- The newest access token stops working too: session_revoked.
- Guess passwords: past the limit, 429 rate_limited.
What is inside
src/auth — register, verify the email address, log in and out, refresh-token rotation with reuse detection, password resetsrc/users — your account, password change and sessions; admin routes for accounts and rolesAccess tokens that stop working the moment their session ends, not when they expireRate limits, Zod validation, and one error shape with machine-readable codesopenapi.json generated from the code, Swagger UI at /docs, and a static API referenceprisma/schema.prisma with its migration, a seed, and a Docker Compose MySQLUnit tests, and end-to-end tests against a real MySQL database in CI
What's in the zip
- .github/workflows/ci.yml
- docker/mysql-init/
- prisma/schema.prisma
- prisma/migrations/
- screenshots/
- scripts/build-docs.mjs
- src/auth/
- src/users/
- src/common/
- src/openapi/
- src/mail/
- test/
- .env.example
- compose.yaml
- openapi.json
- CHANGELOG.md
- LICENSE.md
- README.md
- package.json
What you need
- Node.js 22.12 or later, and npm
- MySQL 8 (a Docker Compose file starts it)
- An SMTP server, to send real emails
Licence
One developer, unlimited projects of your own and your clients’. You may deliver it inside the projects you build; you may not resell or share the template itself, or use it to make a template product. Updates for twelve months.
The full terms are in LICENSE.md, which comes with the template. Ask me for a copy before you buy.
Questions people ask
What am I allowed to do with a template?
One developer can use it in as many projects as they like, their own and their clients’. You may not resell or share the template itself, changed or not, or use it to make a template product of your own.
Do I get updates?
Yes, for twelve months from purchase. When a new version comes out, I send it to you.
Is there support?
On WhatsApp or by email, with your licence key, and I answer within one working day. Support covers the template working as described. It does not cover writing your features for you.


