import Fastify from "fastify"; import cors from "@fastify/cors"; import helmet from "@fastify/helmet"; import rateLimit from "@fastify/rate-limit"; import sensible from "@fastify/sensible"; import { config } from "./config.js"; import { healthRoutes } from "./routes/health.js"; import { toolRoutes } from "./routes/tools.js"; import { runRoutes } from "./routes/runs.js"; import { chatRoutes } from "./routes/chat.js"; import { projectRoutes } from "./routes/projects.js"; const app = Fastify({ logger: true }); await app.register(cors, { origin: true }); await app.register(helmet); await app.register(sensible); await app.register(rateLimit, { max: 300, timeWindow: "1 minute" }); await app.register(healthRoutes); await app.register(toolRoutes); await app.register(runRoutes); await app.register(chatRoutes); await app.register(projectRoutes); app.listen({ port: config.port, host: "0.0.0.0" }).then(() => { console.log(`🚀 Control Plane API running on http://localhost:${config.port}`); }).catch((err) => { app.log.error(err); process.exit(1); });