A RESTful API for a blogging platform that allows users to create, read, update, and delete blog posts, manage authentication, and interact with content through comments and likes.
- 🔐 JWT-based Authentication
- 👤 User Registration & Login
- ✍️ CRUD operations on Blog Posts
- 💬 Comment System
- ❤️ Like / Unlike Posts
- 🏷️ Tags & Categories Support
- Backend: Node.js, Express.js
- Database: MongoDB (Mongoose)
- Authentication: JWT (JSON Web Token)
- Tools: Thunder Client
├── src/
│ ├── app.js # Express app setup
│ ├── config/
│ │ └── dbConnection.js # Database connection
│ ├── controllers/
│ │ ├── postController.js # Post-related business logic
│ │ └── userController.js # User-related business logic
│ ├── middleware/
│ │ ├── errorHandler.js # Error handling middleware
│ │ └── isLoggedIn.js # Authentication middleware
│ ├── models/
│ │ ├── postModel.js # Post schema
│ │ └── userModel.js # User schema
│ └── routes/
│ ├── postRoute.js # Post routes
│ └── userRoute.js # User routes
├── package.json # Dependencies and scripts
├── README.md # Project documentation
└── server.js # Entry pointgit clone https://github.com/bisu39/BLOG-APIs.git
cd BLOG-APIs
npm install
- Node.js installed
- MongoDB running locally or cloud (MongoDB Atlas)
PORT = <your port>
MONGODB_URL = <your_mongodb_connection_string>
ACCESS_TOKEN_SECRET= <your_secret_key>npm start
| Method | Endpoint | Description |
|---|---|---|
| POST | /users | Register user |
| POST | /users/auth | Login user |
| Method | Endpoint | Description |
|---|---|---|
| GET | /posts | Get all posts |
| POST | /posts | Create post (auth) |
| PATCH | /posts/:id | Update post (auth) |
| DELETE | /posts/:id | Delete post (auth) |
| Method | Endpoint | Description |
|---|---|---|
| POST | /posts/:postID/comment | Add comment |
Include token in headers for protected routes:
Authorization: Bearer <your_token>
The API uses a centralized error handling middleware that returns consistent responses:
{
"success": false,
"message": "Error message",
"stack": "Only in development"
}POST /posts
{
"title": "My First Blog",
"content": "This is a long blog content...",
"tags": ["tech", "node"],
"category": "Programming"
}- Project deployed in Railway
- Online access link: https://blog-apis.up.railway.app/
Frontend Implemenation Pagination Image upload (Cloud storage) Rate limiting & security enhancements
Contributions are welcome!
git checkout -b feature/new-feature
git commit -m "Add new feature"
git push origin feature/new-feature
This project is licensed under the MIT License.