Node.js Auth API Development by Sunil Kumar rao sNode.js Auth API Development by Sunil Kumar rao s

Node.js Auth API Development

Portfolio project
Sunil Kumar rao s

Node.js Auth API

A secure RESTful API built with Node.js, Express, MongoDB, and JWT for user authentication. This project demonstrates backend fundamentals like user registration, login, protected routes, and token-based access control.

๐Ÿ”ง Tech Stack

Node.js
Express.js
MongoDB & Mongoose
JWT (JSON Web Token)
bcryptjs
dotenv

๐Ÿ“ Features

โœ… User registration (/api/auth/register)
โœ… User login with hashed passwords
โœ… JWT-based token authentication
โœ… Protected route (/api/auth/profile)
โœ… Modular structure (routes, controllers, models)
โœ… MongoDB connection via Mongoose

๐Ÿ› ๏ธ Installation

# 1. Clone the repository
git clone https://github.com/YOUR_USERNAME/node-auth-api.git

# 2. Navigate into the project
cd node-auth-api

# 3. Install dependencies
npm install

# 4. Create .env file
touch .env

.env Configuration

PORT=5000
MONGO_URI=mongodb://localhost:27017/nodeauth
JWT_SECRET=your_secret_key

Running the API

Start in development mode

npm run dev


OR

Start in production mode

node server.js


๐Ÿ“ฎ API Endpoints
Method Route Description Access POST /api/auth/register Register a new user Public POST /api/auth/login Login & get token Public GET /api/auth/profile Get user profile Protected
๐Ÿ” Example Auth Header
Authorization: Bearer <your_token>


๐Ÿ“ฌ Contact Built with โค๏ธ by Sunil Kumar Rao S

0 likes ยท 7 views ยท Oct 8, 2025

Built a secure RESTful API with Node.js for user authentication.

Tags