mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-12 01:37:40 +02:00
Remove direct weather data access for all users and enforce administrator-only viewing of weather information by implementing role-based access control on the API endpoint. Refactor weather system initialization to use a new auto-configuration module that fetches API keys from environment variables. Replit-Commit-Author: Agent Replit-Commit-Session-Id: d43bd811-9372-45a7-8ac9-4a954c0538e1 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/d43bd811-9372-45a7-8ac9-4a954c0538e1/cp1Ryg6
47 lines
1.3 KiB
TypeScript
47 lines
1.3 KiB
TypeScript
import express, { type Request, Response, NextFunction } from "express";
|
|
import { registerRoutes } from "./routes.js";
|
|
import { setupVite, serveStatic } from "./vite.js";
|
|
|
|
// 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}`);
|
|
});
|