Git Product home page Git Product logo

storefront-backend's Introduction

Storefront Backend

Overview

Storefront API using node js connected to a Postgres database.

Description

A storefront backend to support connecting to a database and allow making changes to the database. the database has 4 tables:

  • users
  • products
  • orders
  • order_products

The application makes use of the following libraries:

  • Postgres for the database
  • Node/Express for the application logic
  • dotenv from npm for managing environment variables
  • db-migrate from npm for migrations
  • jsonwebtoken from npm for working with JWTs
  • jasmine from npm for testing

Usage

  1. We use a docker container for the postgreSQL database. To create the container and setup the shopping database, run the docker-compose up --detach command in the terminal.
  2. We create tables by running the npx db-migrate up command.
  3. To start the server run the npm run start command from the terminal. The backend runs on port 3000, and the database on port 5432.

Database Migrations

  • Create all tables: npx db-migrate up
  • Drop one table at a time: npx db-migrate up
  • Drop all tables: npx db-migrate reset

Other Commands

  • prettier: npm run prettier
  • start: npm run start
  • watch: npm run watch
  • test: npm run test

Setting up the testing database

  1. To connect to the container we run docker exec -i -t storefront-backend_postgres_1 /bin/bash where storefront-backend_postgres_1 is the container name.
  2. To connect to the postgreSQL database we run the following command in the terminal: psql shopping -h localhost -U shopping_user postgres where shopping is the POSTGRES_DB and shopping_user is the POSTGRES_USER.
  3. To create the testing database run the SQL command CREATE DATABASE shopping_test where shopping_test is the testing database.

.env

POSTGRES_HOST=127.0.0.1
POSTGRES_DB=shopping
POSTGRES_TEST_DB=shopping_test
POSTGRES_USER=shopping_user
POSTGRES_PASSWORD=password123
ENV=dev
BCRYPT_PASSWORD=secret
SALT_ROUNDS=10
TOKEN_SECRET=secrettoken

Resources

Author

  • Shorouk Elkhateeb

storefront-backend's People

Contributors

shelkhateeb 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.