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 |