An online bookstore built with Node.js and PostgresSQL
- Latest versions of Node.js and npm must be installed
- Postgres must be installed
- Optional: have pgAdmin installed to make database setup easier.
For all steps involving node and npm described below, ensure to cd into the project directory
- Run
npm install
- Create a database for the project. This can be done through pgAdmin.
- In the
sql/ddl-dmldirectory, run the providedDDL.sqlfile on the created database - Once the tables have been created, run the provided
all_inserts.sqlfile to insert the mock data - Once that is done, navigate to the
sql/triggersdirectory, and run theall_triggers.sqlfile to create the required triggers for the database that takes care of keeping the stock up-to-date (reducing on order and automatically reordering once reaching a given threshold)
4.1. Alternatively, you can first runstock_on_order_proc.sqland then runauto_reorder.sql
- Once the database has been initialized, create a file by the name of
.env - In the file, write the database information in the following format by replacing the
<...>with the appropriate information:
PGUSER = "<postgres-username>"
PGHOST = "localhost"
DATABASE = "<db-name>"
PASSWORD = "<postgres-user-password>"
PGPORT = <port the database is running on>
Ensure that the database has been initialized before running server.
- Run
npm startornpm run start
1.1. Optionally, you may also choose to runnode app.js
- Run
npm run devstart
- Once the server is running, navigate to http://localhost:3000/ on the browser of choice to view the different pages
You can login as an owner by entering [email protected] as the email and youshallnotpass as the password
There are many possible customer logins with the mock data insert. One possible login is email: [email protected] with password: amy70