This project is a todo frontend app and is part of a challenge by Rocketseat 🚀

Demo on Render

Demo Frontend usin this api on Vercel

This API, built using Fastify, Prisma, and tested with Vitest and Supertest, provides a comprehensive task management solution. It allows users to create, edit, mark as complete, filter, and delete tasks efficiently. The integration of Fastify ensures optimal performance, while Prisma offers robust database management. Vitest and Supertest contribute to a reliable, well-tested application, ensuring a seamless user experience for managing tasks.

Installation

Clone the project repository:

  git clone https://github.com/YagoFGomes/api-todo-rocketseat-challenge.git

Run the docker-compose file:

  docker-compose -f docker-composer.dev.yml up -d

Task object anatomy

  {
    "id": uuid,
    "title": string,
    "description": string,
    "completed_at": datetime | null,
    "created_at": datetime,
    "updated_at": datetime
  }

Usage

To use the API, you will need to send requests to the following endpoints:

Create task

  POST /tasks

Required json body

  {
      "title": "string",
      "description": "string"
  }

Return status: 201 Created

Get all tasks

  GET /tasks

Return

{
   "tasks": [
      {task object}
   ]
}

Return status: 200 OK

Filter tasks

  GET /tasks?title=title_task
  # or
  GET /tasks?description=task_description
  # or
  GET /tasks?title=title_task&description=task_description

Return status: 200 OK

{
   "tasks": [
      {task object},
      {task object}
   ]
}  

Edit task

  PUT /tasks/:id_task

Required json body

   {
      "title": "Title changed",
      "description": "Description changed"
  }

Return status: 200 OK

 {
  "tasks": [
    {
      "id": uuid,
      "title": "Title changed",
      "description": "Description changed",
      "completed_at": null,
      "created_at": datetime,
      "updated_at": datetime
    }
  ]
}

Complete task

  PATCH /tasks/:id_task/completed

Return status: 200 OK

 {
  "tasks": [
    {
      "id": uuid,
      "title": string,
      "description": string,
      "completed_at": datetime, <-- save datetime 
      "created_at": datetime,
      "updated_at": datetime
    }
  ]
}

Uncomplete task

  PATCH /tasks/:id_task/uncompleted

Return status: 200 OK

 {
  "tasks": [
    {
      "id": uuid,
      "title": string,
      "description": string,
      "completed_at": null, <-- return to null
      "created_at": datetime,
      "updated_at": datetime
    }
  ]
}

Delete task

  DELETE /tasks/:id_task

Return status: 200 OK

Testing

The API is tested using Vitest and Supertest. To run the tests, simply run the following command:

  npm run test