Reviews service for Team Bell's Steam app clone. Here is a journal documenting my entire process for creating this service.
Note that some display images do not work because the target API service has not completely implemented support for them yet.
These are the related Steam services, of which Game Description and the reverse proxy were also developed by me individually.
- Reviews Graph
- Downloadable Content
- Photo Carousel
- User Tags
- Game Description
- Steam Clone - Reverse Proxy
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
- Node JS v12
- PostgreSQL v12
-
Clone repo & install dependencies:
git clone https://github.com/FEC-Bell/steam-reviews.git` cd steam-reviews npm install npx install-peerdeps knex
-
PostgreSQL v12 must be set up before continuing:
- Linux setup (assuming Ubuntu v16.04+)
- MacOS setup
- Windows setup
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.
-
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, deleteyour_password_here
from the above line. The.env
file has been.gitignore
d 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 ~ %
-
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. -
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
- If using Mac: instead of
-
Ensure that all tests pass with
npm run test
. -
Start the server with
npm run server:dev
.- Alternatively, start a production server with
npm run start
.
- Alternatively, start a production server with
-
Start the client with
npm run client:dev
.- Alternatively, build a production-ready minified
bundle.js
withnpm run build
.
- Alternatively, build a production-ready minified
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}
ANDto={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
Any uncovered problems, or errors that you solved and want to share? Feel free to open a issue.
- If using
psql -d steam_reviews
via CLI to check that the database was seeded properly, an errormight appear. If this happens, usepsql: error: could not connect to server: FATAL: role "<USERNAME>" does not exist
sudo su postgres
to switch to the postgres account, and runpsql -d steam_reviews
again. If user 'postgres' does not exist in your system, you may create this user with superuser permissions by typingCREATE USER postgres SUPERUSER;
in psql CLI. See this post for more details. Typingsudo su YOUR_USERNAME
will switch you back to your user account.