Skip to content

Canvix — Free & open-source graphic design tool. A community-built Canva alternative with a drag-and-drop editor, templates, shapes, text, images & one-click export. Works on desktop, tablet & mobile.

1.0 KB
Raw Blame
import { NextResponse } from 'next/server'
import { stockPhotoProviders } from '@/lib/stock-photo'
import { withLogging } from '@/lib/observability'

export const runtime = 'nodejs'
export const dynamic = 'force-dynamic'

/**
 * GET /api/stock-photo/available — public, secret-free feature
 * detection for the Photos panel's web-search section (v0.16.4
 * A4, the F2b pattern): the panel queries this to know whether
 * stock photo search is keyed before the first search runs.
 * Exposes WHICH connectors are keyed, never the keys themselves.
 */
async function __canvix_get() {
  // A5: keys resolve console-first (stored → env), so this reads the
  // AppConfig cache — one findMany per 10 s per instance at most.
  const providers = await stockPhotoProviders()
  return NextResponse.json({
    available: providers.length > 0,
    providers,
  })
}

// v0.12.5 (H7): opt-in request logging wrapper — passthrough
// unless CANVIX_LOG=requests (see src/lib/observability.ts)
export const GET = withLogging('GET /api/stock-photo/available', __canvix_get)