Code Monkey home page Code Monkey logo

storefront_api's Introduction

Storefront API

Storefront API is created for a fictional e-commerce organization, its used to store information about the products they sell, store users that use their website and manage different orders.


Table of contents


Requirements

  • yarn
  • node > 12.0.0
  • Server is running on PORT 3000
  • Database is running on PORT 5432 || you can run this query from psql to obtain the port in your environment SELECT * FROM pg_settings WHERE name='port';
  • When endpoint is marked as Auth required that refers to a requirement of JWT token to perform the action

Setup

  1. Clone this repo
  2. Run yarn install
  3. This will install all required packages

Scripts

Scripts can be run using yarn <script-name>

Script Function
watch This script runs typescript compiler on watch mode then runs nodemon on our entry point server.ts file, any subsequent saves restart the whole process automatically
build A script to compile our typescript into pure javascript code
test A script to run tests
migrate:up Initiate the migrations of the database tables
migrate:down Reverse the migrations of the database tables

Connect

To be able to connect to the database, please refer to the submission notes for ENV variables to be able to fill <POSTGRES-XXX>

1- Create a .env file in the root dir then copy-paste the variables from submission notes.

2- CTRL+SHIFT+T To open a new terminal window then run psql postgres.

3- Create new user using CREATE ROLE <POSTGRES_USER> WITH SUPERUSER PASSWORD '<POSTGRES_PASSWORD>'

4- Create a new database using the following query CREATE DATABASE <name-assigned-to-POSTGRES_DB-in-env-file>;

5- Next, in the root dir of the project you can find a database.json file which contains 2 databases one for production and another for testing

6- Run yarn migration:up script to create required tables.

7- Our database is ready to accept our CRUD operations.


notes ๐Ÿด

  1. You have to create 2 databases, one for development and another for testing.

  2. While testing, to be able to run tests on orders and order_products make sure you have:

    • a user in users table
    • a product in products table

Please refer to REQUIREMENTS for more information about the database

storefront_api's People

Contributors

mohamedy72 avatar

Stargazers

Roman avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.