managarten/services/mana-geocoding/src/app.ts
Till JS c47ce83e83 fix(geocoding): proxy Pelias health through wrapper for monitoring
blackbox-exporter can't resolve host.docker.internal on Colima, so
probes of host.docker.internal:4000 and :9200 always fail. Instead,
add a /health/pelias endpoint on the Hono wrapper that proxies to
the Pelias API, and update prometheus.yml to probe the wrapper's
proxied health endpoint.

Also simplifies the status page friendly_name() now that we don't
need to display the host.docker.internal targets.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 16:45:43 +02:00

32 lines
753 B
TypeScript

/**
* App factory — separated from index.ts so tests can import without
* triggering the production bootstrap.
*/
import { Hono } from 'hono';
import { cors } from 'hono/cors';
import type { Config } from './config';
import { createHealthRoutes } from './routes/health';
import { createGeocodeRoutes } from './routes/geocode';
export function createApp(config: Config): Hono {
const app = new Hono();
app.onError((err, c) => {
console.error('Unhandled error:', err);
return c.json({ error: 'internal_error' }, 500);
});
app.use(
'*',
cors({
origin: config.cors.origins,
credentials: true,
})
);
app.route('/health', createHealthRoutes(config));
app.route('/api/v1/geocode', createGeocodeRoutes(config));
return app;
}