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
- please read the Endpoints.md to know more about endpoints
-
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.
-
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;
- 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
-
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
root:.
├───migrations
│ └───sqls
├───spec
│ └───support
└───src
├───database
├───handlers
├───helpers
├───middleware
├───models
└───routes
└───APIs