export function parseJsonBody(body: unknown): unknown {
  if (body == null) return null;
  if (Buffer.isBuffer(body)) {
    const text = body.toString('utf8').trim();
    return text ? JSON.parse(text) : null;
  }
  if (typeof body === 'string') {
    const text = body.trim();
    return text ? JSON.parse(text) : null;
  }
  return body;
}
