frontend_nyla/scripts/deploy-server.js
2025-09-10 13:04:16 +02:00

30 lines
No EOL
1.1 KiB
JavaScript

import express from 'express';
import path from 'path';
import { fileURLToPath } from 'url';
import { getAppName, getAppVersion, getAppEnvironment, isDebugMode } from '../config/serverConfig.js';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const app = express();
// Serve static files from current directory
app.use(express.static(path.join(__dirname)));
// Handle React Router - send all requests to index.html
app.get('/*', function(req, res) {
res.sendFile(path.join(__dirname, 'index.html'));
});
// Use Azure's PORT environment variable or fallback to 8080
const port = process.env.PORT || 8080;
// Listen on all interfaces (important for Azure)
app.listen(port, '0.0.0.0', () => {
console.log(`🚀 ${getAppName()} Deploy Server running on port ${port}`);
console.log(`📦 Version: ${getAppVersion()}`);
console.log(`🌍 Environment: ${getAppEnvironment()}`);
console.log(`🐛 Debug Mode: ${isDebugMode() ? 'Enabled' : 'Disabled'}`);
console.log(`📁 Serving from: ${__dirname}`);
console.log(`🔧 Node Environment: ${process.env.NODE_ENV || 'development'}`);
});