import type { HonoRequest } from '../request.ts' export type BodyData = Record export const parseBody = async ( r: HonoRequest | Request ): Promise => { let body: BodyData = {} const contentType = r.headers.get('Content-Type') if ( contentType && (contentType.startsWith('multipart/form-data') || contentType.startsWith('application/x-www-form-urlencoded')) ) { const form: BodyData = {} ;(await r.formData()).forEach((value, key) => { form[key] = value }) body = form } return body as T }