Skip to content

Reviews module (Most Helpful Reviews) for Steam clone app

Notifications You must be signed in to change notification settings

FEC-Bell/steam-reviews

Repository files navigation

Steam Reviews Service

Build Status Coverage Status

Reviews service for Team Bell's Steam app clone. Here is a journal documenting my entire process for creating this service.

Media

Steam Reviews

Link to deployed site

Steam Reviews GIF Demo

Link to deployed site

Steam Game Description GIF Demo

Note that some display images do not work because the target API service has not completely implemented support for them yet.

Link to deployed site

Steam Proxy GIF Demo

Related Projects

These are the related Steam services, of which Game Description and the reverse proxy were also developed by me individually.

Table of Contents

  1. Usage
  2. Requirements
  3. Development
  4. Service Endpoints
  5. Troubleshooting

Usage

The Steam Reviews microservice is intended to be used in conjunction with its Related Projects to create a realistic Steam item details page clone using Docker and AWS. Here is an example of a proxy server created with this service.

git clone https://github.com/FEC-Bell/steam-reviews.git`
cd steam-reviews
npm install

Requirements

  • Node JS v12
  • PostgreSQL v12

Development

  1. Clone repo & install dependencies:

    git clone https://github.com/FEC-Bell/steam-reviews.git`
    cd steam-reviews
    npm install
    npx install-peerdeps knex
    
  2. PostgreSQL v12 must be set up before continuing:

    If using Windows, you may also install PostgreSQL as a Linux service via Windows Subsystem for Linux. However, you'll need to upgrade to WSL 2.0 if using Ubuntu v20.04. See this journal post for details on how this can be done.

    Verify that PostgreSQL is version 12.

    PostgreSQL service commands for Windows WSL or Linux:

    sudo service postgresql start
    sudo service postgresql stop
    sudo service postgresql status
    

    PostgreSQL service commands for Mac:

    brew services start postgresql
    brew services stop postgresql
    brew services
    

    Further development assumes that PostgreSQL is running on its default port, 5432, and has been installed with the default settings otherwise.

  3. Create file named .env in local repo root containing the following lines:

    PORT=3001
    PG_PASS=your_password_here
    PG_USER=your_username_here
    

    The PG_PASS line is the password for accessing your PostgreSQL service. You may add other environment variables to this file, and access them throughout your code via adding the line require('dotenv').config() in your code. If you did not provide a password during PostgreSQL installation, delete your_password_here from the above line. The .env file has been .gitignored for your convenience.

    Your username for accessing PG_USER on Windows WSL or Linux should be postgres. On Mac, it should be your username as displayed in zsh: your_username@MacBook-Pro ~ %

  4. Create the steam_reviews database in your CLI:

    createdb steam_reviews
    

    Or from inside psql:

    CREATE DATABASE steam_reviews;
    

    Make sure you're entering the above command as the user postgres (or whatever your username is on Mac). See Troubleshooting PostgreSQL for more information.

  5. Seed the database with npm run seed.

    • If using Mac: instead of npm run seed, run:
    sudo npm i -g knex
    npm run seed:internal
    
    • You may check that the DB has the proper entries via psql CLI tool:
    psql -d steam_reviews         // connect to steam_reviews database
    \dt                           // describe tables
    select count(*) from badges;  // 16
    select count(*) from users;   // 750
    select count(*) from reviews; // 1000
    \q                            // quit psql
    
  6. Ensure that all tests pass with npm run test.

  7. Start the server with npm run server:dev.

    • Alternatively, start a production server with npm run start.
  8. Start the client with npm run client:dev.

    • Alternatively, build a production-ready minified bundle.js with npm run build.

Service Endpoints

GET /api/gamereviews/:gameid

Data shape:

{
  steamPurchasedCount: Number,
  otherPurchasedCount: Number,
  data: [
    {
        "id": Number,
        "id_user": Number,
        "user": {
            "id": Number, // matches id_user
            "username": String,
            "profile_url": String,
            "is_online": Boolean,
            "num_products": Number,
            "num_reviews": Number,
            "steam_level": Number,
            "id_badge": Number, // id may be null, in which case badge entry won't be present
            "badge": Null || {
                "id": Number, // matches id_badge
                "title": String,
                "xp": Number,
                "badge_url": String
            }
            "is_in_game": Boolean,
            "in_game_id": Null || Number,
            "in_game_status": Null || String
        },
        "id_game": Number,
        "is_recommended": Boolean,
        "hours_on_record": Single-precision Float String (“1800.3”),
        "hours_at_review_time": Single-precision Float String (“1800.3”),
        "purchase_type": String (either `direct` or `key`),
        "date_posted": ISODateString ("2020-06-03T15:00:00.000Z"),
        "received_free": Boolean,
        "review_text": String,
        "num_found_helpful": Number,
        "num_found_funny": Number,
        "num_comments": Number
    },
    {
      id: Number
      ... etc etc. Total data count will be 10 or less every time
    }
  ],
  recent: [
    ...
    // Same content as data, but ordered by date. Recent will only appear when the endpoint is hit with a display=summary query, or when the display query is absent (defaults to summary in that case).
  ]
}

Query parameters (URLSearchParams) for /api/gamereviews/:gameid:

  • Review type param:

    • review_type={all || positive || negative}
    • Default: all
  • Purchase type param:

    • purchase_type={all || steam || other}
    • Default: all
  • Date range params:

    • from={yyyy-mm-dd}
    • to={yyyy-mm-dd}
    • Default: omit this query param to get the default search range, which is all reviews -- only 10 reviews per game are in the dataset
    • from={yyyy-mm-dd} & to={yyyy-mm-dd} are both optional
    • Interacts with Reviews Graph service
  • Exclude date range param:

    • exclude={true || false}
    • Default: false
    • If true, filter results will be of dates EXCLUDING the range parameter specified above. If no date range parameter with from={yyyy-mm-dd} AND to={yyyy-mm-dd} is specified, this parameter does nothing.
  • Playtime params:

    • play_min={[0-100]}
    • play_max={[0-100]}
    • Default: you may omit these queries to get the default, which is no min & no max
    • One or both queries may be used to specify upper/lower range
    • Valid ranges from client UI are:
      • No minimum
      • Over 1 hour: play_min=1
      • Over 10 hours: play_min=10
      • Over 100 hours: play_min=100
      • More granular filter options with double-ended slider
  • Display as param:

    • display={summary || helpful || recent || funny}
    • Default: summary
    • ONLY Summary will bring up the right-sided "Recently Posted" reviews sub-module
  • Example:

    • /api/gamereviews/:gameid?review_type=negative&from=2019-06-01&play_min=50
    • Get all negative reviews from last June 1st until now from people who`ve played at least 50 hours

Troubleshooting

Any uncovered problems, or errors that you solved and want to share? Feel free to open a issue.

Troubleshooting PostgreSQL

  1. If using psql -d steam_reviews via CLI to check that the database was seeded properly, an error
    psql: error: could not connect to server: FATAL:  role "<USERNAME>" does not exist
    
    might appear. If this happens, use sudo su postgres to switch to the postgres account, and run psql -d steam_reviews again. If user 'postgres' does not exist in your system, you may create this user with superuser permissions by typing CREATE USER postgres SUPERUSER; in psql CLI. See this post for more details. Typing sudo su YOUR_USERNAME will switch you back to your user account.

About

Reviews module (Most Helpful Reviews) for Steam clone app

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages