Skip to content

tawfik-s/storefront_backend

Repository files navigation

store front backend

this is an API for backend application with the requirements in the requirements document

the API is full covered by integration and unit testing

Setup Steps

To get started:

1-clone the repo on the machine

2-install all dependencies by running command

npm  install

3-create a .env file with all the required environment variables:

POSTGRES_HOST="localhost"
POSTGRES_DB="store_backend"
POSTGRES_TEST_DB="store_backend_test"
POSTGRES_USER="postgres"
POSTGRES_PASSWORD="admin"
ENV="test"
BCRYPT_PASSWORD="speak-friend-and-enter"
SALT_ROUNDS="10"
PORT=4000
ACCESS_TOKEN_SECRET="noobs123"

4-Now, check if Postgres has the database database_dev, if not create it:


# Postgres shell
create database  store_backend;
create database  store_backend_test;

5-run npm test to test and build the project all tests must success

6-chenge the value of env in .env to be test when you testing and dev when you run the API

7-database is run on localhost port 5432 the project is running on port 4000 to change this please modify the env variables

Runing the program locally in development mode

npm run start

-and then head to your browser at localhost:3000 and it should be working.

Test the app

    npm run test

before you test the app

db-migrate reset --env test

to reset the test data base

Runing the program locally in production mode

npm run build

node dist/index.js

Code formating

I'm using prettier

npm run prettier I'm using eslint

npm run lint

scripts

  • npm run test to test the project
  • npm run build convert typescript to javascript in dist folder
  • npm run run build and run the project
  • npm lint run eslint
  • npm run prettier

Built With