This the backend API for Kitabi Store website. It's a website that manages an online books store.
There's 3 types of users. Guest / Client / Admin.
-
Guest user could view all books and stores, he could also manage his cart. Without having an account necessarily.
-
A client could buy books, view his account and edit it, track his orders status.
-
A seller could:
- Add and supply books with their specific prices, discount and quantity.
- Remove and update books.
Clone this project to your host by running:
git clone https://github.com/hamza-hadj-aissa/kitabi_store_API.git
Then navigate to the project's directory:
cd kitabi_store_API
Copy the .env file sample and add the envirement variables on your host
cp .env.sample .env
To run this project, you will need to add the following environment variables to your .env file
-
In order to run email verification, you must provide your email and your password (You don't have to put your own personal password. Instead, you should use another password that you can get by following these instructions Get my app password)
EMAIL
EMAIL_PASSWORD_APP
-
These env variables are necaissary for secure authentification. Make sure you put different secrets for each variable
-
ACCESS_JWT_SECRET
-
REFRESH_JWT_SECRET
-
EMAIL_JWT_SECRET
-
-
Firstly, on your terminal, make sure you are on the root project directory and run these following commands: make sure you install the dependencies
npm install
- Server is running on port 8000.
- MySql is running on port 3306 by default, you can always change that on the env variables
- Make sure to start mysql and appache servers.
Database creation and migration
- Navigate to db/ directory
cd db/
- Create the database named 'kitabi_store_db' with the following command:
npx sequelize db:create
- Create the database tables with this command:
node models/index.js
- Run this command to migrate data into the database:
npx sequelize db:seed:all
- Next, go back to the root directory and run this command to serve images to the front app:
cd ..
http-server
- Finally, start the server by typing this command:
npm start
And voila! API is running!