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 17:13:36 +00:00
|
|
|
const mcpProxy = require('./routes/mcp-proxy');
|
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', () => {
|
2026-03-12 17:13:36 +00:00
|
|
|
console.log(req.method + ' ' + req.path + ' ' + res.statusCode + ' ' + (Date.now() - start) + 'ms');
|
2026-03-12 16:44:37 +00:00
|
|
|
});
|
|
|
|
|
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
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2026-03-12 17:13:36 +00:00
|
|
|
app.use('/', mcpProxy);
|
|
|
|
|
|
2026-03-12 16:44:37 +00:00
|
|
|
module.exports = app;
|