2026-08-05 13:14:03 +00:00
|
|
|
import { z } from 'zod';
|
|
|
|
|
|
|
|
|
|
const envSchema = z.object({
|
|
|
|
|
PORT: z.coerce.number().default(8096),
|
|
|
|
|
HOST: z.string().default('0.0.0.0'),
|
|
|
|
|
DATA_DIR: z.string().default('./data'),
|
|
|
|
|
STATIC_DIR: z.string().optional(),
|
|
|
|
|
PUBLIC_URL: z.string().url().default('http://localhost:8096'),
|
2026-08-05 14:58:43 +00:00
|
|
|
// Set when this instance is deployed under a path prefix on a shared domain
|
|
|
|
|
// (e.g. "/regress" on podsteadr.atobitcoin.io/regress/) rather than at
|
|
|
|
|
// root. Must match nginx's location block, which must NOT strip the
|
|
|
|
|
// prefix — the NIP-98 `u` tag the frontend signs includes it, so the
|
|
|
|
|
// backend needs to see (and route) the same full path. Leave unset ("") to
|
|
|
|
|
// deploy at root, e.g. its own dedicated host/port.
|
|
|
|
|
ROUTE_PREFIX: z.string().default(''),
|
2026-08-05 13:14:03 +00:00
|
|
|
NIP98_MAX_SKEW_SECS: z.coerce.number().default(60),
|
|
|
|
|
SESSION_TTL_DAYS: z.coerce.number().default(30),
|
|
|
|
|
// Default sync area: Madeira, Portugal (Funchal-centered radius covering the whole island).
|
|
|
|
|
BTCMAP_CENTER_LAT: z.coerce.number().default(32.7607),
|
|
|
|
|
BTCMAP_CENTER_LON: z.coerce.number().default(-16.9595),
|
|
|
|
|
BTCMAP_RADIUS_KM: z.coerce.number().default(45),
|
|
|
|
|
// How close (in meters) a player must be to a place to claim it or link from it.
|
|
|
|
|
CLAIM_RADIUS_METERS: z.coerce.number().default(40),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export type Config = z.infer<typeof envSchema>;
|
|
|
|
|
|
|
|
|
|
export function loadConfig(env: NodeJS.ProcessEnv = process.env): Config {
|
|
|
|
|
return envSchema.parse(env);
|
|
|
|
|
}
|