Build a complete in-memory blog REST API with the following endpoints:
| Method | Path | Description |
|---|---|---|
| GET | /posts | Return all posts (array) |
| POST | /posts | Create a post — body: { title, body } |
| GET | /posts/:id | Return one post by id |
| DELETE | /posts/:id | Delete a post by id |
Requirements:
{ id, title, body, createdAt }POST /posts with missing title or body → 400 { error: "title and body are required" }GET /posts/:id for unknown id → 404 { error: "Post not found" }DELETE /posts/:id for unknown id → 404 { error: "Post not found" }"Blog API ready" on start then close.Build a complete in-memory blog REST API with the following endpoints:
| Method | Path | Description |
|---|---|---|
| GET | /posts | Return all posts (array) |
| POST | /posts | Create a post — body: { title, body } |
| GET | /posts/:id | Return one post by id |
| DELETE | /posts/:id | Delete a post by id |
Requirements:
{ id, title, body, createdAt }POST /posts with missing title or body → 400 { error: "title and body are required" }GET /posts/:id for unknown id → 404 { error: "Post not found" }DELETE /posts/:id for unknown id → 404 { error: "Post not found" }"Blog API ready" on start then close.