Table of Contents
A StoreFront backend API written in NodeJS for Udacity. This application has APIs for Users, Products, and Orders.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
You need the following modules and dependencies installed to run this project:
docker-compose # To run the Postgres database on Docker
node 12 # To run the application
yarn # For dependency management
Simply, run the following command to install the project dependencies:
yarn
First, create a .env
file with all the required environment variables:
# .env
PORT=3000
NODE_ENV=dev
PGHOST='localhost'
PGPORT=5432
PGDATABASE=store
PGDATABASE_TEST=store_test
PGUSER= databaseUser
PGPASSWORD= databasePassword
BCRYPT_PASSWORD=your-secret-password
SALT_ROUNDS=10
TOKEN_SECRET=your-secret-token
Next, start the Postgres server on Docker:
docker-compose up
Now, check if Postgres has the database store
, if not create it:
# Connect to Postgres container
docker exec -it <postgres_container_id> bash
# Login to Postgres
psql -U postgres
# Postgres shell
# This will list out all the databases
\l
# If "store" database is not present
create database store;
Next, you need to run the database migrations:
yarn migrations up
Use the following command to run the application in watch mode:
yarn run watch
Use the following command to run the application in using node:
yarn start
The application will run on http://localhost:3000/.
Use the following command to run the unit tests:
yarn test
You may also use the Postman collection present in the repository for testing.
- NodeJS - The JavaScript runtime
- Yarn - The dependency manager
- db-migrate - The database migration tool
- Express - The web framework
- TypeScript - Types JS extension
- Jasmine - The unit testing framework
all CopyRights ...
- The official documentation of
db-migrate
- The official Documentation of
Jasmine
- See REQUIREMENTS.md file
- See REQUIREMENTS.md file