import { NextResponse } from 'next/server' /** * Hot-reload endpoint for roadmap updates * Allows updating roadmap without container restart * * Usage: * curl -X POST http://localhost:3001/api/roadmap/reload * * Returns: Updated roadmap data immediately * No container rebuild/restart needed! */ export async function POST() { try { // Clear Next.js route cache for /api/roadmap // This forces the roadmap API to re-execute on next request // In production, you could also use revalidatePath('/api/roadmap') // Fetch fresh roadmap data const baseUrl = process.env.NEXT_PUBLIC_BASE_URL || 'http://localhost:3000' const response = await fetch(`${baseUrl}/api/roadmap`, { method: 'GET', cache: 'no-store', headers: { 'Cache-Control': 'no-cache, no-store, must-revalidate', } }) if (!response.ok) { throw new Error(`Failed to fetch roadmap: ${response.status}`) } const data = await response.json() return NextResponse.json({ success: true, message: 'Roadmap reloaded successfully - changes live without restart!', timestamp: new Date().toISOString(), stats: data.stats, itemsCount: data.roadmap?.length || 0 }) } catch (error: any) { console.error('❌ Roadmap reload error:', error) return NextResponse.json({ success: false, error: error.message }, { status: 500 }) } } // GET method for info/status export async function GET() { return NextResponse.json({ endpoint: '/api/roadmap/reload', method: 'POST', description: 'Hot-reload roadmap without container restart', usage: 'curl -X POST http://localhost:3001/api/roadmap/reload', benefit: 'Update roadmap instantly - no downtime, no rebuild needed' }) }