export default async function parse_body(req: Request): Promise<any> {
	switch (req.headers.get('content-type')) {
		case 'application/x-www-form-urlencoded': {
			const form_data = await req.formData();
			const body: Record<string, any> = {};
			const keys = form_data.keys();

			for (const key of keys) {
				body[key] = form_data.get(key);
			}

			return body;
		}
		case 'application/json':
		default:
			return req.json();
	}
}
