Skip to content

md-abu-kayser/vanilla-node-todo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Vanilla Node.js Todo API

License: MIT

JavaScript ECMAScript Spec

Plain docs links


A lightweight, high-performance RESTful API built with pure Node.js for managing todos, demonstrating the power of Node.js without external dependencies.

Features

  • Zero Dependencies: Built using only Node.js built-in modules
  • JSON Storage: Persistent data storage using JSON file system
  • RESTful Architecture: Following REST principles for API design
  • Error Handling: Comprehensive error handling and status codes
  • CRUD Operations: Complete Create, Read, Update, Delete functionality
  • Flexible Querying: Search todos by ID or title
  • Duplicate Prevention: Built-in title uniqueness validation
  • Async/Await Pattern: Modern asynchronous code practices
  • Clean Architecture: Well-organized and maintainable codebase

Installation

  1. Clone the repository:
git clone https://github.com/md-abu-kayser/vanilla-node-todo.git
cd vanilla-node-todo
  1. Start the server:
node server.js
  • The server will start on http://127.0.0.1:5000

Usage

The API can be tested using any HTTP client (cURL, Postman, or your preferred tool). Below are some example requests:

Create a Todo

curl -X POST http://127.0.0.1:5000/todos/create-todo \
  -H "Content-Type: application/json" \
  -d '{"title": "Learn Node.js", "body": "Study Node.js fundamentals"}'

Get All Todos

curl http://127.0.0.1:5000/todos

API Endpoints

| Method | Endpoint                             | Description                        |
| ------ | ------------------------------------ | ---------------------------------- |
| GET    | `/todos`                             | Retrieve all todos                 |
| GET    | `/todo?id=123` or `/todo?title=Task` | Get a specific todo by ID or title |
| POST   | `/todos/create-todo`                 | Create a new todo                  |
| PATCH  | `/todos/update-todo?id=123`          | Update an existing todo            |
| DELETE | `/todos/delete-todo?id=123`          | Delete a todo                      |

Detailed API Documentation

GET /todos

  • Description: Retrieves all todos
  • Response: Array of todo objects
  • Status Codes:
    • 200: Success
    • 500: Server error

GET /todo

  • Description: Get a specific todo by ID or title
  • Query Parameters:
    • id: Todo ID (optional)
    • title: Todo title (optional)
  • Status Codes:
    • 200: Success
    • 404: Todo not found
    • 500: Server error

POST /todos/create-todo

  • Description: Create a new todo
  • Body:
    {
      "title": "string",
      "body": "string"
    }
  • Status Codes:
    • 201: Created
    • 400: Invalid request
    • 409: Duplicate title
    • 500: Server error

PATCH /todos/update-todo

  • Description: Update a todo's body
  • Query Parameters:
    • id: Todo ID (optional)
    • title: Todo title (optional)
  • Body:
    {
      "body": "string"
    }
  • Status Codes:
    • 200: Success
    • 400: Invalid request
    • 404: Todo not found
    • 500: Server error

DELETE /todos/delete-todo

  • Description: Delete a todo
  • Query Parameters:
    • id: Todo ID (optional)
    • title: Todo title (optional)
  • Status Codes:
    • 200: Success
    • 400: Invalid request
    • 404: Todo not found
    • 500: Server error

Data Structure

Each todo object has the following structure:

{
  "id": "1699123456789-1234",
  "title": "Example Todo",
  "body": "Todo description",
  "createdAt": "11/10/2025, 12:00:00 PM"
}

Error Handling

The API implements comprehensive error handling:

  • Input validation
  • Duplicate entry prevention
  • Resource not found handling
  • Invalid JSON payload detection
  • Internal server error handling

All errors return appropriate HTTP status codes and JSON responses with error messages.

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

  • This project is licensed under the terms of the MIT License.
  • You may replace or update the license as needed for client or proprietary projects.

Contact and Maintainer

If you’d like this README tailored for a specific purpose - such as hiring managers, open-source contributors, or client deliverables - feel free to request a custom tone or format.


It’s designed to be clean, well-structured, and pleasant to explore - perfect for interviews, portfolio showcases, or professional demos. Thank you for reviewing this project!


About

Vanilla Node.js Todo API - Lightweight, dependency-free RESTful API using Node.js core modules with JSON persistence, full CRUD, flexible querying, and clean architecture.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors