/**
 * Post Code Review to GitHub API Route
 *
 * POST /api/code-reviews/:id/post — Post a completed review to GitHub
 */
import { NextResponse } from 'next/server';
import { resolve } from '../../../../../lib/server-container.js';
export const dynamic = 'force-dynamic';
export async function POST(_request, { params }) {
    try {
        const { id } = await params;
        const useCase = resolve('PostCodeReviewUseCase');
        const review = await useCase.execute(id);
        return NextResponse.json(review);
    }
    catch (error) {
        const message = error instanceof Error ? error.message : 'Internal server error';
        if (message.includes('not found')) {
            return NextResponse.json({ error: message }, { status: 404 });
        }
        if (message.includes('Cannot post')) {
            return NextResponse.json({ error: message }, { status: 422 });
        }
        // eslint-disable-next-line no-console
        console.error('[POST /api/code-reviews/:id/post]', error);
        return NextResponse.json({ error: message }, { status: 500 });
    }
}
