Skip to content

grand-rick001/Storefront-Backend-API

Repository files navigation

Storefront Backend API

Project two of my Udacity nano degree

To use the API, follow the steps below.

Step 1 -- Setup and configuration

  1. Run the command below to install node_modules.

    npm i
  2. After the node_modules folder has been installed, check the package.json file for the dependencies and devDependencies and install them as follows.

    • You can use either npm or yarn for installation.
    • If you use yarn as your package installer, follow step 1, if you use npm, follow step 2:
      1. YARN

        Installing the dependencies

        yarn add bcrypt body-parser cors jasmine jasmine-spec-reporter jsonwebtoken morgan nodemon pg express dotenv db-migrate db-migrate-pg

        Installing the devDependencies

        yarn add --dev typescript ts-node tsc-watch prettier jasmine-ts eslint-plugin-prettier eslint-config-prettier eslint @types/node @types/bcrypt @types/body-parser @types/cors @types/express @types/jasmine @types/jsonwebtoken @types/morgan @types/nodemon @types/pg @typescript-eslint/eslint-plugin @typescript-eslint/parser
      2. NPM

        Installing the dependencies

        npm i bcrypt body-parser cors jasmine jasmine-spec-reporter jsonwebtoken morgan nodemon pg express dotenv db-migrate db-migrate-pg

        Installing the devDependencies

        npm i -D typescript ts-node tsc-watch prettier jasmine-ts eslint-plugin-prettier eslint-config-prettier eslint @types/node @types/bcrypt @types/body-parser @types/cors @types/express @types/jasmine @types/jsonwebtoken @types/morgan @types/nodemon @types/pg @typescript-eslint/eslint-plugin @typescript-eslint/parser
  3. The tsconfig.json, eslint.json and .prettierrc are already configured for you. Don't worry about that.

  4. BACKEND PORT = 3000, DATABASE PORT = 5432.

  5. Use the .env.example to create a .env file with your own values for sensitive info and some from the database.json file.

  6. Creating user

    CREATE USER store_manager WITH PASSWORD 'password123';
    

    Creating databases

    CREATE DATABASE store;
    CREATE DATABASE store_test;
    

    Granting privileges to user

    GRANT ALL PRIVILEGES ON DATABASE store TO store_manager;
    GRANT ALL PRIVILEGES ON DATABASE store_test TO store_manager;
    

Step 2 - Running the tests

  • This will be simple, just run the command below and watch.
    npm run test // FOR NPM
    yarn test //FOR YARN
  • You should see this as the results. Tests successful

The endpoints are listed here

About

This is a backend implementation of an e-commerce API, using typescript as the primary language.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published