A RESTful API server for a blog platform where users can create accounts, post blogs, read, update, and delete them, and comment on other users' posts.
-
User Authentication
- User registration and login
- Password hashing for security
- JWT-based authentication for protected routes
-
Blog Management
- Create new blog posts
- Read all or individual blog posts
- Update or delete your own posts
- Search or filter posts (optional)
-
Comments
- Add comments to any blog post
- Read all comments on a blog
- Update or delete your own comments
-
Authorization
- Users can only modify or delete their own blogs and comments
- Public can read blogs without authentication (optional)
- Backend: Node.js, Express.js
- Database: MongoDB / Mongoose
- Authentication: JWT (JSON Web Token)
- Validation: Joi / Zod (optional)
POST /api/auth/register– Register a new userPOST /api/auth/login– Login and receive a tokenGET /api/users/:id– Get user details
POST /api/blogs– Create a new blog (authenticated)GET /api/blogs– Get all blogsGET /api/blogs/:id– Get a specific blogPUT /api/blogs/:id– Update a blog (authenticated & owner only)DELETE /api/blogs/:id– Delete a blog (authenticated & owner only)
POST /api/blogs/:id/comments– Add a comment to a blog (authenticated)GET /api/blogs/:id/comments– Get all comments for a blogPUT /api/comments/:id– Update a comment (authenticated & owner only)DELETE /api/comments/:id– Delete a comment (authenticated & owner only)