Skip to content

A simple and modular RESTful API for managing todo items, built with Node.js, Express.js, and MongoDB. Features include CRUD operations, input validation, Swagger documentation, and a clean project structure for easy scalability and testing.

Notifications You must be signed in to change notification settings

KBatuhanB/Node.js-Todo-REST-API

Repository files navigation

Todo-API

Todo-API is a RESTful API built with Node.js and Express.js. This project allows you to perform CRUD (Create, Read, Update, Delete) operations using a MongoDB database and provides API documentation through Swagger. You can add, list, update, and delete todos, with advanced validation to ensure data integrity.

Features

  • Add, list, update, and delete todos
  • Advanced data validation
  • Swagger-based API documentation (/api-docs)
  • Modular and organized project structure
  • Reliability through automated tests

Technologies Used

  • Node.js – Server-side JavaScript runtime
  • Express.js – Web framework
  • MongoDB – NoSQL database
  • uuid – Unique ID generation
  • dotenv – Environment variable management
  • swagger-ui-express – API documentation interface
  • Jest – For testing (or another test framework of your choice)

Installation

  1. Clone the repository and navigate into the project folder:

    git clone <repository-url>
    cd <repository-folder>
    npm install
  2. Create a .env file and add the required environment variables:

    PORT=3000
    MONGODB_URI=<your-mongodb-uri>
  3. Start the server:

    node server.js
  4. Access the API documentation at:

    http://localhost:3000/api-docs
    

Project Structure

The main directory contains app.js, server.js, and package.json. Additionally, it includes config, controllers, middlewares, models, routes, swagger, tests, and validations folders:

  • config/ : Environment and database configurations
  • controllers/ : Business logic
  • middlewares/ : Middleware functions
  • models/ : Data models
  • routes/ : API endpoints
  • swagger/ : Swagger documentation
  • tests/ : Test files
  • validations/ : Validation schemas

API Endpoints

Method Endpoint Description
GET /todos Retrieve all todos
POST /todos Create a new todo
GET /todos/:id Retrieve a specific todo
PUT /todos/:id Update a todo
DELETE /todos/:id Delete a todo

For detailed information and example requests, use the Swagger interface.

Tests

Basic CRUD operations are tested using Jest. Run the tests with:

npm test

About

A simple and modular RESTful API for managing todo items, built with Node.js, Express.js, and MongoDB. Features include CRUD operations, input validation, Swagger documentation, and a clean project structure for easy scalability and testing.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published