Blog API
- User registration and authentication (JWT)
- Create, read, update, and delete blog posts
- Commenting system
- MongoDB database integration
- Validation and error handling
- Unit tests using Jest and Supertest
POST /api/users/register
json { "name": "John Doe", "email": "john@example.com", "password": "123456" }
POST /api/users/login
json { "email": "john@example.com", "password": "123456" }
Copy the returned token for authorization in subsequent requests.
POST /api/posts
Headers:
Authorization: Bearer <token>
json { "title": "My First Blog Post", "content": "This is a sample blog post content." }
GET /api/posts
GET /api/posts/:id
PUT /api/posts/:id
Headers:
Authorization: Bearer <token>
#Delete a post
DELETE /api/posts/:id
Headers:
Authorization: Bearer <token>
Server runs on: http://localhost:5000
blog/
├── src/
│ ├── config/
│ ├── controllers/
│ ├── models/
│ ├── routes/
│ ├── middleware/
│ └── app.js
├── tests/
├── server.js # Entry point
├── .env
├── .gitignore
├── package.json
└── README.md
- Node.js
- Express.js
- MongoDB & Mongoose
- JWT Authentication
- Jest & Supertest
- Render (Deployment)
Author
Wada Gift (OG Tech) wgift41@gmail.com GitHub Profile