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