Skip to content

A secure Node.js Authentication API with JWT, password hashing, role-based access, and integrated email functionality using Nodemailer for account verification & password reset.

Notifications You must be signed in to change notification settings

Akash-01Code/Authentication-API

Repository files navigation

🔐 Node.js Authentication API

A secure Authentication API built with Node.js & Express.
Includes JWT-based authentication, password hashing, role-based access control (RBAC), and Nodemailer email services for user verification and password recovery.


🚀 Features

  • ✅ User Registration & Login
  • 🔒 Password Hashing using bcrypt
  • 🔑 Authentication using JWT (JSON Web Token)
  • 🛡️ Role-based Authorization (Admin/User)
  • 📩 Email Service with Nodemailer
    • Account Verification Email
    • Password Reset via Email Link
  • 🔐 Secure Routes (Protected APIs)
  • 📦 MongoDB integration with Mongoose

🛠️ Tech Stack

  • Backend: Node.js, Express.js
  • Database: MongoDB (Mongoose ODM)
  • Authentication: JWT, bcrypt
  • Email Service: Nodemailer + Gmail/SMTP
  • Environment: dotenv

📂 Project Structure

FULLSTACK │── controller/ │ └── user.controller.js │── middleware/ │ └── auth.middleware.js │── model/ │ └── User.model.js │── prisma/
│── routes/ │ └── user.routes.js │── utils/ │ └── dg.js
│── .env │── .gitignore │── decription.md │── index.js
│── package.json │── package-lock.json │── README.md


⚡ Getting Started

1️⃣ Clone the repository

git clone https://github.com/your-username/node-auth-api.git
cd node-auth-api


2️⃣ Install dependencies
    npm install

3️⃣ Setup environment variables
    PORT=5000
    DATABASE_URL=your_database_connection_string
    JWT_SECRET=your_jwt_secret_key
    EMAIL_USER=your_email@gmail.com
    EMAIL_PASS=your_email_password_or_app_password

4️⃣ Start the server

    npm start

About

A secure Node.js Authentication API with JWT, password hashing, role-based access, and integrated email functionality using Nodemailer for account verification & password reset.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published