Node/Express REST API to provide typical functionality found in an ecommerce website. Users can create accounts, view products, add products to a cart, and place/view orders.
You can either interact with a deployed version, or run the app locally on your machine. If you prefer the deployed version option, skip ahead.
To run locally, npm install
, then npm run start
This project requires a PostgreSQL database to be running locally. Reference the ERD diagram located in the resources
folder of this repo to view the tables structure.
Make sure to create a .env
file and include the following variables:
PGDATABASE
— assigned your database nameSECRET
— assigned your express session secretPORT
(Optional ) — assigned your desired server port number
To easily populate your database with the relevant tables, npm run create-db
. This will create tables in your database if they don't already exist. The configuration for this script can be found in the setupDB.js
file located in the root of this project.
Alternatively, run the setupDB.sql
file directly in your postgres client.
Once the app is running locally, you can access the API at http://localhost:<your-port>
.
Swagger documentaion will be available at http://localhost:<your-port>/docs
.
This app is deployed on Render and its base URL is https://ecom-app-api-5syq.onrender.com
.
Swagger documentaion is available for this version as well.
Most endpoints are protected and require authentication. In order to properly access these endpoints, you will need to have a session cookie present when making your request. This is accessed by hitting the /login
endpoint first.
Note: Session cookies are not supported by Swagger UI, so its "Try it out" feature won't work.
HTTP clients will automatically store cookies and send them with subsequent requests.
You can use various HTTP clients such as Postman, Insomnia, or REST Client (which works within VS Code) to make requests to the API endpoints.