A secure authentication API built with Node.js, Express, and MongoDB. This project provides user registration, login, password hashing, JWT-based authentication, and protected routes.
- User Registration
- User Login
- Password Hashing with bcrypt
- JWT Authentication
- Protected Routes
- Input Validation
- Error Handling Middleware
- MongoDB Database Integration
- RESTful API Design
- Node.js
- Express.js
- MongoDB Atlas
- Mongoose
- JWT (JSON Web Token)
- bcryptjs
- dotenv
src/
├── controllers/
├── middleware/
├── models/
├── routes/
├── app.js
├── server.js
└── db.js
git clone https://github.com/v-988/auth-app.git
cd auth-appnpm installCreate a .env file:
PORT=5000
MONGO_URI=your_mongodb_connection_string
JWT_SECRET=your_secret_keynpm run devor
npm startPOST /api/auth/registerRequest Body:
{
"name": "John Doe",
"email": "john@example.com",
"password": "password123"
}POST /api/auth/loginRequest Body:
{
"email": "john@example.com",
"password": "password123"
}GET /api/auth/profileHeaders:
Authorization: Bearer <token>Use Postman or Thunder Client to test the API endpoints.
- Password hashing using bcrypt
- JWT token authentication
- Protected routes middleware
- Environment variable protection
- Input validation
- Password Reset
- Email Verification
- Refresh Tokens
- Role-Based Access Control (RBAC)
- OAuth Authentication (Google/GitHub)
Developed by Vishal
GitHub: https://github.com/v-988