import { NextResponse } from 'next/server';
import { syncModuleRegistry } from '@/lib/modules/feature-flags';

export const dynamic = 'force-dynamic';

/**
 * POST /api/modules/sync
 * Force-sync the module registry to the database.
 * Useful after code updates that add new modules.
 */
export async function POST() {
  try {
    await syncModuleRegistry();
    return NextResponse.json({ success: true, message: 'Module registry synced successfully.' });
  } catch (error) {
    console.error('Failed to sync modules:', error);
    return NextResponse.json({ error: 'Failed to sync module registry' }, { status: 500 });
  }
}
