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 |