Auth API with Node.js, Express & MongoDB
A secure authentication API built with Node.js, Express, and MongoDB featuring JWT authentication, password hashing, and password reset functionality.
User registration with email verification
JWT-based authentication
Password hashing with bcrypt
Password reset functionality
Protected routes with middleware
Error handling and status codes
MongoDB database integration
RESTful API design
Backend : Node.js, Express
Database : MongoDB (with Mongoose ODM)
Authentication : JSON Web Tokens (JWT)
Password Hashing : bcryptjs
Environment Variables : dotenv
Endpoint
Method
Description
Auth Required
/api/auth/signup
POST
Register a new user
No
/api/auth/login
POST
Login existing user
No
/api/auth/logout
POST
Logout user
Yes
/api/auth/update-password
POST
Update user password
Yes
/api/auth/forgot-password
POST
Initiate password reset
No
/api/auth/reset-password
POST
Complete password reset
No
Endpoint
Method
Description
Auth Required
/api/users/create-user
POST
Create user
No
/api/users/all-user
GET
Get all user details
No
/api/users/single-user/:id
GET
Single user details
No
/api/users/update-user/:id
PUT
Update user details
No
/api/users/delete-user/:id
Delete
Delete user details
No
Clone the repository:
git clone https://github.com/yourusername/repo.git
cd repo
Install dependencies:
Create a .env file in the root directory and add your environment variables:
MONGO_URI=your_mongodb_connection_string
JWT_SECRET=your_jwt_secret_key
PORT=5000
Start the development server:
The server will start on http://localhost:5000