Skip to content

Full Fledged E-Commerce API built using NodeJs/Typescript to Udacity FullStack Nanodegree

License

Notifications You must be signed in to change notification settings

MrBomber0x001/Udacity-Storefront-api

Repository files navigation

Udacity-Storefront-api

E-Commerce api project for udacity fullstack web nanodegree

Project Structure

src                      
├─ config                
│  └─ db.ts              
├─ handlers              
│  ├─ dashboard.ts       
│  ├─ home.ts            
│  ├─ orderProducts.ts   
│  ├─ orders.ts          
│  ├─ products.ts        
│  └─ users.ts           
├─ middlewares           
│  └─ Error.ts           
├─ models                
│  ├─ Order.ts           
│  ├─ Order_Products.ts  
│  ├─ Product.ts         
│  └─ User.ts            
├─ services              
│  └─ Dashboard.ts       
├─ tests                 
│  ├─ helpers            
│  │  └─ reporter.ts     
│  ├─ models             
│  │  ├─ orderSpec.ts    
│  │  ├─ productSpec.ts  
│  │  └─ userSpec.ts     
│  └─ routes             
│     ├─ orderSpec.ts    
│     ├─ productSpec.ts  
│     └─ userSpec.ts     
├─ uploads               
│  ├─ categories         
│  ├─ products           
│  └─ profiles           
├─ utils                 
│  ├─ jwt.ts             
│  └─ multer.ts          
└─ server.ts             

API Endpoints & Database Schema

Head over to REQUIREMENTS

Installing

Install the project dependencies

npm install

Setup and Connect to database

  1. creating user
CREATE USER shop_user WITH PASSWORD 'password123';
  1. create both development and testing db
CREATE DATABASE shop;
CREATE DATABASE shop_test;
  1. grant all privileges on both databases
\c shop;
GRANT ALL PRIVILEGES ON DATABASE shop To shop_user;
\c shop_test 
GRANT ALL PRIVILEGES ON DATABASE shop_test To shop_user;
  • setting enviroment variables
touch .env
nano .env

## place the enviroment variables below inside the .env file
# .env
APP_PORT=3000
POSTGRES_HOST=localhost
POSTGRES_USER=shop_user
POSTGRES_DB=shop
POSTGRES_PASSWORD=password123
POSTGRES_TEST_DB=shop_test
ENV=test
BCRYPT_PASS=thisissupersecretpassword
SALT_ROUNDS=10
PEPPER=password
JWT_SECRET_KEY=thisissupersecretpassword
  • port of the posgres database server 5432
  • port of the backend: the server runs localhost
  • package installation instructions

Running Or Dropping Migration

Running

  • testing db
db-migrate up -e test
  • development db
db-migrate up -e dev

or simply run

npm run migrate

Rollingback

db-migrate down

Running application

  • to run on compiled files
npm run dev
  • to run on typescript files
npm run start:dev

Running Tests

To run tests, you need only two steps

  1. Export ENV to test
export ENV=test
  1. Run testing command, which will build the project and run the tests, this step is so important because jasmine tests the compiled js code
npm run build-test

or simple run

npm run test

About

Full Fledged E-Commerce API built using NodeJs/Typescript to Udacity FullStack Nanodegree

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published