import { createApiRoute, requireAuth } from '@/utils/apiRouteHandler';
import { serverApiClient } from '@/utils/serverApiClient';

/**
 * Generic co-creation start endpoint
 * Accepts a co_creation_url and forwards it to the backend
 */
export const POST = createApiRoute(
  requireAuth(async (req, { token }) => {
    const body = await req.json();
    const { co_creation_url } = body;

    if (!co_creation_url) {
      return {
        success: false,
        message: 'Co-creation URL is required',
      };
    }

    // Forward the request to the backend using the co_creation_url
    const result = await serverApiClient(co_creation_url, {
      method: 'GET',
    });

    return result;
  })
);
