This is a simple REST API built with Express.js that provides CRUD (Create, Read, Update, Delete) operations for managing blogs.
-
GET /api/blog: Retrieve all blogs from the database.
-
POST /api/blog/post: Create a new blog with title and description.
-
PUT /api/blog/:id: Update a blog with a specific ID.
-
DELETE /api/blog/:id: Delete a blog with a specific ID.
To set up and run this API on your machine, follow these steps:
- Node.js installed on your machine.
- Clone this repository to your local machine:
git clone https://github.com/your-username/express-blog-api.gitOnce the server is running, you can use any HTTP client (e.g., Postman) to interact with the API endpoints.
- GET all blogs:
GET http://localhost:3000/api/blog
- POST a new blog:
POST http://localhost:3000/api/blog/post
Body:
{
"title": "New Blog Title",
"description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit."
}- PUT (update) a blog with ID 123:
PUT http://localhost:3000/api/blog/123
Body:
{
"title": "Updated Blog Title",
"description": "Updated description."
}- DELETE a blog with ID 123:
Send a DELETE request to http://localhost:<port>/api/blog/:id with the ID of the blog to delete in the URL.