This repo contains a basic Node and Express app to get you started in constructing an API. To get started, clone this repo and run yarn
in your terminal at the project root.
This project using Postgres SQL
-
Connect to the default postgres database as the server's root user
psql -U postgres
-
Create user
CREATE USER admin WITH PASSWORD '123456';
-
Create database for dev and test
CREATE DATABASE storefront;
CREATE DATABASE storefront_test;
-
Change the owner of a database to role.
ALTER DATABASE storefront OWNER TO admin;
ALTER DATABASE storefront_test OWNER TO admin;
You need to install db-migrate: npm install -g db-migrate
After install db-migrate, run db-migrate up
to migrate database
Add a .env
file in the root directory and set the missing ###
environment parameters
PORT=127.0.0.1
POSTGRES_HOST="localhost"
POSTGRES_USER=###
POSTGRES_PASSWORD=###
POSTGRES_DB="storefront"
POSTGRES_TEST_DB="storefront_test"
TOKEN_KEY=###
ENV=dev
BCRYPT_PASSWORD=###
SALT_ROUNDS="10"
yarn install
- Start project:
yarn start
- Test:
yarn run test