This is a Node.js and Express.js backend project providing user authentication and CRUD (Create, Read, Update, Delete) functionality for posts. It uses MongoDB via Mongoose, JWT for secure user sessions, and follows a clean MVC architecture. Ideal for building a secure backend for web or mobile applications.
- Features(#-features)
- Tech Stack(#-tech-stack)
- Setup Instructions(#-setup-instructions)
- Environment Variables(#-environment-variables)
- API Endpoints(#-api-endpoints)
- Auth Routes(#auth-routes)
- Post Routes(#post-routes)
🚀 Features
✅ User Registration & Login
🔒 Password hashing with bcrypt
🔐 Token-based authentication using JWT
🔄 CRUD operations for posts
🧱 Follows MVC architecture
🌐 RESTful API design
📦 .env support for environment configs
🛡️ Protected routes for authenticated users only
🛠️ Tech Stack
- Node.js
- Express.js
- MongoDB + Mongoose
- JWT for authentication
- bcrypt for password hashing
- dotenv for environment variables
- Postman (for testing)
⚙️ Setup Instructions
- Clone the repository
bash git clone https://github.com/Nboss21/authentication_backend.git cd authentication_backend
🔑 Auth Routes (/auth)
| Method | Endpoint | Description |
|---|---|---|
| POST | /register |
Register a new user |
| POST | /login |
Authenticate a user and return JWT |
📝 Post Routes (/posts)
| Method | Endpoint | Description |
|---|---|---|
| GET | /all-post |
Get all posts |
| GET | /post/:id |
Get a single post by ID |
| POST | /create |
Create a new post |
| PUT | /update/:id |
Update a post by ID |
| DELETE | /delete/:id |
Delete a post by ID |