TheHuntingGame (deprecated)
last updated: 19th march 2025
⚠️ Warning: Documentation deprecated!!!
Server-Setup
Important:
Change the DB_HOST value to postgres if you are switching from manual development to docker. DB_HOST value should be localhost for manual development.
Manual development (non Docker)
GitHub Codespaces
Install extension git graph
Install npm packages:
sudo npm install
(sudo npm i -g)
Install postgresql, log in, change password and create database thehuntinggame:
sudo apt-get update
sudo apt-get -y install postgresql
sudo service postgresql start
sudo su postgres
psql postgres
Change password:
\password
Create Database:
CREATE DATABASE thehuntinggame;
General Commands:
Start PostgreSQL Server:
sudo service postgresql start
Stop PostgreSQL Server:
sudo service postgresql stop
Start Redis Server:
sudo service redis-server start
Stop Redis Server:
sudo service redis-server stop
Start nodemon Server:
ctrl+c
MacOS
Install homebrew,
Open Code in VS Code
(install git graph extension)
Open Terminal (cmd+space, search for ‘Terminal’)
install postgresql, redis:
brew install postgresql@14
brew install redis
Start redis:
redis-server
Start Postgresql server (from now on it will auto start at login):
brew services start postgresql
go into postgres:
psql postgres
change password:
\password
If you changed the password to other than “postgres”, you have to update the .env and the docker-compose.yml file too:
DB_USER=postgres
DB_PASSWORD=postgres //Change this
DB_NAME=thehuntinggame
DB_HOST=localhost
JWT_SECRET=ekjbfjw
REFRESH_TOKEN_SECRET=melwmflw
NODE_ENV=DEVELOPMENT
REDIS_HOST=redis
REDIS_PORT=6379
EMAIL_USER=(google email)
CLIENT_ID=(google client id)
CLIENT_SECRET=(google client secret)
REFRESH_TOKEN=(google refresh token)
services:
app:
build: .
container_name: thehuntinggamebackend
ports:
- "3000:3000"
environment:
- PORT=3000
- DB_HOST=postgres
- DB_PORT=5432
- DB_USER=postgres
- DB_PASSWORD=postgres #CHANGE
- DB_NAME=thehuntinggame
- REDIS_HOST=redis
- REDIS_PORT=6379
depends_on:
- postgres
- redis
volumes:
- .:/app
- /app/node_modules
postgres:
image: postgres:14
container_name: postgres
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres #CHANGE
POSTGRES_DB: thehuntinggame
ports:
- "5432:5432"
volumes:
- postgres-data:/var/lib/postgresql/data
redis:
image: redis:6
container_name: redis
ports:
- "6379:6379"
volumes:
- redis-data:/data
volumes:
postgres-data:
redis-data:
Continue creating the database:
CREATE DATABASE thehuntinggame;
Exit posgresql using:
\q
General Commands:
Start the Dev Server using:
nodemon server.js
Stop the Server using:
ctrl+c
stop redis:
ctrl+c
//or
redis-cli shutdown
start redis:
redis-server
Setup email verification sending
✅ Step 1: Make Sure OAuth Consent Screen is Set Up
- Go to Google Cloud Console.
- Navigate to APIs & Services → OAuth consent screen.
- If you haven’t set it up, set the User Type to “External” (required for non-Google Workspace accounts).
- Fill in required fields:
- App name (e.g., “TheHuntingGame”).
- User support email.
- Developer contact email.
- Scopes: Add
https://mail.google.com/(if missing). - Test Users: If in “Testing” mode, add your email as a test user.
- Click Save and Continue.
✅ Step 2: Enable Gmail API
- Go to Gmail API.
- If not enabled, click Enable.
✅ Step 3: Verify OAuth Client ID and Secret
-
Go to APIs & Services → Credentials.
-
Under OAuth 2.0 Client IDs, create a new ClientID, make sure that:
- Application Type is Web (as you are developing/deploying to a web server).
- Redirect URI:
https://developers.google.com/oauthplayground
- Client ID & Client Secret match your
.envfile.
✅ Step 4: Use OAuth Playground to Get Refresh Token
If you didn’t generate the refresh token correctly, redo these steps:
-
Open OAuth 2.0 Playground.
-
Click “OAuth 2.0 Configuration” (gear icon).
-
Check “Use your own OAuth credentials”, enter:
- Client ID (from Google Cloud).
- Client Secret (from Google Cloud).
-
In Step 1, add this scope:
<https://mail.google.com/> -
Click “Authorize APIs” → Sign in with your Gmail account.
-
In Step 2, click “Exchange authorization code for tokens”.
-
Copy the Refresh Token (not the access token) and update your
.envfile:REFRESH_TOKEN=your-refresh-token
- Add your email as USER_EMAIL to the .env file
Template .env:
DB_USER=postgres
DB_PASSWORD=postgres //Whatever your password is
DB_NAME=thehuntinggame
DB_HOST=localhost
JWT_SECRET=ekjbfjw
REFRESH_TOKEN_SECRET=melwmflw
NODE_ENV=DEVELOPMENT
REDIS_HOST=redis
REDIS_PORT=6379
EMAIL_USER=(google email)
CLIENT_ID=(google client id)
CLIENT_SECRET=(google client secret)
REFRESH_TOKEN=(google refresh token)