feat(server): healthz, testable app, local dev script (P0-3)

This commit is contained in:
Benjamin Oezcan
2026-11-19 01:40:31 +01:00
parent 35348324d6
commit fa68ef620d
8 changed files with 1465 additions and 16 deletions

View File

@@ -6,7 +6,11 @@ const bcrypt = require('bcryptjs');
const jwt = require('jsonwebtoken');
const { Users, Wallet, Tokens } = require('./db');
const SECRET = process.env.JWT_SECRET || 'dev-insecure-change-me';
// No secret configured -> random per process (tokens die on restart). Never fall back to a known string.
const SECRET = process.env.JWT_SECRET || (() => {
if (process.env.NODE_ENV !== 'test') console.warn('[auth] JWT_SECRET not set - using a random secret, sessions end on restart');
return crypto.randomBytes(32).toString('hex');
})();
const ACCESS_TTL = 3600; // seconds
const REFRESH_TTL = 30 * 864e5; // 30 days (ms)
const START_MONEY = 800;