Git Product home page Git Product logo

storefront-backend-udacity's Introduction

Install Instructions

To install devDependencies & dependencies

npm i

.env

POSTGRES_HOST=127.0.0.1
POSTGRES_DB=store
POSTGRES_TEST_DB=store_test
POSTGRES_USER=yourUsername
POSTGRES_PASSWORD=yourPassword
ENV=dev
BCRYPT_PASSWORD=change_Here_To_What_You_Want
SALT_ROUNDS=10
TOKEN_SECRET=change_Here_To_What_You_Want

Database and Migrations

the Database used in the project was Postgres database

to install database packages by yourself

npm i pg
npm i db-migrate db-migrate-pg

run this command to login to default postgres user

psql -U postgres

or

psql postgres

then create your postgres username

create Role yourUsername with password 'yourPassword' SUPERUSER LOGIN CREATEDB;

Default Port

Default port is 5432.

Finally

Remember to change the .env file to your own settings

Scripts of project

"prettier": "prettier --config .prettierrc 'src/**/*.ts' --write",
"build": "rm -r build && npx tsc",
"jasmine": "jasmine",
"lint": "eslint 'src/**/*.ts' --fix",
"delete-db": "db-migrate -e create db:drop store",
"init-db": "db-migrate -e create db:create store && db-migrate up ",
"start": "nodemon src/index.ts",
"delete-test-db": "db-migrate -e create db:drop store_test",
"init-test-db": "npm run delete-test-db &&db-migrate -e create db:create store_test && db-migrate -e test up ",
"test": "export ENV=test && npm run init-test-db && npm run build && npm run jasmine && npm run delete-test-db ",
"start-test": "export ENV=test && npm run init-test-db  && nodemon src/index.ts && npm run delete-test-db"

Endpoints

http://localhost:3000

Users Endpoints

Get  [/users]
Get  [/users/:id]
Post [/users]
Post [/user/authenticate]

products Endpoints

Get  [/products]
Get  [/products/:id]
Post [/products]

Orders Endpoints

Get  [/orders]
Get  [/:id]
Post [/orders/:id/products]

Database config

{
"dev": {
    "driver": "pg",
    "host": {
        "ENV": "POSTGRES_HOST"
    },
    "database": {
        "ENV": "POSTGRES_DB"
    },
    "user": {
        "ENV": "POSTGRES_USER"
    },
    "password": {
        "ENV": "POSTGRES_PASSWORD"
    }
},
"test": {
    "driver": "pg",
    "host": {
        "ENV": "POSTGRES_HOST"
    },
    "database": {
        "ENV": "POSTGRES_TEST_DB"
    },
    "user": {
        "ENV": "POSTGRES_USER"
    },
    "password": {
        "ENV": "POSTGRES_PASSWORD"
    }
},
"create": {
    "driver": "pg",
    "host": {
        "ENV": "POSTGRES_HOST"
    },
    "user": {
        "ENV": "POSTGRES_USER"
    },
    "password": {
        "ENV": "POSTGRES_PASSWORD"
    }
}

}

Database schema

TABLE users(
    id SERIAL PRIMARY KEY,
    firstName VARCHAR(100) NOT NULL,
    lastNAME VARCHAR(100)NOT NULL,
    email VARCHAR(100) NOT NULL UNIQUE,
    password TEXT NOT NULL
);
TABLE products (
    id SERIAL PRIMARY KEY,
    name VARCHAR NOT NULL,
    price INTEGER NOT NULL,
    category VARCHAR(100)
);
TABLE orders (
    id SERIAL PRIMARY KEY,
    status VARCHAR(30),
    user_id integer REFERENCES users(id)
);
TABLE order_products(
    id SERIAL PRIMARY KEY,
    quantity integer,
    order_id integer REFERENCES orders(id),
    product_id integer REFERENCES products(id)
);

storefront-backend-udacity's People

Contributors

25khattab 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.