Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Codylon Studios Documentation

© 2022 - 2026 Codylon Studios

💡 You can search for different projects and install guides to see what Codylon Studios has done so far.

Github: https://github.com/Codylon-Studios

The documentation for TaskMinder on Notion is deprecated, see more: https://docs.taskminder.de

Big Game

last updated: 18th jan 2025

Github Codespaces

⚠️ Warning: FÜR CODESPACES (EXPLIZIT DAFÜR/NICHT FÜR ANDERE OS)

  1. Codespaces starten, Erweiterung git graph installieren
  2. In Kommandozeile ausführen: (Installiert alle dependencies)
sudo npm install
  1. (PostgreSQL (Datenbank-Management) installieren):
sudo apt-get update
sudo apt-get -y install postgresql
  1. (Start von postgresql server):
sudo service postgresql start
  1. (Einloggen in Terminal vom Server):
sudo su postgres
  1. (Anmelden als postgres user (Standard-user)):
psql postgres
  1. (Passwort ändern und merken!):
\password
  1. (Erstellt eine Datenbank namens accounts):
CREATE DATABASE accounts;
  1. (Listet alle Datenbanken auf):
\l
  1. (Verbindet sich mit Datenbank accounts):
\c accounts
  1. (Erstellt Tabelle accounts):
CREATE TABLE accounts (
id SERIAL PRIMARY KEY,
username VARCHAR(255) UNIQUE NOT NULL,
password VARCHAR(255) NOT NULL
);
  1. (erstellt Tabelle chessgames):
CREATE TABLE chessgames (
    game_id SERIAL PRIMARY KEY,                 
    player_white_id INT NOT NULL,                
    player_black_id INT NOT NULL,                
    start_time TIMESTAMP NOT NULL,          
    end_time TIMESTAMP,                          
    status ENUM('ongoing', 'white_won', 'black_won', 'draw') NOT NULL,                          
    moves TEXT,                                  
    is_rated BOOLEAN DEFAULT FALSE,              
    time_control VARCHAR(20),                    
    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 
    FOREIGN KEY (player_white_id) REFERENCES accounts(id) ON DELETE CASCADE ON UPDATE CASCADE,
    FOREIGN KEY (player_black_id) REFERENCES accounts(id) ON DELETE CASCADE ON UPDATE CASCADE
);
  1. (Verlassen psql Terminal Oberfläche, danch Terminal schließen und neu öffnen):
\q
  1. (Für datenbankverbindung noch config_db.json anlegen!):

your_password beim password parameter soll dabei den Wert tragen, der in Schritt 7 festgelegt wurde.

db_config.json:

{
"host": "localhost",
"port": 5432,
"database": "accounts",
"user": "postgres",
"password": "your_password",
}
  1. Start von Server:
nodemon server.js
  1. Besuchen der Website:
localhost:3000
  1. Jetzt kann man programmieren! Veränderungen im Code werden automatisch erkannt und der Server wird daraufhin neu gestartet.
  2. Ausführen von Git-Befehlen (wenn nötig)
  3. Stoppen des Servers (windows, mac, linux)
control+c
  1. Stoppen der Postgres Datenbank:
sudo service postgresql stop

Bei allen weiteren Malen können die Schritte 1 bis inklusive 15 übersprungen werden, nur die Schritte 16-20 werden für den normalen workflow benötigt. Jedoch muss man vor den 16. Schritt noch

sudo service postgresql start

ausführen, denn dies startet den postgres server (datenbank).


Error/Troubleshooting

1️⃣:

Error: listen EADDREINUSE: address already in use :::3000

(zeigt alle offenen Anwendungen für port 3000 an):

sudo lsof -i :3000

Dies listet alle offenen Anwendungen für port 3000 an, jede enthält eine PID, nun kann man jede ungenutzte Anwendungen durch ihre PID beenden:

(beendet die PID):

kill -9 <PID> 

2️⃣:

error: Error: Cannot find module 'bcrypt'

(Wenn bycrpt Fehler gibt):

npm uninstall bcrypt
npm i bcrypt

3: when running psql postgres

psql: error: connection to server on socket “/tmp/.s.PGSQL.5432” failed: No such file or directory Is the server running locally and accepting connections on that socket?

Auf mac: (gibt das Ende der log-file aus:)

tail -n 10 /opt/homebrew/var/log/postgres.log

bzw:

tail -n 10 /opt/homebrew/var/log/postgresql@{version}.log

If error =

data directory “/opt/homebrew/var/postgresql@14” has invalid permissions

Permissions should be u=rwx (0700) or u=rwx,g=rx (0750).

sudo chmod -R 0700 /opt/homebrew/var/postgresql@14

bzw.:

sudo chmod -R 0700 /opt/homebrew/var/postgres

Git

Under this section, some Git merging strategies will be introduced. Always ask other People before merging branches.

Rebase-Merge (Preferred)

