MCPcopy Create free account
hub / github.com/boringstack-xyz/boringstack / buildApp

Function buildApp

apps/api/tests/middleware/request-logger.test.ts:22–46  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

20const REQUEST_ID_HEADER = "x-request-id";
21
22const buildApp = () =>
23 new Elysia()
24 .use(requestLogger)
25 .onError(({ code, error, set }) =>
26 errorHandler({ code: String(code), error, set })
27 )
28 .get(TEST_PATH, () => ({ ok: true }), {
29 detail: { tags: [...TEST_TAGS] },
30 response: t.Object({ ok: t.Boolean() }),
31 })
32 .get(
33 "/throw-api-error",
34 () => {
35 throw ApiErrors.forbidden("nope");
36 },
37 {
38 detail: { tags: [...TEST_TAGS] },
39 response: t.Object({ ok: t.Boolean() }),
40 }
41 )
42 .post("/needs-body", ({ body }) => ({ ok: typeof body === "object" }), {
43 body: t.Object({ requiredField: t.String() }),
44 response: t.Object({ ok: t.Boolean() }),
45 detail: { tags: [...TEST_TAGS] },
46 });
47
48describe("requestLogger sets x-request-id on every response", () => {
49 test("response carries an x-request-id header in UUID form", async () => {

Callers 1

Calls 2

errorHandlerFunction · 0.90
getMethod · 0.45

Tested by

no test coverage detected