Git Product home page Git Product logo

storefront-backend-udacity's Introduction

Welcome to storefront-backend ๐Ÿ‘‹

Version License: MIT

A node express server application providing restful api endpoints to manage products and user orders for an online store.

Prerequisites

  • npm >= 6.9.0

  • node >= 12.0.0

  • yarn

Install

Run the following command in the projects root folder to install dependencies. All provided yarn commands are run at the root level of the project.

yarn install

Database Setup (for both development and test databases)

The server application is configured to run with a Postgresql database running with the following settings:

  • Host: 127.0.0.1
  • Port: 5432
  • Database user: "shopping_user"
  • Database name: "shopping"
  • Test database name: "shopping_test"

To set up the database (dev + test), use the following commands in postgresql environment:

  CREATE USER shopping_user WITH PASSWORD 'yourpasswordhere';
  CREATE DATABASE shopping; 
  GRANT ALL PRIVILEGES ON DATABASE shopping TO shopping_user;
  CREATE DATABASE shopping_test;
  GRANT ALL PRIVILEGES ON DATABASE shopping_test TO shopping_user;

A .env file should also be created containing variables with names matching those seen in the database.json file and containing all the settings above.

Environment variables

A .env file is required to hold environment variables for project. Create a .env file and copy the following into it.

POSTGRES_HOST=127.0.0.1
POSTGRES_PORT=5432
POSTGRES_DB=shopping
POSTGRES_TEST_DB=shopping_test
POSTGRES_USER=shopping_user
POSTGRES_PASSWORD=yourpassword123
ENV=dev
BCRYPT_PASSWORD=your-secret-hash-password-123
SALT_ROUNDS=10
TOKEN_SECRET=wicked-witch-of-the-west

Usage

To start the server appplication run the following command.

yarn watch

The application is configured to run on localhost port 3000 - http://localhost:3000.

Run tests

To run available tests, use following command.

yarn test

This temporarily modifies the ENV key in environment variables from 'dev' to 'test' and runs migrations to setup the test database to be used for testing. The test database is pulled down after tests are complete.

Run build

The following command can be used to compile and build the project from typescript to javascript.

yarn build

Once the build is complete the built project can be found in the dist folder. To start the built application you can run the following command in the root folder of the project.

node dist/.

Author

๐Ÿ‘ค Amy Turnah

Show your support

Give a โญ๏ธ if this project helped you!


This README was generated with โค๏ธ by readme-md-generator

storefront-backend-udacity's People

Contributors

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