2026-08-01 01:15:31 +00:00
|
|
|
import { Hono } from "hono";
|
|
|
|
|
import { cors } from "hono/cors";
|
|
|
|
|
import { logger } from "hono/logger";
|
2026-08-01 01:25:01 +00:00
|
|
|
import { authMiddleware } from "./middleware/auth";
|
2026-08-01 01:15:31 +00:00
|
|
|
import { authRoutes } from "./routes/auth";
|
|
|
|
|
import { mcpRoutes } from "./routes/mcp";
|
|
|
|
|
import { realtimeRoutes } from "./routes/realtime";
|
2026-08-01 01:25:01 +00:00
|
|
|
import { domainRoutes } from "./routes/domains";
|
2026-08-01 01:38:25 +00:00
|
|
|
import { taskRoutes } from "./routes/tasks";
|
|
|
|
|
import { habitRoutes } from "./routes/habits";
|
|
|
|
|
import { projectRoutes } from "./routes/projects";
|
|
|
|
|
import { noteRoutes } from "./routes/notes";
|
2026-08-01 01:47:25 +00:00
|
|
|
import { searchRoutes } from "./routes/search";
|
|
|
|
|
import { calendarRoutes } from "./routes/calendar";
|
|
|
|
|
import { graphRoutes } from "./routes/graph";
|
|
|
|
|
import { dashboardRoutes } from "./routes/dashboard";
|
|
|
|
|
import { agentRoutes } from "./routes/agents";
|
|
|
|
|
import { webhookRoutes } from "./routes/webhooks";
|
|
|
|
|
import { canvasRoutes } from "./routes/canvas";
|
|
|
|
|
import { dailyNoteRoutes } from "./routes/daily-notes";
|
|
|
|
|
import { tagRoutes } from "./routes/tags";
|
|
|
|
|
import { customFieldRoutes } from "./routes/custom-fields";
|
|
|
|
|
import { errorLogRoutes } from "./routes/error-log";
|
|
|
|
|
import { analyticsRoutes } from "./routes/analytics";
|
|
|
|
|
import { importExportRoutes } from "./routes/import-export";
|
2026-08-10 08:53:18 +00:00
|
|
|
import { notificationRoutes } from "./routes/notifications";
|
2026-08-01 01:25:01 +00:00
|
|
|
import { healthHandler } from "./routes/health";
|
2026-08-01 01:15:31 +00:00
|
|
|
|
|
|
|
|
const app = new Hono();
|
|
|
|
|
|
|
|
|
|
// Middleware
|
|
|
|
|
app.use("*", cors({ origin: "http://localhost:3000", credentials: true }));
|
|
|
|
|
app.use("*", logger());
|
2026-08-01 01:25:01 +00:00
|
|
|
app.use("*", authMiddleware);
|
2026-08-01 01:15:31 +00:00
|
|
|
|
2026-08-01 01:25:01 +00:00
|
|
|
// Health check — expanded with DB ping
|
|
|
|
|
app.get("/api/health", async (c) => {
|
|
|
|
|
const result = await healthHandler();
|
|
|
|
|
return c.json(result);
|
2026-08-01 01:15:31 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Routes
|
|
|
|
|
app.route("/api/auth", authRoutes);
|
2026-08-01 01:25:01 +00:00
|
|
|
app.route("/api/domains", domainRoutes);
|
2026-08-01 01:38:25 +00:00
|
|
|
app.route("/api/tasks", taskRoutes);
|
|
|
|
|
app.route("/api/habits", habitRoutes);
|
|
|
|
|
app.route("/api/projects", projectRoutes);
|
|
|
|
|
app.route("/api/notes", noteRoutes);
|
2026-08-01 01:47:25 +00:00
|
|
|
app.route("/api/search", searchRoutes);
|
|
|
|
|
app.route("/api/calendar", calendarRoutes);
|
|
|
|
|
app.route("/api/graph", graphRoutes);
|
|
|
|
|
app.route("/api/dashboard", dashboardRoutes);
|
|
|
|
|
app.route("/api/agents", agentRoutes);
|
|
|
|
|
app.route("/api/webhooks", webhookRoutes);
|
|
|
|
|
app.route("/api/canvas", canvasRoutes);
|
|
|
|
|
app.route("/api/daily-notes", dailyNoteRoutes);
|
|
|
|
|
app.route("/api/tags", tagRoutes);
|
|
|
|
|
app.route("/api/custom-fields", customFieldRoutes);
|
|
|
|
|
app.route("/api/error-log", errorLogRoutes);
|
|
|
|
|
app.route("/api/analytics", analyticsRoutes);
|
2026-08-10 08:53:18 +00:00
|
|
|
app.route("/api/notifications", notificationRoutes);
|
2026-08-01 01:47:25 +00:00
|
|
|
app.route("/api", importExportRoutes);
|
2026-08-01 01:15:31 +00:00
|
|
|
app.route("/api", realtimeRoutes);
|
2026-08-01 11:33:12 +00:00
|
|
|
app.route("/api/mcp", mcpRoutes);
|
2026-08-01 01:15:31 +00:00
|
|
|
|
|
|
|
|
const port = parseInt(process.env.PORT || "3001", 10);
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
port,
|
|
|
|
|
fetch: app.fetch,
|
|
|
|
|
};
|
|
|
|
|
|
2026-08-01 01:47:25 +00:00
|
|
|
console.log("API server listening on :" + port);
|