@@ -6,28 +6,6 @@ import type { AppConfig } from './types';
66const dataDir = process . env . DATA_DIR || path . join ( process . cwd ( ) , '..' , 'data' ) ;
77const configPath = path . join ( dataDir , 'config.json' ) ;
88
9- // ── Migration: move config from old locations into the unified data dir ──────
10- const OLD_CONFIG_PATHS = [
11- path . join ( process . cwd ( ) , 'data' , 'config.json' ) , // server/data/config.json
12- path . join ( process . cwd ( ) , '..' , 'config.json' ) , // <root>/config.json
13- ] ;
14-
15- function migrateConfig ( ) : void {
16- if ( fs . existsSync ( configPath ) ) return ; // already in the right place
17- fs . mkdirSync ( dataDir , { recursive : true } ) ;
18-
19- for ( const oldPath of OLD_CONFIG_PATHS ) {
20- if ( fs . existsSync ( oldPath ) ) {
21- fs . copyFileSync ( oldPath , configPath ) ;
22- fs . unlinkSync ( oldPath ) ;
23- console . log ( `[migrate] Moved config from ${ oldPath } → ${ configPath } ` ) ;
24- return ;
25- }
26- }
27- }
28-
29- migrateConfig ( ) ;
30-
319// Defaults ensure any field added to the codebase after a deployment
3210// still has a sane value even if the persisted config.json pre-dates it.
3311const DEFAULTS : AppConfig = {
@@ -55,23 +33,9 @@ export function loadConfig(): AppConfig {
5533 }
5634
5735 const raw = fs . readFileSync ( configPath , 'utf-8' ) ;
58- const saved = JSON . parse ( raw ) as Record < string , unknown > ;
59-
60- // Strip legacy credential fields — auth now lives in the database
61- let dirty = false ;
62- for ( const key of [ 'adminUsername' , 'adminPassword' , 'lobbyTimeoutMin' ] ) {
63- if ( key in saved ) {
64- delete saved [ key ] ;
65- dirty = true ;
66- }
67- }
68- if ( dirty ) {
69- fs . writeFileSync ( configPath , JSON . stringify ( saved , null , 2 ) , 'utf-8' ) ;
70- console . log ( '[migrate] Removed legacy credential fields from config.json' ) ;
71- }
72-
36+ const saved = JSON . parse ( raw ) as Partial < AppConfig > ;
7337 // Merge: saved values win; any key missing from the file falls back to DEFAULTS
74- const cfg = { ...DEFAULTS , ...( saved as Partial < AppConfig > ) } ;
38+ const cfg = { ...DEFAULTS , ...saved } ;
7539 // Env vars always win over file — useful for Docker deployments
7640 if ( process . env . JWT_SECRET ) cfg . jwtSecret = process . env . JWT_SECRET ;
7741 return cfg ;
0 commit comments