mirror of
https://github.com/versia-pub/server.git
synced 2026-04-27 20:59:15 +02:00
feat(api): ✨ Add response logging
This commit is contained in:
parent
b5411c01e4
commit
5d2aa82247
4 changed files with 37 additions and 2 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import type { OpenAPIHono } from "@hono/zod-openapi";
|
||||
import type { Config } from "~/packages/config-manager/config.type";
|
||||
import type { HonoEnv } from "~/types/api";
|
||||
import { debugResponse } from "./api";
|
||||
|
||||
export const createServer = (config: Config, app: OpenAPIHono<HonoEnv>) =>
|
||||
Bun.serve({
|
||||
|
|
@ -17,7 +18,13 @@ export const createServer = (config: Config, app: OpenAPIHono<HonoEnv>) =>
|
|||
}
|
||||
: undefined,
|
||||
hostname: config.http.bind || "0.0.0.0", // defaults to "0.0.0.0"
|
||||
fetch(req, server) {
|
||||
return app.fetch(req, { ip: server.requestIP(req) });
|
||||
async fetch(req, server) {
|
||||
const output = await app.fetch(req, { ip: server.requestIP(req) });
|
||||
|
||||
if (config.logging.log_responses) {
|
||||
await debugResponse(output.clone());
|
||||
}
|
||||
|
||||
return output;
|
||||
},
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue