wilsonfsouza / 01-foundations-nodejs-challenge

This project has an API to manage your tasks without using a framework for Nodejs. It also allows to import a local csv using a Stream to populate a fake database.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

About the project

It requires the LTS version of node (>= v.18.17.1).

This project has an API to manage your tasks without using a framework for Nodejs. It also allows to import a local csv using a Stream to populate a fake database.

Functionalities

  • Create a task
  • List all tasks
  • Update a task using its id
  • Remove a task using its id
  • Import multiple tasks via a csv file

Task Model

Field Description
id Unique identifier for each task.
title Task title.
description Dtailed description of a task.
completed_at Date of task completion. The initial value must be null.
created_at Date of task creation.
updated_at Date when task is updated. It must be always have the new date for any updates.

Routes & Business Logic

Create Tasks

Route

HTTP Method Route
POST /tasks

Description

Creates a new task in the database, sending the fields title and description via the request body.

After creating a task, the fields id, created_at, updated_at, and completed_at will be filled automatically


List All Tasks

Route

HTTP Method Route
GET /tasks

Description

Lists all tasks stored in the database. It can also permorm a search, filtering tasks by title and description


Update a task

Route

HTTP Method Route
PUT /tasks/:id

Description

Updates a task using its id. In the request body, you will receive title and/or description to be updated.

If only title was received, description must not change and vice-versa.

Before an update, a validation happens to check if the given id matches a task stored in the database.


Remove a task

Route

HTTP Method Route
DELETE /tasks/:id

Description

Remove a task by using its id.

Before an update, a validation happens to check if the given id matches a task stored in the database.

Toggle a task as completed/incompleted

Route

HTTP Method Route
PATCH /tasks/:id/complete

Description

It toggles a task as completed or incompleted. The incompleted is the "normal" state of a task.

Before an update, a validation happens to check if the given id matches a task stored in the database.


CSV Import

Route

HTTP Method Route
POST /tasks

Description

Using the package csv-parse, this function creates a readable Stream for the csv to read it by parts and populate the database.


About

This project has an API to manage your tasks without using a framework for Nodejs. It also allows to import a local csv using a Stream to populate a fake database.


Languages

Language:JavaScript 100.0%