To do list application example using Node.js API starter with PostgreSQL
To run this project you need to have installed:
Create a copy .env file from .env.example and populate the variables.
Install dependencies:
make installRun migrations:
make migrate-upStart application:
make upView logs:
make logsThis command will boot:
-
Node API on http://localhost:3000 if
PORTvariable has not been set on .env file. If variable has been set, will boot API onhttp://localhost:${PORT} -
PostgreSQL database on PORT 5432 with environments variables defined in
docker-compose.yml. To change database name, just change it in bothdocker-compose.ymland.envfiles
Folder: /src/users
POST to /users endpoint with request body such as:
{
"name": "User name",
"email": "user_email@email.com"
}GET to /users endpoint will return all users on database
Folder: /src/tasks
POST to /users/${USER_ID}/tasks endpoint with request body such as:
{
"title": "Task tittle",
"description": "Task description",
"status": ["to_do", "in_progress", "on_review", "ready_for_release", "done"],
"dueDate": "2021-05-20T18:00:00.000Z"
}PUT to /tasks/${TASK_ID} endpoint with request body such as:
{
"title": "Task tittle",
"description": "Task description",
"status": ["to_do", "in_progress", "on_review", "ready_for_release", "done"],
"dueDate": "2021-05-20T18:00:00.000Z"
}GET to /users/${USER_ID}/tasks endpoint will return user tasks
For new migrations, just add them on migrations folder with file name as time_action_entity_type. For example: 20210517211000_create_users_table.ts
Run migrations:
make migrate-upRollback migrations
make migrate-downmake install - install dependencies
make add lib=PACKAGE_NAME - add dependency
make add-dev lib=PACKAGE_NAME - add dev dependency
make up - start app
make logs - view logs
make down - kill app
make lint - run lint
make test - run tests
make test-watch - run tests on watch mode
make test-coverage - run tests with coverage report on /coverage folder
make build - build app on /dist folder
make up-build - start built app
make migrate-up - run migrations
make migrate-down - rollback the last batch of migrations
make shell - run app shell