Table of Contents
This is a backend API build in Nodejs for an online store. It exposes a RESTful API that will be used by the frontend developer on the frontend.
The database schema and and API route information can be found in the REQUIREMENT.md
- Typescript
- Node.js
- Epress framework
- Jasmine
- postgreSQL
This project require some prequesites and dependenscies to be installed, you can find the instructions below
To get a local copy, follow these simple steps :
-
Clone the repo
git clone https://github.com/SalmaaOsamaa/Storefront-Backend.git
-
install dependenscies
npm install
-
create databases
-
connect to the default postgres database as the server's root user
psql -U postgres
-
In psql run the following to create a user
CREATE USER postgres WITH PASSWORD '1111';
-
In psql run the following to create the dev and test database
CREATE DATABASE storefront_end; CREATE DATABASE store_test;
-
Connect to the databases and grant all privileges
\c storefront_end; GRANT ALL PRIVILEGES ON DATABASE storefront_end TO postgres; \c store_test; GRANT ALL PRIVILEGES ON DATABASE store_test TO postgres;
-
In psql run the following to create the dev and test database
CREATE DATABASE storefront_end; CREATE DATABASE store_test;
-
-
Enviromental Variables Set up
- Here are the environmental variables that needs to be set in a .env file. This is the default setting that I used for development, but you can change it to what works for you.
PORT=3000 NODE_ENV=dev POSTGRES_HOST=127.0.0.1 POSTGRES_PORT= 5432 POSTGRES_DB=storefront_end POSTGRES_DB_TEST=store_test POSTGRES_USER=postgres POSTGRES_PASSWORD=1111 BCRYPT_PASSWORD=top-secret SALT_ROUNDS=10 TOKEN_SECRET=your-secret-token
-
Run Migrations
# globally to use its terminal comands npm install -g db-migrate db-migrate up
-
Run development server
npm start
-
or: Run Production server
npm run build
- Testing
npm run test
- Server runs on port
3000
- Database on port
5432
-
All endpoints are described in the REQUIREMENT.md file.
-
Token and Authentication Tokens are passed along with the http header as
Authorization Bearer <token>
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request