This is a backend project for a Todo List API built using express, express-validator, mysql2, typeorm, and typescript. The API provides three RESTful routes for managing tasks.
The following instructions will get you a copy of the project and the setting needed to run the back-end server on your local machine.
- Clone the repository:
git clone https://github.com/smallpaes/ts-todo-list-api.git- Enter the project:
cd ts-todo-list-api- Install the dependencies:
npm install- Set up the database configuration in the
.envfile, which should contain the following variables(or reference to.env.examplefile):
PORT=
MYSQL_USER=
MYSQL_PASSWORD=
MYSQL_DB=- Start the server:
npm startAlternatively, you can run the server in development mode with:
npm run dev- Find the message for successful activation:
App is listening on port 3000This project is built using Typescript. To compile it into Javascript, use the following command and the compiled files will be generated in the dist folder:
npm run buildThis endpoint returns all tasks from the database.
[
{
"id": "8e31eb23-8e08-48b9-a2eb-8d0eb780dc3a",
"title": "Task 2",
"date": "2023-05-01T12:00:00Z",
"description": "Description 2",
"priority": "High",
"status": "To Do"
},
]This endpoint creates a new task in the database.
{
"title": "Task 2",
"description": "Description 2",
"date": "2023-05-01T12:00:00Z",
"status": "Done",
"priority": "High"
}{
"title": "Task 2",
"description": "Description 2",
"date": "2023-05-01T12:00:00Z",
"status": "To Do",
"priority": "Done",
"id": "8e31eb23-8e08-48b9-a2eb-8d0eb780dc3a"
}This endpoint updates the status of a task in the database.
{
"status": "To Do"
}{
"generatedMaps": [],
"raw": [],
"affected": 1
}