Rewrites the feature branch history to make it appear as if it was developed on top of the current develop branch. This creates a linear history for the feature branch commits and a merge commit when the feature branch is finally merged.

git checkout develop
git pull
git checkout <branch>
git rebase develop
git push --force
git checkout develop
git merge --no-ff <branch>
git push
git branch -d <branch>

You can call git config merge.ff false to change config. Then you can call git merge <branch>instead of git merge --no-ff <branch> for future uses.

Merge (Alternative)

Retains the original commit history and creates a merge commit. The history will show exactly where the branches diverged and merged.

git checkout develop
git pull
git merge <branch>
git push

programmierspiel2022

last updated: 18th jan 2025

Install Guide:

Download the project under: GitHub Project. Open the folder and double click on sourcecode.html to open game in browser.

TaskMinder

last updated: 19th march 2025

⚠️ Warning: Documentation deprecated, new docs here: TaskMinder Docs.

DEVELOPMENT

  1. Start an editor of you choice (preferrably VS Code), install extension “git graph”
  1. Open Terminal, execute
sudo npm install

to install all dependencies.

Installation of redis:

Follow the guide of your OS (see link below):

For GitHub Codespaces, follow the guide for Ubuntu (Linux).

Install Redis

start Redis:

individuell for OS

GitHub Codespaces:
sudo service redis-server start

For the next step, you need to install the database, PostgreSQL, which is individuell for every OS:

PostgreSQL: Downloads

For GitHub Codespaces, execute the following commands to install PostgreSQL start and create the database:

sudo apt-get update
sudo apt-get -y install postgresql
sudo service postgresql start
sudo su postgres
psql postgres
\password
CREATE DATABASE haplaner;

For the other OS, please get into pqsl (SQL Shell) as user postgres and change the password using \password and lastly, create the database:

psql -U postgres
\password
CREATE DATABASE haplaner;

Create an .env file in the root folder, which holds all your enviroment variables:

For DB_PASSWORD, set the value to your password set for the postgres user ealier in this guide.

.env:

DB_USER=postgres
DB_PASSWORD=your_postgres_password
DB_NAME=haplaner
DB_HOST=localhost
NODE_ENV=DEVELOPMENT
REDIS_HOST=redis
REDIS_PORT=6379
SESSION_SECRET=your_session_secret
DSB_USER=your_dsb_user
DSB_PASSWORD=your_passcode
CLASSCODE=your_classcode
DB_CONTAINER=taskminder-postgres
BACKUP_DIR=/var/taskminder/backups

Before starting the server, you still need to create two tables:

node ./src/initTables/eventType.js
node ./src/initTables/team.js

Finally, you can start the server:

nodemon server.js

Visit http://localhost:3000 to view the website.

Stopping the server:

control+c

Stopping redis and postgresql:

See inidividual guides for redis and postgresql on thier offical websites:

GitHub Codespaces:
sudo service postgresql stop
sudo service redis-server stop

Old SQL cmds (not used anymore)

  1. (Listet alle Datenbanken auf):
\\l

  1. (Verbindet sich mit Datenbank haplaner):
\\c haplaner

  1. (Erstellt Tabelle users):
CREATE TABLE users (
id SERIAL PRIMARY KEY,
username VARCHAR(255) UNIQUE NOT NULL,
password VARCHAR(255) NOT NULL,
-- school VARCHAR(200) NOT NULL,
class VARCHAR(255) NOT NULL
);

  1. Erstellt Tabelle hausaufgaben10d: (wenn bereits erstellt wurde: → ALTER TABLE hausaufgaben10d(…….);)
CREATE TABLE homework10d (
   homeworkId SERIAL PRIMARY KEY,
   content TEXT NOT NULL,
   subjectId INT NOT NULL,
   assignmentDate BIGINT NOT NULL,
   submissionDate BIGINT NOT NULL
   -- lastChanged DATE NOT NULL,
   -- author VARCHAR(50) NOT NULL,
   -- FOREIGN KEY (author) REFERENCES users(username)
);

  1. Erstellt Tabelle ereignisse10d
(leer)

  1. Erstellt Tabelle user_ha10d (JOIN TABLE)
CREATE TABLE homework10dCheck (
   checkId SERIAL PRIMARY KEY,
   username VARCHAR(255) NOT NULL,
   homeworkId INT NOT NULL,
   checked BOOLEAN NOT NULL DEFAULT FALSE,
   FOREIGN KEY (username) REFERENCES users(username) ON DELETE CASCADE,
   FOREIGN KEY (homeworkId) REFERENCES homework10d(homeworkid) ON DELETE CASCADE,
   CONSTRAINT unique_user_homework UNIQUE (username, homeworkId) -- ensure a user can only check each homework once
);

  1. Erstellt Tabelle anmerkungen10d
(leer)

  1. (Verlassen psql Terminal Oberfläche):
\\q

  1. Terminal (nur dieses) schließen und neu öffnen

PRODUCTION (Docker Compose)

