A RESTful API built with Express for managing blog posts, categories, and comments.This project was built to focus on authentication, CRUD operations, and relational data management.
- User authentication (JWT-based login/register)
- CRUD operations for blog posts
- Categories and tags support
- Comment system (linked to blog posts & users)
- Erro handling
- Node.js + Express.js
- MongoDB + Mongoose
- JWT for authentication
- Multer / Cloudinary for image uploads
- Postman for API testing
blog-api/
│ ├── controllers/ # Request handlers
│ ├── models/ # Mongoose schemas
│ ├── config/ # for configurations
│ ├── routes/ # Express routes
│ ├── middlewares/ # Authentication
│ ├── utils/ # Helpers (e.g. Cloudinary upload)
│── .env
│── index.js
│── package.json
│── README.md
- Register with
POST /api/users/authentication/register
- Login with
POST /api/users/authentication/login
Detailed Postman docs here 👉 View Postman Documentation
# Clone repo
git clone https://github.com/DamiAjele/Blog-API.git
cd blog-api
# Install dependencies
npm install
# Create .env file
MONGO_URI=your_mongo_connection
JWT_SECRET=your_jwt_secret
PORT=5000
# Run server
npm run start
Example request to create a blog post:
POST /api/posts/create-post Authorization: Log in (JWT-based) Content-Type: application/json
{
"title": "My First Blog Post",
"content": "This is the content of the blog",
"category": "Technology"
}
- Pagination, filtering and sorting of blog posts
The API includes proper error handling for:
- Non-existent users, posts, categories, and comments
- Invalid users and posts IDs
- Malformed requests
Damilola Ajele