This repository documents a CRUD exercise performed as part of a training to learn about some back-end development technologies. A sketch of this exercise can be found in this google document.
. Node
. Fastify
. Fastify/postgres
. Fastify/jwt
. Fastify/plugin
. Fastify/autoload
. Fastify/cli
. pg
. Dotenv
. Knex
For more information, please, see the package.json file.
Run npm install to install the dependencies within this project.
. To run the docker compose file and start its services and volumes:
~$ docker-compose -f docker-compose.yml up. To down the services and volumes in the docker compose file:
~$ docker-compose -f docker-compose.yml down. To remove all docker volumes:
~$ docker volume rm $(docker volume ls -qf dangling=true). To acces a bash terminal to execute commands over the database configured for this exercise:
~$ docker exec -it crud_exercise-db-1 /bin/bash. To acces the database terminal of the db configured for this exercise:
~$ psql order postgres. To remove all the databases created:
~$ drop schema public cascade;. To create the public schema:
~$ create schema public;OBS: The last two commands in this section are not recommended and were used just to quickly correct some newbie errors.
. To create a migration based on a knexfile:
~$ knex --env <env_name> --knexfile knexfile.js migrate:make <migration_name>Below, the command executed to create a migration for the creation of the user table in the database:
~$ knex --env dockerLocal --knexfile knexfile.js migrate:make create_user_table. To execute all migrations (migrations already executed will not be executed twice):
~$ knex --env <env_name> --knexfile knexfile.js migrate:latestInstall nodemon globally:
~$ npm install nodemon -gOBS: use postgres full image (alpine version does not create database on docker compose up).