This repo contains a basic Storefront API. To get started, clone this repo and run yarn
in your terminal at the project root.
You need to setup the required environmental variables:
POSTGRES_HOST=
POSTGRES_DB=
POSTGRES_TEST_DB=
POSTGRES_USER=
POSTGRES_PASSWORD=
ENV=dev
BCRYPT_PASSWORD=
SALT_ROUNDS=
PEPPER=
TOKEN_SECRET=
The next step is to run yarn docker
to create the container and the main database POSTGRES_DB, as well as establish the connection with it.
NOTE It is required a docker interface, like Docker Desktop, installed and running.
To run migrations and create all data tables needed, run yarn migrate
.
After previous settings, run the API:
yarn watch
NOTE The server should be running on port 3000
and the database on port 5432
.
With the container running, you need to access it with the POSTGRES_USER and create the POSTGRES_TEST_DB:
docker exec -it <container_name> bash
su postgres
psql
CREATE DATABASE <database_name>;
To test the API run:
yarn test