Skip to content

Latest commit

 

History

History
120 lines (93 loc) · 2.56 KB

readme.md

File metadata and controls

120 lines (93 loc) · 2.56 KB

A basic e-store-API for the e-commerce platform

api is used in this site PcMart

this is api for e-store
you can create , update , delete and get all for products , categories and carts
using auth token from firebase,
no need to create user database in this project
firebase is handling user auth for us


Endpoints


How to start

  • download and install node.js

  • download and install PostgreSql

  • run the following command to install the dependencies:

        npm install
    

    you are now ready to go.


Database

  • after downloading PostgreSql and install it

  • run the following command to connect to postgres:

        psql -U postgres
    

    to login to the database and write your password you created in the installation.

  • after login to the database, write the following command to create the database:

        CREATE DATABASE store_dev;
        CREATE DATABASE store_test;

Environment variables

  • put inside the .env file
    PORT=3000 #or any other port
    NODE_ENV=dev #{dev, test, production}
    DB_HOST=localhost
    DB_PORT=5432
    DB_USER='...' # your postgres username
    DB_PASSWORD='...' # your postgres password
    DB_NAME=store_dev 
    DB_TEST=store_test 
    DATABASE_URL='...' # connection string for ssl connection, production phase for heroku

Scripts

  • To run the server

        npm run start
    
  • To run the server in development mode with nodemon

        npm run dev
    
  • To run db-migrate up to start the migration

        npm run migrate:up
    
  • To run db-migrate down to rollback the migration

        npm run migrate:down
    
  • To run prettier to format the code

        npm run prettier
    
  • To run eslint to check the code

        npm run eslint
    
  • To clean the code with prettier and eslint

        npm run format
    

Directory structure

root:.
    ├───migrations
    │   └───sqls
    ├───spec
    │   └───support
    └───src
        ├───database
        ├───handlers
        ├───helpers
        ├───middleware
        ├───models
        └───routes
            └───APIs