hemax2000 / Storefront-backend

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Storefront Backend Project

Terminal commands

  • to start project use: npm start
  • to run unit tests use: npm test
  • to install packages use: npm install

create user, databases, migrations

connect to the default postgres database as the server's root user psql -U postgres

create user: CREATE USER owner_user WITH PASSWORD 'password123';

creat databases:

  • CREATE DATABASE store_db;

  • CREATE DATABASE store_test_db;

grant privileges:

  • \c store_db

  • GRANT ALL PRIVILEGES ON DATABASE store_db TO owner_user;

  • GRANT USAGE, CREATE ON SCHEMA public TO owner_user;


  • \c store_test_db;

  • GRANT ALL PRIVILEGES ON DATABASE store_test_db TO owner_user;

  • GRANT USAGE, CREATE ON SCHEMA public TO owner_user;

migrations

Navigate to the root directory and run the command:

  • db-migrate up

dotenv file

image

HOST=localhost

DB=store_db

DB_TEST=store_test_db

USER=owner_user

PASSWORD=password123

ENV=dev

PEPPER=randomPeper

TOKEN_SECRET=CE677DA24F46CE651691EEA890B8DCCCEB064FBF258BD3A7D67A0C9AAF841F48


Server running on PORT: 3000

Database running on PORT: 5432

Authorization

tokens are passed like this:

Authorization => Bearer TOKEN

URLS

body: { "firstname":"ibrahim", "lastname":"othman", "password":"12345678" }

body: { "firstname":"ibrahim", "lastname":"alnumair", "password":"12345678" }


body: { "name":"iphone", "price":"22", "category":"phhone" }

body: { "name":"iphone", "price":"500", "category":"phone" }


body: { "user_id":"1", "status":"active" }

body: { "status":"complete" }

body: { "product_id":"2", "quantity":"5" }

About

License:Other


Languages

Language:TypeScript 82.6%Language:JavaScript 17.4%