$ git clone https://github.com/raymondngiam/FSJND-BuildAStorefrontBackend.git
$ cd FSJND-BuildAStorefrontBackend
$ npm install
$ npm run build
-
Default installation of PostgreSQL would be running at the TCP/IP address of
127.0.0.1:5432
. This can be verified with the following bash command:$ sudo netstat -plunt | grep postgres tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN 991/postgres
-
To setup the database for this application, first start a terminal and change user to
postgres
.$ sudo -iu postgres postgres $
-
Start
psql
postgres $ psql postgres=#
-
Create a new user
shopping_user
in thepsql
prompt with the following command:postgres=# CREATE USER shopping_user WITH PASSWORD 'password123';
-
Create two databases
postgres=# CREATE DATABASE shopping_dev; postgres=# CREATE DATABASE shopping_test;
-
Connect to the database
shopping_dev
postgres=# \c shopping_dev You are now connected to database "shopping_dev" as user "postgres". shopping_dev=#
-
Grant permission on
SCHEMA
(of the current database) to the user:shopping_dev=# GRANT ALL ON SCHEMA public TO shopping_user;
-
Connect to the database
shopping_test
postgres=# \c shopping_test You are now connected to database "shopping_test" as user "postgres". shopping_test=#
-
Grant permission on
SCHEMA
(of the current database) to the user:shopping_test=# GRANT ALL ON SCHEMA public TO shopping_user;
-
Quit
psql
shopping_test=# \q
-
To setup the migration:
$ db-migrate --env dev up
-
To tear down the migration:
$ db-migrate --env dev reset
$ npm run test
$ node dist/server.js