drop/server/nuxt.config.ts
wdunn001 0348d10602 community: M4 -- game-server registry and issue reports
GameServer/GameServerStatusHistory/Issue/IssueComment models, a
strategy-per-probe_type ServerProbe (tcp_connect/http_get/presence_inferred,
mirroring script-library's game-server-registry-probe.py including the
integer ConnectTimeout fix), the bundled verified registry seed (WoW, EQEmu,
the Goldberg relay, Impostor, OpenDAoC), and full player+admin UI at
/community/servers and /community/issues. Featured flag pins the
persistent-world servers (WoW/EQEmu/OpenDAoC) to a compact status panel
surfaced on the community landing page. Scheduled sweep respects a
circuit-breaker backoff and never probes on page load; the relay is never
network-probed, only liveness-checked over ssh.
2026-08-03 03:19:54 -04:00

364 lines
9.6 KiB
TypeScript

import tailwindcss from "@tailwindcss/vite";
import { execSync } from "node:child_process";
import { readFileSync, existsSync } from "node:fs";
import path from "node:path";
import module from "node:module";
import { fileURLToPath } from "node:url";
import { type } from "arktype";
const packageJsonSchema = type({
name: "string",
version: "string",
});
const twemojiPackage = module.findPackageJSON(
"@discordapp/twemoji",
import.meta.url,
);
if (!twemojiPackage) {
throw new Error("Could not find @discordapp/twemoji package.");
}
const twemojiAssetsPath = path.join(
path.dirname(twemojiPackage),
"dist",
"svg",
);
// get drop version
const dropVersion = getDropVersion();
// get git ref or supply during build
const commitHash =
process.env.BUILD_GIT_REF ??
execSync("git rev-parse --short HEAD").toString().trim();
console.log(`Drop ${dropVersion} #${commitHash}`);
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
extends: ["../libraries/base"],
// Module config from here down
modules: [
"vue3-carousel-nuxt",
"nuxt-security", // "@nuxt/image",
"@nuxt/fonts",
"@nuxt/eslint",
"@nuxtjs/i18n",
"@vueuse/nuxt",
],
// Nuxt-only config
telemetry: false,
compatibilityDate: "2024-04-03",
devtools: {
enabled: true,
telemetry: false,
timeline: {
// this seems to be the tracking issue, composables not registered
// https://github.com/nuxt/devtools/issues/662
enabled: false,
},
},
css: ["~/assets/tailwindcss.css", "~/assets/core.scss"],
sourcemap: {
server: true,
client: true,
},
experimental: {
buildCache: true,
viewTransition: false,
appManifest: false,
componentIslands: true,
},
// future: {
// compatibilityVersion: 4,
// },
vite: {
plugins: [
// eslint-disable-next-line @typescript-eslint/no-explicit-any
tailwindcss() as any,
],
},
runtimeConfig: {
gitRef: commitHash,
dropVersion: dropVersion,
// /community's RomM adapter (server/internal/community/rommAdapter.ts)
// reads RomM's MariaDB directly through a dedicated read-only role
// (community_ro, GRANT SELECT ON romm.* only -- see
// homelab-compose/drop-stack's README for provisioning). Overridable via
// NUXT_ROMM_DB_HOST etc per Nuxt's runtimeConfig env convention; left
// empty by default so a deploy without RomM configured just skips the
// sync (see titleSyncService's early-return) instead of failing.
romm: {
dbHost: "",
dbPort: "3306",
dbUser: "",
dbPassword: "",
dbName: "romm",
publicUrl: "https://games.quasarke.net",
},
// /community's mods catalog (server/internal/community/modPipelineAdapter.ts)
// and achievement importer (server/internal/community/goldbergAdapter.ts)
// both read local, already-archived directory trees per the house
// offline rule (C1) -- never Steam, never a network fetch. Both mounts
// are read-only bind-mounts of /mnt/local24 subtrees (see
// homelab-compose/drop-stack/docker-compose.yml); left pointed at the
// container-internal paths those mounts land at by default, overridable
// via NUXT_COMMUNITY_MODS_ARCHIVE_ROOT / NUXT_COMMUNITY_GOLDBERG_SCHEMAS_ROOT
// per Nuxt's runtimeConfig env convention. A deploy without either mount
// present just finds nothing to import (see the sync services' early
// return on ENOENT) instead of failing.
community: {
modsArchiveRoot: "/mnt/game-mods",
goldbergSchemasRoot: "/mnt/goldberg-schemas",
},
public: {
// OpenPanel RUM (plugins/telemetry.client.ts). Empty by default so a
// deploy without telemetry configured just skips injecting it.
telemetry: {
clientId: "",
apiUrl: "",
},
},
},
app: {
head: {
link: [{ rel: "icon", href: "/favicon.ico" }],
},
},
routeRules: {
"/api/**": { cors: true },
// redirect old OIDC callback route
"/auth/callback/oidc": {
redirect: "/api/v1/auth/oidc/callback",
},
},
devServer: {
port: 4000,
},
nitro: {
minify: true,
compressPublicAssets: true,
experimental: {
websocket: true,
tasks: true,
openAPI: true,
},
openAPI: {
// tracking for dynamic openapi schema https://github.com/nitrojs/nitro/issues/2974
// create body from types: https://github.com/nitrojs/nitro/issues/3275
meta: {
title: "Drop",
description:
"Drop is an open-source, self-hosted game distribution platform, creating a Steam-like experience for DRM-free games.",
version: dropVersion,
},
},
scheduledTasks: {
"0 * * * *": ["dailyTasks"],
// Every 6h: RomM has ~34.5k titles, not worth resyncing hourly.
"17 */6 * * *": ["communityTitleSync"],
// Every minute: the sweep itself only actually probes a server once
// its own probeIntervalSec (default 60s, backed off up to 15min after
// 5 consecutive failures) has elapsed -- this cron is just how often
// we check "is anything due", not the probe cadence. Never probed on
// page load (see serverProbeService.ts).
"* * * * *": ["communityServerProbeSweep"],
},
storage: {
appCache: {
driver: "lru-cache",
},
},
devStorage: {
appCache: {
// store cache on fs to handle dev server restarts
driver: "fs",
base: "./.data/appCache",
},
},
serverAssets: [
{
baseName: "twemoji",
// get path to twemoji svg assets
dir: twemojiAssetsPath,
},
],
},
typescript: {
// vue-tsc's full-project typecheck is the single most memory-hungry step
// in `nuxt build` (observed >1GB RSS on a large multi-hundred-route
// project like this one). It's a correctness gate, not a build
// requirement -- Nitro/Vite bundle plain-JS output either way. Escape
// hatch for building on a memory-contended host (e.g. a shared box
// already near its limit): NUXT_BUILD_SKIP_TYPECHECK=true, wired to
// the Dockerfile's SKIP_TYPECHECK build arg. Defaults to on; only skip
// deliberately, and re-run `pnpm run typecheck` separately afterward on
// a host with headroom -- this is a resource-pressure escape hatch, not
// a reason to stop typechecking altogether.
typeCheck: process.env.NUXT_BUILD_SKIP_TYPECHECK !== "true",
tsConfig: {
compilerOptions: {
verbatimModuleSyntax: false,
strictNullChecks: true,
exactOptionalPropertyTypes: true,
},
},
},
carousel: {
prefix: "Vue",
},
i18n: {
bundle: {
optimizeTranslationDirective: false,
},
defaultLocale: "en-us",
lazy: true,
strategy: "no_prefix",
experimental: {
localeDetector: "localeDetector.ts",
autoImportTranslationFunctions: true,
},
detectBrowserLanguage: {
useCookie: true,
cookieKey: "drop_i18n_redirected",
fallbackLocale: "en-us",
},
locales: [
{ code: "en-us", language: "en-us", name: "English", file: "en_us.json" },
{
code: "en-gb",
language: "en-gb",
name: "English (UK)",
file: "en_gb.json",
},
{
code: "en-au",
language: "en-au",
name: "English (Australia)",
file: "en_au.json",
},
{
code: "en-pirate",
language: "en-pirate",
name: "English (Pirate)",
file: "en_pirate.json",
},
{
code: "fr",
language: "fr",
name: "French",
file: "fr.json",
},
{
code: "de",
language: "de",
name: "German",
file: "de.json",
},
{
code: "it",
language: "it",
name: "Italian",
file: "it.json",
},
{
code: "es",
language: "es",
name: "Spanish",
file: "es.json",
},
{
code: "zh",
language: "zh",
name: "Chinese",
file: "zh.json",
},
{
code: "zh-tw",
language: "zh-tw",
name: "Chinese (Taiwan)",
file: "zh_tw.json",
},
],
},
security: {
headers: {
contentSecurityPolicy: {
"upgrade-insecure-requests": false,
"img-src": [
"'self'",
"data:",
"https://www.giantbomb.com",
"https://images.pcgamingwiki.com",
"https://images.igdb.com",
"https://*.steamstatic.com",
],
},
strictTransportSecurity: false,
},
rateLimiter: false,
xssValidator: false,
requestSizeLimiter: false,
},
});
/**
* Gets the drop version from the environment variable or package.json
* @returns {string} The drop version
*/
function getDropVersion(): string {
// get drop version from environment variable
if (process.env.BUILD_DROP_VERSION) {
return process.env.BUILD_DROP_VERSION;
}
// example nightly: "v0.3.0-nightly.2025.05.28"
const defaultVersion = "v0.0.0-alpha.0";
const packageJsonPath = fileURLToPath(import.meta.resolve("./package.json"));
if (!existsSync(packageJsonPath)) {
console.error("Could not find package.json, using default version.");
return defaultVersion;
}
// parse package.json
const raw = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
const packageJson = packageJsonSchema(raw);
if (packageJson instanceof type.errors) {
console.error("Failed to parse package.json", packageJson.summary);
return defaultVersion;
}
// ensure version starts with 'v'
if (packageJson.version.startsWith("v")) {
return packageJson.version;
}
return `v${packageJson.version}`;
}