π Notes API (Express.js)
A simple RESTful API built with Express.js for managing notes.
π Features
Get all notes
- Get all notes
Request:
GET /notes
Response:
[ { "id": 1, "title": "First Note", "content": "This is my first note" }, { "id": 2, "title": "Seccond Note", "content": "This is my seccond note" } ]
Get a single note by ID Request:
GET /notes/1
Response (success):
{ "id": 1, "title": "First Note", "content": "This is my first note" }
Response (not found):
{ "message": "Note note found" }
Create a new note Request:
POST /notes Content-Type: application/json
{ "title": "Learn Express", "content": "Express makes backend easy!" }
Response (success):
{ "message": "Success", "note": { "id": 3, "title": "Learn Express", "content": "Express makes backend easy!" } }
Response (missing fields):
{ "message": "title and content are required" }
Update a note Request:
PUT /notes/2 Content-Type: application/json
{ "title": "Updated Note Title", "content": "Updated Note Content" }
Response (success):
{ "message": "Updated successfully", "note": { "id": 2, "title": "Updated Note Title", "content": "Updated Note Content" } }
Response (not found):
{ "message": "Note note found" }
Delete a note Request:
DELETE /notes/2
Response (success):
{ "message": "Deleted successfully", "note": { "id": 2, "title": "Seccond Note", "content": "This is my seccond note" } }
Response (not found):
{ "message": "Note note found" }
Install dependencies:
npm install
Run the server:
node index.js
Server will start at:
π API Endpoints
GET /notes β Get all notes
GET /notes/:id β Get note by ID
POST /notes β Create a new note
PUT /notes/:id β Update a note
DELETE /notes/:id β Delete a note