Skip to content

EuphoriaTheme/backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ED-API

Backend API for license verification, game server querying, translations, products, contributors, donators, and stats.

Runtime

This branch runs on Fastify.

Scripts

  • npm run dev - Start Fastify in watch mode
  • npm run build - Build placeholder (no compile step required)
  • npm run start - Start Fastify server
  • npm run update:games - Update game definitions
  • npm run fetch:gameicons - Fetch game icons
  • npm run sync:translations - Sync translation files now
  • npm run sync:blueprint - Sync blueprint extensions now

Setup

  1. Install dependencies:
npm install
  1. Configure .env with required credentials and optional sync settings.

  2. Start development server:

npm run dev
  1. Start production runtime:
npm run start

Reverse Proxy Setup (Cloudflare + Nginx)

For a Cloudflare -> Nginx -> API chain, set these values in .env:

PROXY_MODE=cloudflare
TRUST_PROXY=true
TRUST_PROXY_HOPS=1
HOST=0.0.0.0
PORT=3000

Use this Nginx location block so client IP forwarding works correctly:

location / {
	proxy_pass http://127.0.0.1:3000;

	proxy_http_version 1.1;
	proxy_set_header Host $host;

	# Proxy chain headers
	proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
	proxy_set_header X-Forwarded-Proto $scheme;
	proxy_set_header X-Forwarded-Host $host;
	proxy_set_header X-Real-IP $remote_addr;

	# Cloudflare origin client IP headers
	proxy_set_header CF-Connecting-IP $http_cf_connecting_ip;
	proxy_set_header True-Client-IP $http_true_client_ip;
}

Notes:

  • Keep Cloudflare proxy enabled for the public DNS record.
  • Restrict origin traffic so only Cloudflare can reach Nginx.
  • Keep TRUST_PROXY_HOPS=1 when Nginx is the direct upstream for the API.

Blueprint Sync

public/blueprint.json is synced at startup and every 24 hours.

Optional .env settings:

BLUEPRINT_EXTENSIONS_URL=https://api.blueprintframe.work/api/extensions
BLUEPRINT_EXTENSIONS_FALLBACK_URL=https://blueprint.zip/api/extensions
BLUEPRINT_SYNC_COOKIE=
BLUEPRINT_SYNC_USER_AGENT=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36
BLUEPRINT_SYNC_ORIGIN=https://blueprintframe.work
BLUEPRINT_SYNC_REFERER=https://blueprintframe.work/
BLUEPRINT_SYNC_INTERVAL_MS=86400000
BLUEPRINT_SYNC_TIMEOUT_MS=20000

Translation Sync

Translations under public/translations are synced at startup and every 24 hours.

Optional .env settings:

TRANSLATIONS_REPO_OWNER=EuphoriaTheme
TRANSLATIONS_REPO_NAME=blueprint-translations
TRANSLATIONS_REPO_REF=main
TRANSLATIONS_SYNC_INTERVAL_MS=86400000
TRANSLATIONS_SYNC_TIMEOUT_MS=20000
TRANSLATIONS_SYNC_GITHUB_TOKEN=

Main Endpoints

  • GET /
  • GET /health
  • GET /openapi.json
  • GET /docs
  • GET /public/*
  • GET /stats
  • GET /products
  • GET /donators
  • GET /contributors
  • GET /translations
  • POST /translations/translate/bulk
  • GET /gameapi
  • GET /gameapi/:game/ip=:ip&port=:port
  • POST /license/verify-license
  • POST /license/v2/verify-license
  • GET /versions
  • GET /rcon/health
  • POST /rcon/variables
  • POST /rcon/players

API Docs (Scalar)

This API now exposes generated OpenAPI docs for public consumers:

  • OpenAPI JSON: GET /openapi.json
  • Scalar UI: GET /docs

Optional .env settings:

API_DOCS_ENABLED=true
API_DOCS_PATH=/docs
OPENAPI_JSON_PATH=/openapi.json
API_TITLE=ED API
API_DESCRIPTION=Public API for licensing, game server querying, translations, metadata, and RCON utilities.
API_VERSION=1.0.0
API_CONTACT_EMAIL=support@euphoriadevelopment.uk

Rate Limiting (Recommended For Public APIs)

Global request throttling is enabled by default.

Optional .env settings:

RATE_LIMIT_ENABLED=true
RATE_LIMIT_MAX=120
RATE_LIMIT_TIME_WINDOW=1 minute
RATE_LIMIT_ALLOW_LIST=

RATE_LIMIT_ALLOW_LIST accepts a comma-separated list of client IPs to bypass limits.

License API Configuration

Optional .env overrides:

LICENSE_API_V1_URL=https://license.euphoriadevelopment.uk/api/v1/validate
LICENSE_API_V2_URL=https://licensing.euphoriadevelopment.uk/api/licenses/validate
LICENSE_API_V2_TOKEN=optional-bearer-token-for-v2

POST /license/v2/verify-license body example:

{
	"productId": "my-product-id",
	"licenseKey": "ABCD-EFGH-IJKL-MNOP",
	"hwid": "pc-main-rig-01",
	"ip": "203.0.113.10"
}

About

Backend API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors