Initial PlayBull release with Trilogy Hub integration.
Includes homelab deploy tooling, image position/zoom manifest persistence, and full trading/casino stack. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
40
server/config.js
Normal file
40
server/config.js
Normal file
@@ -0,0 +1,40 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const ROOT = path.resolve(__dirname, '..');
|
||||
|
||||
// Minimaler .env Parser (keine externe Abhaengigkeit noetig)
|
||||
function loadEnv() {
|
||||
const file = path.join(ROOT, '.env');
|
||||
if (!fs.existsSync(file)) return;
|
||||
const txt = fs.readFileSync(file, 'utf8');
|
||||
for (const line of txt.split(/\r?\n/)) {
|
||||
const trimmed = line.trim();
|
||||
if (!trimmed || trimmed.startsWith('#')) continue;
|
||||
const idx = trimmed.indexOf('=');
|
||||
if (idx === -1) continue;
|
||||
const key = trimmed.slice(0, idx).trim();
|
||||
const val = trimmed.slice(idx + 1).trim();
|
||||
if (!(key in process.env)) process.env[key] = val;
|
||||
}
|
||||
}
|
||||
|
||||
loadEnv();
|
||||
|
||||
export const config = {
|
||||
ROOT,
|
||||
PORT: Number(process.env.PORT || 3000),
|
||||
JWT_SECRET: process.env.JWT_SECRET || 'dev-secret-change-me',
|
||||
FINNHUB_API_KEY: process.env.FINNHUB_API_KEY || '',
|
||||
START_BALANCE: Number(process.env.START_BALANCE || 10000),
|
||||
DATA_DIR: path.join(ROOT, 'data'),
|
||||
PUBLIC_DIR: path.join(ROOT, 'public'),
|
||||
UPLOADS_DIR: path.join(ROOT, 'data', 'uploads', 'avatars'),
|
||||
FILES_DIR: path.join(ROOT, 'data', 'uploads', 'files'),
|
||||
};
|
||||
|
||||
if (!fs.existsSync(config.DATA_DIR)) fs.mkdirSync(config.DATA_DIR, { recursive: true });
|
||||
if (!fs.existsSync(config.UPLOADS_DIR)) fs.mkdirSync(config.UPLOADS_DIR, { recursive: true });
|
||||
if (!fs.existsSync(config.FILES_DIR)) fs.mkdirSync(config.FILES_DIR, { recursive: true });
|
||||
Reference in New Issue
Block a user