2026-03-12 16:44:37 +00:00
|
|
|
const express = require('express');
|
2026-03-12 16:46:30 +00:00
|
|
|
const registry = require('./backend-registry');
|
2026-03-12 16:44:37 +00:00
|
|
|
|
|
|
|
|
const app = express();
|
|
|
|
|
|
|
|
|
|
app.use(express.json());
|
|
|
|
|
|
|
|
|
|
app.use((req, res, next) => {
|
|
|
|
|
const start = Date.now();
|
|
|
|
|
res.on('finish', () => {
|
|
|
|
|
console.log(`${req.method} ${req.path} ${res.statusCode} ${Date.now() - start}ms`);
|
|
|
|
|
});
|
|
|
|
|
next();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
app.get('/health', (req, res) => {
|
|
|
|
|
res.json({
|
|
|
|
|
status: 'ok',
|
|
|
|
|
uptime: process.uptime(),
|
2026-03-12 16:46:30 +00:00
|
|
|
connectedBackends: registry.count(),
|
2026-03-12 16:44:37 +00:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
module.exports = app;
|