mirror of
https://github.com/versia-pub/server.git
synced 2025-12-06 08:28:19 +01:00
fix(federation): 🐛 Fix debug logger not correctly outputting
This commit is contained in:
parent
eab61b38f1
commit
fd38161769
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { debugRequest } from "@api";
|
||||||
import {
|
import {
|
||||||
type EntityValidator,
|
type EntityValidator,
|
||||||
SignatureConstructor,
|
SignatureConstructor,
|
||||||
|
|
@ -42,5 +43,12 @@ export const objectToInboxRequest = async (
|
||||||
body: JSON.stringify(object),
|
body: JSON.stringify(object),
|
||||||
});
|
});
|
||||||
|
|
||||||
return await ctor.sign(request);
|
const signed = await ctor.sign(request);
|
||||||
|
|
||||||
|
if (config.debug.federation) {
|
||||||
|
// Debug request
|
||||||
|
await debugRequest(signed);
|
||||||
|
}
|
||||||
|
|
||||||
|
return signed;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ import { fromZodError } from "zod-validation-error";
|
||||||
import type { Application } from "~database/entities/Application";
|
import type { Application } from "~database/entities/Application";
|
||||||
import { getFromHeader } from "~database/entities/User";
|
import { getFromHeader } from "~database/entities/User";
|
||||||
import type { User } from "~packages/database-interface/user";
|
import type { User } from "~packages/database-interface/user";
|
||||||
import { LogLevel } from "~packages/log-manager";
|
import { LogLevel, LogManager } from "~packages/log-manager";
|
||||||
import type { APIRouteMetadata, HttpVerb } from "~types/api";
|
import type { APIRouteMetadata, HttpVerb } from "~types/api";
|
||||||
|
|
||||||
export const applyConfig = (routeMeta: APIRouteMetadata) => {
|
export const applyConfig = (routeMeta: APIRouteMetadata) => {
|
||||||
|
|
@ -302,7 +302,10 @@ export const jsonOrForm = () => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const debugRequest = async (req: Request, logger = consoleLogger) => {
|
export const debugRequest = async (
|
||||||
|
req: Request,
|
||||||
|
logger = new LogManager(Bun.stdout),
|
||||||
|
) => {
|
||||||
const body = await req.clone().text();
|
const body = await req.clone().text();
|
||||||
await logger.log(
|
await logger.log(
|
||||||
LogLevel.DEBUG,
|
LogLevel.DEBUG,
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ const isEntry = true;
|
||||||
export const logger = new LogManager(
|
export const logger = new LogManager(
|
||||||
isEntry ? requests_log : Bun.file("/dev/null"),
|
isEntry ? requests_log : Bun.file("/dev/null"),
|
||||||
);
|
);
|
||||||
|
|
||||||
export const consoleLogger = new LogManager(
|
export const consoleLogger = new LogManager(
|
||||||
isEntry ? Bun.stdout : Bun.file("/dev/null"),
|
isEntry ? Bun.stdout : Bun.file("/dev/null"),
|
||||||
!noColors,
|
!noColors,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue