Refactor code structure for improved readability and maintainability

This commit is contained in:
2025-12-21 00:08:25 +01:00
parent 89ef1d6e8b
commit 16cba64d03
3 changed files with 1099 additions and 31 deletions

View File

@@ -10,7 +10,7 @@
},
"dependencies": {
"cors": "^2.8.5",
"dotenv": "^16.4.5",
"dotenv": "^16.6.1",
"express": "^4.19.2",
"helmet": "^7.1.0",
"jsonwebtoken": "^9.0.2",

1096
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,4 @@
import dotenv from 'dotenv';
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
import express from 'express';
import http from 'http';
import cors from 'cors';
@@ -13,33 +10,8 @@ import lobbyRoutes from './routes/lobby.js';
import walletRoutes from './routes/wallet.js';
import pool from './db.js';
import { setupWebSocket } from './ws.js';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const envCandidates = [
path.join(process.cwd(), '.env'),
path.join(__dirname, '..', '.env'),
path.join(__dirname, '..', '..', '.env')
];
let envLoaded = false;
for (const candidate of envCandidates) {
if (fs.existsSync(candidate)) {
dotenv.config({ path: candidate });
envLoaded = true;
break;
}
}
if (!envLoaded) {
// eslint-disable-next-line no-console
console.warn('Figyelem: .env fajl nem talalhato, ENV valtozok nelkul indul.');
}
if (!process.env.DB_HOST) {
// eslint-disable-next-line no-console
console.error('Hiba: DB_HOST nincs beallitva. Ellenorizd az .env fajlt vagy az ENV valtozokat.');
process.exit(1);
}
import dotenv from 'dotenv';
dotenv.config();
const app = express();