MCPcopy Create free account
hub / github.com/Zleap-AI/SAG / buildHttpServer

Function buildHttpServer

src/api/server.ts:113–583  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

111});
112
113export 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

Callers 1

startHttpServerFunction · 0.85

Calls 15

notFoundFunction · 0.85
sendFunction · 0.85
getPublicMcpSettingsFunction · 0.85
listProjectsMethod · 0.80
createProjectMethod · 0.80
updateProjectMethod · 0.80
archiveProjectMethod · 0.80
restoreProjectMethod · 0.80
deleteProjectMethod · 0.80
listDocumentsMethod · 0.80
getProjectStatsMethod · 0.80
getProjectGraphMethod · 0.80

Tested by

no test coverage detected