fix(server): add root healthcheck endpoint for Railway deployment

- Add root '/' endpoint that responds with JSON status
- Make download routes handle missing installers gracefully
- Add error handling around download routes registration
- Add logging for download routes initialization

Fixes Railway healthcheck failures by ensuring server responds at root path
This commit is contained in:
MrPiglr 2026-02-12 12:55:59 -07:00
parent f099ffd8a6
commit 66ad61b8a0
2 changed files with 27 additions and 4 deletions

View file

@ -22,9 +22,11 @@ router.get('/desktop', async (req, res) => {
// Check if file exists
if (!fs.existsSync(installerPath)) {
console.log('[Download] Installer not found at', installerPath);
return res.status(404).json({
error: 'Installer not found',
message: 'The desktop installer has not been built yet. Please run: npm run build:tauri'
error: 'Installer not available',
message: 'The desktop installer is not yet available. It will be uploaded soon.',
note: 'For development: Run "npm run build:tauri" in shell/aethex-shell to build the installer'
});
}

View file

@ -25,6 +25,21 @@ app.get("/health", (_req, res) => {
res.json({ status: "healthy", timestamp: new Date().toISOString() });
});
// Root health check (Railway uses this)
app.get("/", (_req, res) => {
res.json({
status: "online",
service: "AeThex OS API",
version: "1.0.0",
timestamp: new Date().toISOString(),
endpoints: {
web: "Use client to access web interface",
api: "/api/*",
download: "/api/download/*"
}
});
});
// API status endpoint (moved from root to /api/status)
app.get("/api/status", (_req, res) => {
const isKernel = process.env.OPS_Version ? true : false;
@ -132,8 +147,14 @@ app.use((req, res, next) => {
(async () => {
// Register download routes
// Register download routes (wrapped in try-catch for safety)
try {
app.use('/api/download', downloadRoutes);
log("Download routes registered", "express");
} catch (error) {
log(`Warning: Failed to register download routes: ${error}`, "express");
// Continue anyway - app can work without download routes
}
// Register routes (org middleware applied selectively within routes.ts)
await registerRoutes(httpServer, app);