mirror of
https://github.com/versia-pub/server.git
synced 2025-12-07 16:58:20 +01:00
fix(api): 🐛 Fix body not being logged in request debugging
This commit is contained in:
parent
de75310b61
commit
e59c3aa625
|
|
@ -4,7 +4,7 @@ import { config } from "~/packages/config-manager";
|
||||||
|
|
||||||
export const logger = createMiddleware(async (context, next) => {
|
export const logger = createMiddleware(async (context, next) => {
|
||||||
if (config.logging.log_requests) {
|
if (config.logging.log_requests) {
|
||||||
await debugRequest(context.req.raw);
|
await debugRequest(context.req.raw, await context.req.text());
|
||||||
}
|
}
|
||||||
|
|
||||||
await next();
|
await next();
|
||||||
|
|
|
||||||
|
|
@ -395,8 +395,8 @@ export const jsonOrForm = () => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const debugRequest = async (req: Request) => {
|
export const debugRequest = async (req: Request, textBody?: string) => {
|
||||||
const body = await req.clone().text();
|
const body = textBody ?? (await req.clone().text());
|
||||||
const logger = getLogger("server");
|
const logger = getLogger("server");
|
||||||
|
|
||||||
const urlAndMethod = `${chalk.green(req.method)} ${chalk.blue(req.url)}`;
|
const urlAndMethod = `${chalk.green(req.method)} ${chalk.blue(req.url)}`;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue