This project is an API that provide all the functionalities needed for an online store
-
Products
- Index (GET /products)
- Show (GET /products/:id)
- Create [token required] (POST /products)
- Top 5 most popular products (GET /products/featured)
- Products by category (args: product category) (GET /products/category/:category)
-
Users
- Index [token required] (GET /users)
- Show [token required] (GET /users/:id)
- Create N[token required] (POST /users)
-
Orders
- Create Order (POST /orders)
- Close Order (PUT /orders/:orderId/close)
- Current Order by user (args: user id)[token required] (GET /orders/current/:userId)
- Completed Orders by user (args: user id)[token required](GET /orders/completed/:userId)
-
Open your terminal and run the following commands:
git clone https://github.com/AhmedMohammed3/store-front-backend.git
cd store-front-backend
npm i
-
Create a file called .env with the following keys and fill it with your own data:
PORT
DB_HOST
DB_USER
DB_PASS
DB_NAME=store_front
DB_TEST_NAME=store_front_test
JWT_SECRET
BCRYPT_PEPPER
BCRYPT_SALT
ENV=dev
-
Run the following set of commands to create your databases
psql -U {POSTGRES_USER}
CREATE DATABASE store_front;
CREATE DATABASE store_front_test;
\q
-
Run the following command to migrate tables:
npm run migrate
-
Run the following command to seed the database:
psql -U {POSTGRES_USER} -d store_front -a -f ./seeds/seed.sql
NOTE That DB is running on the default port 5432 so you don't need to add it to the .env file.
- Run the following command to start the server:
npm run start
- Open your terminal and clone the repository
git clone https://github.com/AhmedMohammed3/store-front-backend.git
- Create your branch
git checkout -b {YOUR_BRANCH_NAME}
- run
npm run dev
to start development server (It's automatically building and restarting). - Make your edits and review it well.
- Commit your changes with appropriate message. Follow these git style guides
git commit -m {YOUR_COMMIT_MSG}
- Push your changes
git push origin {YOUR_BRANCH_NAME}
- Create a pull request