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:
POSTGRES_PASSWORD="password"
POSTGRES_USER="postgres"
POSTGRES_DB="store"
DATABASE_URL="postgresql://postgres:password@localhost:5432/store"
ROOT_USER_PASSWORD="password"
SALT_ROUNDS="10"
JWT_SECRET="super-secure-jwt-secret"
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:8000/.
Note: On the first run, the application will create the following root user which you can use to create more users:
{
"id": "root",
"password": "{process.env.ROOT_USER_PASSWORD}",
"firstname": "Root",
"lastname": "Root",
"superuser": true
}
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
- Surya Kant Bansal - Initial work - skb1129
This project is licensed under the ISC License - see the LICENSE.txt file for details
- The official documentation of
db-migrate
- The official Documentation of
Jasmine