Skip to content

Commit 96002b6

Browse files
committed
fix feedbacks of the team
1 parent f49e8bd commit 96002b6

4 files changed

Lines changed: 20 additions & 86 deletions

File tree

data/config.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"port": 3000,
3-
"appName": "Scaleway",
4-
"appSubtitle": "hellllllooooooo",
3+
"appName": "",
4+
"appSubtitle": "",
55
"jwtSecret": "change-this-secret-in-production",
66
"questionTimeSec": 20,
7-
"defaultBaseScore": 300,
7+
"defaultBaseScore": 500,
88
"speedBonusMax": 200,
99
"speedBonusMin": 10,
1010
"maxPlayersPerSession": 50,

docker-compose.yml

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,22 @@ services:
1111
- JWT_SECRET=${JWT_SECRET:-change-this-secret-in-production}
1212
volumes:
1313
- ./data:/data
14-
# Avatars live on the host — drop image files here and they appear in the picker
15-
- ./avatars:/data/avatars
1614

17-
caddy:
18-
image: caddy:latest
19-
restart: unless-stopped
20-
depends_on:
21-
- app
22-
ports:
23-
- "80:80"
24-
- "443:443"
25-
environment:
26-
- DOMAIN=${DOMAIN:-}
27-
volumes:
28-
- ./Caddyfile:/etc/caddy/Caddyfile
29-
- ./site:/srv
30-
- caddy_data:/data
31-
- caddy_config:/config
15+
# caddy:
16+
# image: caddy:latest
17+
# restart: unless-stopped
18+
# depends_on:
19+
# - app
20+
# ports:
21+
# - "80:80"
22+
# - "443:443"
23+
# environment:
24+
# - DOMAIN=${DOMAIN:-}
25+
# volumes:
26+
# - ./Caddyfile:/etc/caddy/Caddyfile
27+
# - ./site:/srv
28+
# - caddy_data:/data
29+
# - caddy_config:/config
3230

3331
volumes:
3432
caddy_data:

server/src/config.ts

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,6 @@ import type { AppConfig } from './types';
66
const dataDir = process.env.DATA_DIR || path.join(process.cwd(), '..', 'data');
77
const 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.
3311
const 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;

server/src/db.ts

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,34 +7,6 @@ import sqlite3 from 'sqlite3';
77
const dataDir = process.env.DATA_DIR || path.join(process.cwd(), '..', 'data');
88
const DB_PATH = path.join(dataDir, 'quizz.db');
99

10-
// ── Migration: move DB from old locations into the unified data dir ──────────
11-
const OLD_DB_PATHS = [
12-
path.join(process.cwd(), '..', 'quizz.db'), // <root>/quizz.db
13-
];
14-
15-
function migrateDb(): void {
16-
if (fs.existsSync(DB_PATH)) return; // already in the right place
17-
fs.mkdirSync(dataDir, { recursive: true });
18-
19-
for (const oldPath of OLD_DB_PATHS) {
20-
if (fs.existsSync(oldPath)) {
21-
// Move the main DB file + WAL/SHM sidecar files
22-
for (const suffix of ['', '-wal', '-shm']) {
23-
const src = oldPath + suffix;
24-
const dst = DB_PATH + suffix;
25-
if (fs.existsSync(src)) {
26-
fs.copyFileSync(src, dst);
27-
fs.unlinkSync(src);
28-
}
29-
}
30-
console.log(`[migrate] Moved database from ${oldPath}${DB_PATH}`);
31-
return;
32-
}
33-
}
34-
}
35-
36-
migrateDb();
37-
3810
export let db: Database;
3911

4012
export async function initDb(): Promise<void> {

0 commit comments

Comments
 (0)