Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

🔐 Auth App API

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.

🚀 Features

  • User Registration
  • User Login
  • Password Hashing with bcrypt
  • JWT Authentication
  • Protected Routes
  • Input Validation
  • Error Handling Middleware
  • MongoDB Database Integration
  • RESTful API Design

🛠️ Tech Stack

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

📂 Project Structure

src/
├── controllers/
├── middleware/
├── models/
├── routes/
├── app.js
├── server.js
└── db.js

⚙️ Installation

Clone Repository

git clone https://github.com/v-988/auth-app.git
cd auth-app

Install Dependencies

npm install

Configure Environment Variables

Create a .env file:

PORT=5000
MONGO_URI=your_mongodb_connection_string
JWT_SECRET=your_secret_key

Run the Application

npm run dev

or

npm start

🔑 API Endpoints

Register User

POST /api/auth/register

Request Body:

{
  "name": "John Doe",
  "email": "john@example.com",
  "password": "password123"
}

Login User

POST /api/auth/login

Request Body:

{
  "email": "john@example.com",
  "password": "password123"
}

Protected Route

GET /api/auth/profile

Headers:

Authorization: Bearer <token>

📮 Testing

Use Postman or Thunder Client to test the API endpoints.

🔒 Security Features

  • Password hashing using bcrypt
  • JWT token authentication
  • Protected routes middleware
  • Environment variable protection
  • Input validation

🌟 Future Improvements

  • Password Reset
  • Email Verification
  • Refresh Tokens
  • Role-Based Access Control (RBAC)
  • OAuth Authentication (Google/GitHub)

👨‍💻 Author

Developed by Vishal

GitHub: https://github.com/v-988

About

A secure authentication API built with Node.js, Express, and MongoDB. Includes user registration, login, JWT-based authentication, and protected routes. Focuses on security, password hashing, and scalable backend structure.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages