import { NextRequest, NextResponse } from 'next/server';
import { ResultDto } from '@/types/response/common';
import { fetchJson } from '@/lib/utils/server';

export async function POST(request: NextRequest, { params }: { params: Promise<{ path: string[] }> }) {
	const { path } = await params;
	const endpoint = `/api/${path.join('/')}`;

	const res: ResultDto = await fetchJson(endpoint, {
		method: 'POST',
		body: await request.arrayBuffer(),
		headers: { 'Content-Type': request.headers.get('content-type') || '' }
	});

	return NextResponse.json(res);
}
