Skip to content

hardytool/server

Repository files navigation

Server

Depfu CI status Checks status Uptime Robot status

RD2L's backend and website — a Node.js + TypeScript server built with Express.js, Pug templates, and PostgreSQL.

Installation

Install dependencies:

npm ci

Environment

Create a .env file with the following variables:

# Required
STEAM_API_KEY='get from https://steamcommunity.com/dev/apikey'
SECRET='random characters'

# Database (individual connection parameters)
POSTGRES_USER='postgres'
POSTGRES_PASSWORD='postgres'
POSTGRES_DB='seal'
POSTGRES_HOST='localhost'
POSTGRES_PORT='5432'

# Server
PORT='80'
HTTPS_PORT='443'
HOST='localhost'

Optional variables:

# Forward auth return requests to a different URL
WEBSITE_URL='http://return-to-website.com'

# Database connection tuning
POSTGRES_POOL_MAX='10'
POSTGRES_TIMEOUT='30000'
POSTGRES_SSL='true'

Note: Do not access process.env directly in source files — it is forbidden by ESLint. Read env vars in src/config.ts and import from there.

Running

Build the TypeScript source, then start the server:

npm run build
npm start

To run with Docker Compose (automatically handles migrations and seeds):

npm run docker:build
npm run docker:run

npm run docker:run requires STEAM_API_KEY and SECRET to be set. Docker Compose reads .env automatically, so you can use the same file for both local and Compose workflows.

Database migrations

Migrations are SQL files in src/migrations/ and run in filename order (e.g. 001.sql before 002.sql). They are applied automatically on startup when running via Docker Compose.

To run migrations manually (after building):

npm run migrate

Seed data

Seed data populates the database with sample content for local development and testing. It includes seasons, divisions, teams, and users. Seeding is idempotent — running it multiple times is safe and will not create duplicates.

When using Docker Compose, seeds are applied automatically after migrations on every docker compose up.

To run seeds manually (after building):

npm run seed

Project structure

src/
  api/           # JSON API controllers
  assets/        # Static files (images, markdown, JSON)
  lib/           # Shared utilities
  migrations/    # SQL migration files applied in order
  pages/         # Page controllers (HTML endpoints)
  repos/         # Database access layer
  templates/     # Pug templates
  types/         # TypeScript type definitions
  config.ts      # Environment variable configuration
  migrate-cli.ts # CLI entry point for migrations
  seed-cli.ts    # CLI entry point for seeding
  seed-data.ts   # Seed data definitions
  server.ts      # Application entry point
scripts/         # Node.js helper scripts for npm run commands
Dockerfile
docker-compose.yml  # Development-oriented quickstart compose file
package.json
package-lock.json

Contributing

See CONTRIBUTING.md for code style, commit conventions, and how to add database migrations.

About

Express-based website for RD2L

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 14

Languages