Skip to content

Abassade/simple-note-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📒 A Simple Notes API

📖 Description

A simple Notes API built with Node.js and Express.js.
This project implements basic CRUD operations (Create, Read, Update, Delete) for managing notes stored in memory.


🚀 Features

  • Create a new note with a title and content.
  • Get all notes or a single note by ID.
  • Update an existing note.
  • Delete a note by ID.
  • JSON-based API responses.
  • Error handling for invalid requests.

📂 Project Structure

project-root/
│── index.js        # Main server file
│── package.json    # Dependencies and scripts
└── README.md       # Project documentation

🛠️ Installation & Setup

1. Clone the repository

git clone <your-repo-url>
cd notes-api

2. Install dependencies

npm install

3. Run the server

npm start

The server will start on:

http://localhost:3000

📡 API Endpoints

Welcome

GET /
Response: "Welcome to Notes API 📒"


Create a Note

POST /notes
Request body:

{ "title": "My first note", "content": "This is the content of my note" }

Response:

{ "id": 1, "title": "My first note", "content": "This is the content of my note" }

Get All Notes

GET /notes
Response:

[
  { "id": 1, "title": "My first note", "content": "This is the content of my note" }
]

Get a Single Note

GET /notes/:id
Example:

GET /notes/1

Response:

{ "id": 1, "title": "My first note", "content": "This is the content of my note" }

Update a Note

PUT /notes/:id
Request body (fields optional):

{ "content": "Updated content" }

Response:

{ "id": 1, "title": "My first note", "content": "Updated content" }

Delete a Note

DELETE /notes/:id
Response:

{ "message": "Note deleted" }

✨ Bonus Features (Optional)

  • Validation to ensure title and content are required when creating a note.
  • Add createdAt timestamp to each note.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors