mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-11 17:27:31 +02:00
Correct the webhook URL for BAP configuration in multiple files (client, server, migrations). Adjust server startup logic to prevent crashes due to database migration failures in production, and add more verbose logging for environment and database connection status. Reorder integrations in `.replit` file. Replit-Commit-Author: Agent Replit-Commit-Session-Id: cfbfe47c-0c9a-4ebf-8a41-2937407eccff Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/cfbfe47c-0c9a-4ebf-8a41-2937407eccff/qkkp1hi
63 lines
2.1 KiB
TypeScript
63 lines
2.1 KiB
TypeScript
import express, { type Request, Response, NextFunction } from "express";
|
|
import { registerRoutes } from "./routes.js";
|
|
import { setupVite, serveStatic } from "./vite.js";
|
|
|
|
// Run database migrations first - FORCER EN PRODUCTION
|
|
console.log('🔄 [STARTUP] Running database migrations...');
|
|
console.log('🔍 [STARTUP] Environment:', process.env.NODE_ENV);
|
|
console.log('🔍 [STARTUP] Has DATABASE_URL:', !!process.env.DATABASE_URL);
|
|
|
|
try {
|
|
const { runMigrations } = await import('./migrations.js');
|
|
await runMigrations();
|
|
console.log('✅ [STARTUP] Database migrations completed');
|
|
} catch (error) {
|
|
console.error('❌ [STARTUP] Database migrations failed:', error);
|
|
console.error('❌ [STARTUP] Error details:', JSON.stringify(error, null, 2));
|
|
// NE PAS arrêter l'app pour éviter les boucles de redémarrage
|
|
console.warn('⚠️ [STARTUP] Continuing without migrations to avoid restart loop');
|
|
}
|
|
|
|
// Initialize weather system
|
|
console.log('🌤️ [STARTUP] Initializing weather system...');
|
|
const { initializeWeatherConfig } = await import('./weatherAutoConfig.js');
|
|
await initializeWeatherConfig();
|
|
console.log('✅ [STARTUP] Weather system initialized');
|
|
|
|
const app = express();
|
|
|
|
app.use(express.json({ limit: '10mb' }));
|
|
app.use(express.urlencoded({ extended: false, limit: '10mb' }));
|
|
|
|
app.use((req, res, next) => {
|
|
const start = Date.now();
|
|
res.on("finish", () => {
|
|
const duration = Date.now() - start;
|
|
if (req.path.startsWith("/api")) {
|
|
console.log(`${req.method} ${req.path} ${res.statusCode} in ${duration}ms`);
|
|
}
|
|
});
|
|
next();
|
|
});
|
|
|
|
const server = await registerRoutes(app);
|
|
|
|
app.use((err: any, _req: Request, res: Response, _next: NextFunction) => {
|
|
const status = err.status || err.statusCode || 500;
|
|
const message = err.message || "Internal Server Error";
|
|
res.status(status).json({ message });
|
|
throw err;
|
|
});
|
|
|
|
// Setup Vite in development
|
|
if (app.get("env") === "development") {
|
|
await setupVite(app, server);
|
|
} else {
|
|
serveStatic(app);
|
|
}
|
|
|
|
const port = 5000;
|
|
server.listen(port, "0.0.0.0", () => {
|
|
console.log(`serving on port ${port}`);
|
|
});
|