A RESTful Blog Backend API built using Node.js, Express, and MongoDB. This project demonstrates CRUD operations, pagination, likes, and comments functionality for blog posts.
- Create Blog Post
- Update Blog Post
- Delete Blog Post
- Like a Post
- Comment on a Post
- Pagination for Posts
- Clean MVC-style backend structure
- Node.js
- Express.js
- MongoDB
- Mongoose
- Nodemon
- Dotenv
blog-backend-api
│
├── config
│ └── db.js
│
├── controllers
│ └── postController.js
│
├── models
│ └── Post.js
│
├── routes
│ └── postRoutes.js
│
├── .env
├── server.js
└── package.json
Clone the repository
git clone https://github.com/yourusername/blog-backend-api.git
Move into the project
cd blog-backend-api
Install dependencies
npm install
Create a .env file in the root directory.
Example:
PORT=5000
MONGO_URI=mongodb://127.0.0.1:27017/blogDB
Start development server
npm run dev
Server will run on
http://localhost:5000
POST /api/posts
Body
{
"title": "My First Blog",
"content": "This is my first blog post"
}GET /api/posts?page=1&limit=5
PUT /api/posts/:id
Body
{
"title": "Updated Blog Title"
}DELETE /api/posts/:id
POST /api/posts/:id/like
POST /api/posts/:id/comment
Body
{
"text": "Great blog!"
}You can test APIs using:
- Thunder Client (VS Code)
- Postman
{
"title": "First Blog",
"content": "Testing local MongoDB",
"likes": 1,
"comments": [],
"createdAt": "2026-03-09T10:22:35.639Z"
}This project helped practice:
- REST API development
- MongoDB schema design
- Pagination
- Express routing
- MVC backend structure
Mitesh Nadiyapara
MERN Stack Developer