()
| 20 | const REQUEST_ID_HEADER = "x-request-id"; |
| 21 | |
| 22 | const 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 | |
| 48 | describe("requestLogger sets x-request-id on every response", () => { |
| 49 | test("response carries an x-request-id header in UUID form", async () => { |
no test coverage detected