Skip to content

OmarAbdelhamed/Store-BackEnd-With-NodeJs

Repository files navigation

Storefront Backend Project

Table of Contents

A StoreFront backend API written in NodeJS for Udacity. This application has APIs for Users, Products, and Orders.

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

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

Installing

Simply, run the following command to install the project dependencies:

yarn

Setup environment

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

Running the application

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/.

Running the unit tests

Use the following command to run the unit tests:

yarn test

You may also use the Postman collection present in the repository for testing.

Built With

License

all CopyRights ...

Acknowledgments

  • The official documentation of db-migrate
  • The official Documentation of Jasmine

Endpoints

Database Schema

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published