The general purpose of the API is to keep track of how a batch of beer is being brewed over time. There are some peripheral information pieces such as employees that are working on the system, the tanks that the batches are being brewed in, actions associated with those tanks, and the recipes for a brew.
Both development and production environments require the use of a .env file to get environment variables. This .env file should never be committed, you can rename the example.env file in the project to .env and it will work.
It contains the following environment variables that are all required for local development with Docker.
For more information on the PG environment variables, check out the official postgres docker container docs
cp example.env .env
will enable the default configuration.npm ci
will install all of the dependencies.npm run watch-ts
in a different terminal, this will trigger the typescript compiler to watch the source files for changes and re-transpile them.npm run build-images
will run docker-compose
, build new images, and run the api.npm run dev
will run docker-compose
, and run the api.The postman collections at the root of this repo contains documentation for all of the avaiable api endpoints. It contains .collection.json and .environment.json that will need to be imported into postman so that authentication is automated for all requests.
Once the application has started the init
(small data set) or init-live
(large data set) endpoint needs to be hit to initialize the test data for the application. Once hit (after success) this can take between 10 seconds to a minute to load all of the data.
Our Postman collections contain these routes, aptly named init
and init-live
.
If you prefer, the following curl commands can be used to hit both endpoints:
curl -X POST http://localhost:3000/init
curl -X POST http://localhost:3000/init-live
NOTE: for the automatic psql instance check the npm
commands section.
To connect to the docker container and interact directly with the database, follow these steps
docker ps
to get the name of the running DB docker containerdocker exec -it {name of DB container} bash -l
psql -U {PGUSER} -d {database name}
You should now be logged into the psql program on the docker container
A few things to note:
\
or end with a ;
\dt
shows all database tablesSELECT * FROM actions;
selects everything from the actions table\q
to quit the psql shellexit
to exit the docker containernpm
commandsnow
cli when running now dev
. There is no need to run this manually.now
cli when running now dev
. There is no need to run this manually.tslint.json
configuration.