Files
ProjectE/apps/api/src/index.ts
T
Hermes e4a241b38f T2/Phase 2A: port auth + infrastructure routes to Hono (~8 routes)
- /api/health: DB ping + version + uptime
   - /api/auth/*: NextAuth -> Auth.js standalone (credentials + passkey)
   - /api/domains: full CRUD
   - /api/realtime: SSE with PostgreSQL LISTEN/NOTIFY
   - /mcp: JSON-RPC 2.0 (initialize, tools/list, tools/call, resources/*)

   Parent: t_e1cbd87d -> t_d8654a91 (T1)
2026-08-01 01:25:01 +00:00

38 lines
1017 B
TypeScript

import { Hono } from "hono";
import { cors } from "hono/cors";
import { logger } from "hono/logger";
import { authMiddleware } from "./middleware/auth";
import { authRoutes } from "./routes/auth";
import { mcpRoutes } from "./routes/mcp";
import { realtimeRoutes } from "./routes/realtime";
import { domainRoutes } from "./routes/domains";
import { healthHandler } from "./routes/health";
const app = new Hono();
// Middleware
app.use("*", cors({ origin: "http://localhost:3000", credentials: true }));
app.use("*", logger());
app.use("*", authMiddleware);
// Health check — expanded with DB ping
app.get("/api/health", async (c) => {
const result = await healthHandler();
return c.json(result);
});
// Routes
app.route("/api/auth", authRoutes);
app.route("/api/domains", domainRoutes);
app.route("/api", realtimeRoutes);
app.route("/mcp", mcpRoutes);
const port = parseInt(process.env.PORT || "3001", 10);
export default {
port,
fetch: app.fetch,
};
console.log(`API server listening on :${port}`);