Skip to content

neelpatel6262/my-notes-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📝 Notes API

A simple, lightweight REST API for managing notes — built with Node.js and Express.

Node.js Express REST API


1. Project Title

Notes API — Simple REST API with Node.js + Express


2. Description

Notes API is a minimal backend REST API that lets you create, read, update, and delete notes via HTTP requests. Built with Node.js and Express, it focuses on clean route structure and straightforward CRUD operations — making it a solid foundation for any note-taking application or a great project for learning backend API development.

No database required to get started — notes are managed in memory, keeping setup fast and friction-free.


3. Features

  • 📥 Add NotesPOST /notes to create a new note.
  • 📋 List All NotesGET /notes to retrieve the full notes list.
  • 🗑️ Delete a NoteDELETE /notes/:index to remove a note by its index.
  • ✏️ Update a NotePATCH /notes/:index to update a note's description.

4. Technologies

Category Technology
Runtime Node.js v18+
Framework Express 4.x
Language JavaScript (ES6+)
Package Mgr npm

5. Getting Started

Prerequisites

Verify your versions:

node -v
npm -v

6. Installation

  1. Clone the repository

    git clone https://github.com/neelpatel6262/notes-api.git
    cd notes-api
  2. Install dependencies

    npm install
  3. Start the server

    node app.js

The server will start on http://localhost:3000 (or the configured port).


7. Usage

Use any HTTP client (Postman, Insomnia, curl, or a frontend) to interact with the API.

Endpoints

Method Endpoint Description
POST /notes Add a new note
GET /notes Retrieve all notes
PATCH /notes/:index Update a note's description
DELETE /notes/:index Delete a note by index

Example Requests

Add a note

curl -X POST http://localhost:3000/notes \
  -H "Content-Type: application/json" \
  -d '{"title": "My Note", "description": "Note content here"}'

Get all notes

curl http://localhost:3000/notes

Update a note

curl -X PATCH http://localhost:3000/notes/0 \
  -H "Content-Type: application/json" \
  -d '{"description": "Updated content"}'

Delete a note

curl -X DELETE http://localhost:3000/notes/0

8. Keyboard Shortcuts

This is a backend API — no keyboard shortcuts apply. Use a REST client like Postman or Insomnia for a GUI-based testing experience.


9. Project Structure

notes-api/
├── app.js          # Express app entry point — server setup & routes
├── package.json    # Dependencies and scripts
└── README.md       # Project documentation

10. Development Process

  • Planned the API surface — identified the four core CRUD operations needed for a notes resource.
  • Set up Express — initialized the project, installed dependencies, configured the server.
  • Defined routes — implemented POST, GET, PATCH, and DELETE endpoints with appropriate HTTP methods and status codes.
  • In-memory storage — used a simple array to store notes, keeping setup fast with no database dependency.
  • Tested with curl / Postman — validated all endpoints manually before finalizing.

11. What I Learned

  • Structuring a REST API with Express — routes, middleware, and request/response handling.
  • Using correct HTTP methods (POST, GET, PATCH, DELETE) for CRUD operations.
  • Parsing JSON request bodies with express.json() middleware.
  • Handling index-based resource addressing in URL params (:index).
  • Returning appropriate HTTP status codes (200, 201, 404, 400).
  • Organizing a minimal Node.js project cleanly from scratch.

12. Overall Growth

Aspect Before After
Backend knowledge Frontend only Comfortable building REST APIs
Express routing Unfamiliar Confident with routes and middleware
HTTP methods Basic GET/POST understanding Full CRUD with correct status codes
API testing Manual browser testing Structured testing via curl / Postman

13. Future Enhancements

  • 🗄️ Database integration — persist notes with MongoDB or SQLite.
  • 🔐 Authentication — JWT-based auth to protect routes.
  • 🆔 UUID-based IDs — replace index-based addressing with stable unique IDs.
  • Input validation — validate request bodies with express-validator or zod.
  • 📄 Pagination — limit and paginate results on GET /notes.
  • 🌐 Deploy — host on Railway, Render, or Vercel serverless functions.
  • 🧪 Tests — add unit/integration tests with Jest or Vitest.

14. Known Issues / Limitations

  • Notes are stored in memory — all data is lost when the server restarts.
  • Index-based addressing can be fragile after deletions (indices shift).
  • No input validation — malformed request bodies are not rejected.
  • No authentication — all endpoints are publicly accessible.

15. Contributing

Contributions and improvements are welcome!

  1. Fork the repository.

  2. Create a feature branch:

    git checkout -b feature/your-feature-name
  3. Commit your changes and push:

    git commit -m "Add: your feature description"
    git push origin feature/your-feature-name
  4. Open a Pull Request describing what you changed.


16. License

This project is open source under the MIT License — free to use, modify, and distribute.


17. Contact


18. Acknowledgments

  • Node.js — JavaScript runtime powering the server.
  • Express — Minimal, flexible web framework for Node.js.
  • Postman — API testing and development tool.

19. Footer

Field Info
Project Status Active / Portfolio-ready
Version 1.0.0
Runtime Node.js v18+

20. Checklist

  • Express server setup
  • POST /notes — add a note
  • GET /notes — list all notes
  • PATCH /notes/:index — update note description
  • DELETE /notes/:index — delete a note
  • JSON request body parsing
  • Database persistence (MongoDB / SQLite)
  • UUID-based IDs
  • Input validation
  • Authentication (JWT)
  • Unit / integration tests
  • Deployed to a hosting platform

About

Simple Notes CRUD API built with Express.js – learn REST basics with GET, POST, PATCH, DELETE

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors