Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | import { existsSync, statSync } from 'fs' import { join } from 'path' import { NextResponse } from 'next/server' import { PREVIEW_TARGETS } from '@/lib/homepage-previews' import { IMAGE_PROVIDERS } from '@/lib/image-providers' import { withAuth } from '@/lib/auth/withAuth' const HOMEPAGE_IMAGES_DIR = join(process.cwd(), 'public', 'images', 'homepage') /** * GET /api/admin/homepage-previews/status * * Returns all preview targets with their image existence and file size. */ export const GET = withAuth( async () => { const targets = PREVIEW_TARGETS.map((target) => { const filePath = join(HOMEPAGE_IMAGES_DIR, `${target.id}.png`) const exists = existsSync(filePath) return { id: target.id, type: target.type, label: target.label, width: target.width, height: target.height, prompt: target.type === 'ai' ? target.prompt : undefined, imageExists: exists, sizeBytes: exists ? statSync(filePath).size : undefined, } }) const providers = IMAGE_PROVIDERS.map((p) => { const hasKey = 'envKeyAlt' in p ? !!(process.env[p.envKey] || process.env[p.envKeyAlt!]) : !!process.env[p.envKey] return { id: p.id, name: p.name, available: hasKey, models: p.models.map((m) => ({ id: m.id, name: m.name })), } }) return NextResponse.json({ targets, providers }) }, { role: 'admin' } ) |