import { ApplicationRequestError } from "../../application/ApplicationRequestError"; export class HttpRequestJsonBodyReader { static async readJsonBody(request: Request): Promise { try { return (await request.json()) as TBody; } catch (error) { const message = error instanceof Error ? error.message : String(error); throw new ApplicationRequestError(400, `Invalid JSON body: ${message}`); } } }