feat: persist metafield resolutions across sessions
Les associations colonne→métachamp sont sauvegardées dans data/metafield-resolutions.json et rechargées automatiquement à la prochaine création de produits. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import { NextRequest, NextResponse } from 'next/server'
|
||||
import { getServerSession } from 'next-auth'
|
||||
import { authOptions } from '@/lib/auth'
|
||||
import { loadResolutionCache, saveResolutionCache } from '@/lib/resolutionCache'
|
||||
import type { MetafieldResolution } from '@/types/creation'
|
||||
|
||||
export async function GET() {
|
||||
const session = await getServerSession(authOptions)
|
||||
if (!session) return NextResponse.json({ error: 'Non authentifié' }, { status: 401 })
|
||||
const cache = await loadResolutionCache()
|
||||
return NextResponse.json(cache)
|
||||
}
|
||||
|
||||
export async function PUT(req: NextRequest) {
|
||||
const session = await getServerSession(authOptions)
|
||||
if (!session) return NextResponse.json({ error: 'Non authentifié' }, { status: 401 })
|
||||
const body = await req.json() as Record<string, MetafieldResolution>
|
||||
await saveResolutionCache(body)
|
||||
return NextResponse.json({ ok: true })
|
||||
}
|
||||
Reference in New Issue
Block a user