@gotocva/nestjs-auth
v0.0.1
Published
Gotocva Queue is a lightweight, in-memory event queue for Node.js that allows you to manage asynchronous tasks efficiently without requiring Redis or any external dependencies. It supports job retries with customizable attempts and backoff strategies, mak
Maintainers
Readme
🔐 @gotocva/nestjs-auth
A NestJS Auth Library built with Mongoose and Passport, providing ready-to-use authentication features:
- Register
- Login
- Email verification (via OTP)
- Reset Password
📦 Installation
npm install @gotocva/nestjs-authOr if using Yarn:
yarn add @gotocva/nestjs-authEnsure
@nestjs/mongoose,mongoose,bcrypt, andclass-validatorare installed in your host app.
⚙️ Setup in Your NestJS App
1. Import AuthModule
// app.module.ts or auth.module.ts
import { Module } from '@nestjs/common';
import { MongooseModule } from '@nestjs/mongoose';
import { AuthModule } from '@gotocva/nestjs-auth';
@Module({
imports: [
MongooseModule.forRoot('mongodb://localhost/your-db'),
AuthModule,
],
})
export class AppModule {}📘 Endpoints
| Method | Path | Description |
| ------ | ---------------------- | --------------------- |
| POST | /auth/register | Register a user |
| POST | /auth/login | Login user |
| POST | /auth/verify-email | Verify OTP from email |
| POST | /auth/reset-password | Reset user password |
🧪 Example Payloads
🔸 Register
POST /auth/register
{
"name": "John Doe",
"email": "[email protected]",
"password": "Password123"
}🔸 Login
POST /auth/login
{
"email": "[email protected]",
"password": "Password123"
}🔸 Verify Email
POST /auth/verify-email
{
"email": "[email protected]",
"otp": "123456"
}🔸 Reset Password
POST /auth/reset-password
{
"email": "[email protected]",
"otp": "123456",
"newPassword": "NewPassword123"
}🛠️ Customize
- Extend the
UserSchemato add more fields (e.g., role, profileImage) - Hook up an email service (e.g., nodemailer, SendGrid) to send OTPs
- Add JWT if you need token-based auth (this library only covers login + verification)
📄 License
MIT © Sivabharathy