1. Set Up Server Environment

Update and Upgrade Packages:

sudo apt update && sudo apt upgrade -y
  1. Ensure you have bought a domain name from a domain registrar (Squarespace, namecheap etc.)
  2. Ensure git is installed and you have a working terminal text editor (either nano or vi).
git --version
vi --version
nano --version
  1. Ensure you have changed the password for the root user for safety reasons.
  2. Find out public IP address of server.
  3. Update the DNS Configuration on the website of your domain registrar.

Configure Domain Name

DNS Settings: Log in to your domain registrar’s control panel and set an A record for www.codylon.de pointing to your Server’s public IP address.

Should look like this:

Host/Name: www

Type: A

IP Address: The public IP of your server

TTL: 3600 seconds (default or 1 hour is fine)

Dynamic DNS (If Applicable): If your IP address is dynamic, consider setting up a Dynamic DNS service to keep your domain pointing to the correct IP.

You can check the propagation of your DNS records using tools like DNS Checker. Search for your domain and verify that it resolves to your public IP.

2. Continue Setting Up the Environment

  1. install and activate the firewall (ufw), allow 80 and 443 (HTTP and HTTPS) to pass.
  2. Ensure docker, docker-cli and docker compose are installed:

Ubuntu

  1. Clone GitHub repository

Navigate to the Desired Directory: Choose a directory where you want to store your project. (create one with mkdir)

cd /pathtodirectory 

Clone the Repository: Use Git to clone the repository:

git clone https://github.com/Codylon-Studios/TaskMinder.git

Create Docker Secrets

In the root folder of your application, create a new folder named docker_secrets.

Inside, create 8 .txt files:

db_name.txt

db_password.txt

db_user.txt

redis_port.txt

session_secret.txt

class_code.txt

dsb_password.txt

dsb_user.txt

backup_dir.txt

db_container.txt

Set Up the Proxy (Nginx)

  1. Install Nginx:

    sudo apt install nginx
    
  2. Create a configuration file for your domain (replace codylon.de with your domain name) :

    sudo nano /etc/nginx/sites-available/codylon.de
    
  3. Copy your configuration into that file (the one that is provided in the root folder of the cloned repo). Make sure to replace codylon.de with your domain name in the marked places in the Nginx configuration.

  1. Set up SSL certificates using Let’s Encrypt, again replacing codylon.de with your domain name in the command.:

    sudo apt install certbot python3-certbot-nginx
    sudo certbot --nginx -d codylon.de
    

    This will automatically create the SSL certificates at the path specified in your config.

  2. Create a symbolic link to enable the site:

(Replace codylon.de with your actual domain name)

sudo ln -s /etc/nginx/sites-available/codylon.de /etc/nginx/sites-enabled/
  1. Test the configuration for syntax errors:

    sudo nginx -t
    
    
  2. Restart Nginx to apply the changes:

    sudo systemctl restart nginx
    
    
  3. Make sure your application is running on port 3000 (as specified in proxy_pass http://localhost:3000).

Don’t forget to init the tables:

node ./src/initTable/eventType.js
node ./src/initTable/team.js
  1. Start the docker Compose
docker compose up -d --build

8. Test the Deployment

Access the Site: Navigate to https://www.codylon.de in your browser to verify that the site is live and the SSL certificate is functioning correctly.

Check for Errors: Monitor the Nginx logs for any issues.

sudo tail -f /var/log/nginx/error.log

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,

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


  1. Go to Google Cloud Console.
  2. Navigate to APIs & ServicesOAuth consent screen.
  3. If you haven’t set it up, set the User Type to “External” (required for non-Google Workspace accounts).
  4. Fill in required fields:
    • App name (e.g., “TheHuntingGame”).
    • User support email.
    • Developer contact email.
  5. Scopes: Add https://mail.google.com/ (if missing).
  6. Test Users: If in “Testing” mode, add your email as a test user.
  7. Click Save and Continue.

✅ Step 2: Enable Gmail API

  1. Go to Gmail API.
  2. If not enabled, click Enable.

✅ Step 3: Verify OAuth Client ID and Secret

  1. Go to APIs & ServicesCredentials.

  2. 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 .env file.

✅ Step 4: Use OAuth Playground to Get Refresh Token

If you didn’t generate the refresh token correctly, redo these steps:

  1. Open OAuth 2.0 Playground.

  2. Click “OAuth 2.0 Configuration” (gear icon).

  3. Check “Use your own OAuth credentials”, enter:

    • Client ID (from Google Cloud).
    • Client Secret (from Google Cloud).
  4. In Step 1, add this scope:

    <https://mail.google.com/>
    
    
  5. Click “Authorize APIs” → Sign in with your Gmail account.

  6. In Step 2, click “Exchange authorization code for tokens”.

  7. Copy the Refresh Token (not the access token) and update your .env file:

    REFRESH_TOKEN=your-refresh-token
    

  1. 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)