/Reviews-Service

Reviews component of a musical instrument bazaar.

Primary LanguageJavaScript

seller-reviews

Displays reviews that an item's seller has received.

Related Projects

Sidebar Service: https://github.com/HRR47-SDC-OMalley/sidebar-service Main Photo Service: https://github.com/HRR47-SDC-OMalley/main-photo

Table of Contents

  1. Usage
  2. Requirements
  3. Development
  4. Production
  5. Deployment

Usage

READ: http://localhost:3000/item/24

POST a new product at a new product id: http://localhost:3000/reviews/api/item/endpoint/:listingId input: {string name, string condition, string category, string style, string brand, boolean asDescribed, string description, string seller}

PUT (update) an existing seller with a provided object: http://localhost:3000/reviews/api/seller/ input: name to update, updates {[] listings, [] listings_counts, [] reviews}

DELETE all reviews for a product: http://localhost:3000/reviews/api/item/:listingId/reviews

Requirements

Development

Execute all these commands from the repository's root directory.

Installing Dependencies

npm install

Seeding CSV File

npm run seed

CSV will be seeded with x item listings.

Database Setup

Postgres join table copy from tables to single CSV:

node database/postgres/copyToCSV.js

Cassandra copy from CSV file:

COPY guitarandreview(id,"productId",author,date,description,name,rating) FROM '~/Documents/projects/hrr47-sdc-omalley.nosync/Reviews-Service/database/seedFiles/guitarsAndReviews.csv' WITH DELIMITER=',' AND HEADER=TRUE;

Testing

npm run test

Production

Webpack

npm run build:watch

Node Express Server

Starts nodemon and loads environment variables

npm start

Deployment

Hosting Webpack Bundles From Cloud

These require the dev-dependencies to be installed

  • Create a file named aws-keys.json in the root directory, with the following contents:
{
  "AWSAccessKeyId": "<your-access-key-ID>",
  "AWSSecretKey": "<your-access-secret-key>",
  "bucket": "<your-bucket-name>"
}
  • Run grunt deploy on the terminal

Hosting Service On Docker

Requirements: [Docker v19.03.12] (https://docs.docker.com/engine/install/) [Docker Compose v1.26.2] (https://docs.docker.com/compose/install/)

  • Run docker-compose build to build a Docker image
  • Run docker-compose up -d to start running the service on port 80
  • Run docker-compose down to stop the service

Running docker-compose up -d the first time will automatically build an image. However, if you want to make any changes afterwards, you need to run build, take down the image with down, and then put up the new image with up -d.

If you host the service in a shell, Docker and Nodejs will not work out of the box. You need to install them on your shell before you can make use of the Dockerfile and package.json.