Skip to content

SalmaaOsamaa/Storefront-Backend

Repository files navigation

Storefront Backend Project

node express TypeScript Jasmine Postgresql


Logo

Storefront Backend

Report Bug

Table of Contents
  1. About The Project
  2. Getting Started
  3. Contributing
  4. Acknowledgments

About The Project

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

(back to top)

Built With

  • Typescript
  • Node.js
  • Epress framework
  • Jasmine
  • postgreSQL

(back to top)


Getting Started

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 :

Installation

  1. Clone the repo

    git clone https://github.com/SalmaaOsamaa/Storefront-Backend.git
  2. install dependenscies

    npm install
  3. 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;
  4. 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
    
  5. Run Migrations

    # globally to use its  terminal comands
    npm install -g db-migrate
    
    db-migrate up
  6. Run development server

    npm start
    
  • or: Run Production server

    npm run build 
  1. Testing
npm run test

(back to top)


Ports & EndPoints

Ports

  • Server runs on port 3000
  • Database on port 5432

API endpoints

  • All endpoints are described in the REQUIREMENT.md file.

  • Token and Authentication Tokens are passed along with the http header as

    Authorization   Bearer <token>
    

    Run in Postman


Contributing

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!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

Acknowledgments