This is the backend for the Udacity StoreFront application.
The database schema and the api endpoints are described in the REQUERMENTS.md file.
To run the backend, you will need to install the dependencies:
to install dependencies:
yarn
this project uses postgres database on docker container that runs on port 5432.
- To run database in the docker container:
docker-compose -f docker-compose.yml up
- connect to the database:
psql -h 127.0.0.1 postgres
- create the Project database:
CREATE DATABASE store_front;
- create Testing database:
CREATE DATABASE store_front_test;
- to make the database looks like the schema in the migration file:
yarn global add db-migrate
db-migrate up
you must make an .env
file in the root of the project providing the following information.
POSTGRES_HOST=127.0.0.1
POSTGRES_DB=store_front
POSTGRES_TEST_DB=store_front_test
POSTGRES_USER=testuser
POSTGRES_PASSWORD=testpassword
BCRYPT_PASSWORD=testPassword
SALT_ROUNDS=10
JWT_SECRET=testPassword
ROOT_USERNAME=root
ROOT_PASSWORD=root
ENV=dev
to run the backend:
yarn watch
The server will start on port 3000.
all endpoints are described in the REQUIREMENTS.md file.
tokens are generated using the JWT library.
to provide authentication to the backend you must path the token to the header of the request as:
{
"Authorization": "Bearer <token>"
}
and to get your token you must use the login endpoint as described in the REQUIREMENTS.md file.
to test the backend:
yarn test