MCPcopy Index your code
hub / github.com/triggerdotdev/trigger.dev / #createHttpServer

Method #createHttpServer

apps/coordinator/src/index.ts:1366–1402  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1364 }
1365
1366 #createHttpServer() {
1367 const httpServer = createServer(async (req, res) => {
1368 logger.log(`[${req.method}]`, req.url);
1369
1370 const reply = new HttpReply(res);
1371
1372 switch (req.url) {
1373 case "/health": {
1374 return reply.text("ok");
1375 }
1376 case "/metrics": {
1377 return reply.text(await register.metrics(), 200, register.contentType);
1378 }
1379 case "/whoami": {
1380 return reply.text(NODE_NAME);
1381 }
1382 case "/checkpoint": {
1383 const body = await getTextBody(req);
1384 // await this.#checkpointer.checkpointAndPush(body);
1385 return reply.text(`sent restore request: ${body}`);
1386 }
1387 default: {
1388 return reply.empty(404);
1389 }
1390 }
1391 });
1392
1393 httpServer.on("clientError", (err, socket) => {
1394 socket.end("HTTP/1.1 400 Bad Request\r\n\r\n");
1395 });
1396
1397 httpServer.on("listening", () => {
1398 logger.log("server listening on port", HTTP_SERVER_PORT);
1399 });
1400
1401 return httpServer;
1402 }
1403
1404 listen() {
1405 this.#httpServer.listen(this.port, this.host);

Callers 1

constructorMethod · 0.95

Calls 5

textMethod · 0.95
emptyMethod · 0.95
getTextBodyFunction · 0.90
logMethod · 0.65
onMethod · 0.65

Tested by

no test coverage detected