()
| 111 | }); |
| 112 | |
| 113 | export function buildHttpServer() { |
| 114 | const app = Fastify({ |
| 115 | logger: { |
| 116 | level: config.LOG_LEVEL, |
| 117 | base: { |
| 118 | service: "sag" |
| 119 | } |
| 120 | } |
| 121 | }); |
| 122 | |
| 123 | app.get("/health", async () => ({ |
| 124 | ok: true, |
| 125 | service: "sag" |
| 126 | })); |
| 127 | |
| 128 | app.get("/api/model-call-logs", async (request) => { |
| 129 | const query = request.query as { after?: string }; |
| 130 | const after = query.after ? Number(query.after) : 0; |
| 131 | return listModelCallLogs(Number.isFinite(after) ? after : 0); |
| 132 | }); |
| 133 | |
| 134 | app.get("/sources", async (request) => { |
| 135 | const query = request.query as { limit?: string; cursor?: string }; |
| 136 | return { |
| 137 | sources: await graphService.listSources({ |
| 138 | limit: query.limit ? Number(query.limit) : undefined, |
| 139 | cursor: query.cursor |
| 140 | }) |
| 141 | }; |
| 142 | }); |
| 143 | |
| 144 | app.get("/api/sources", async (request) => { |
| 145 | const query = request.query as { limit?: string; cursor?: string }; |
| 146 | return { |
| 147 | sources: await webuiService.listSources({ |
| 148 | limit: query.limit ? Number(query.limit) : undefined, |
| 149 | cursor: query.cursor |
| 150 | }) |
| 151 | }; |
| 152 | }); |
| 153 | |
| 154 | app.get("/api/projects", async (request) => { |
| 155 | const query = request.query as { limit?: string; cursor?: string; includeArchived?: string }; |
| 156 | return { |
| 157 | projects: await webuiService.listProjects({ |
| 158 | limit: query.limit ? Number(query.limit) : undefined, |
| 159 | cursor: query.cursor, |
| 160 | includeArchived: query.includeArchived === "true" |
| 161 | }) |
| 162 | }; |
| 163 | }); |
| 164 | |
| 165 | app.post("/api/projects", async (request, reply) => { |
| 166 | const input = projectSchema.parse(request.body); |
| 167 | const project = await webuiService.createProject(input); |
| 168 | return reply.code(201).send({ project }); |
| 169 | }); |
| 170 |
no test coverage detected