Creative Analyzer - v0.0.1
    Preparing search index...

    Function handleAnalyze

    • Handle a POST /api/analyze request end-to-end.

      Pipeline:

      1. Parse JSON body — return 400 on malformed JSON.
      2. Zod-validate the { url } shape — return 400 with a static message on failure (Zod issue detail goes to console.warn, never the client).
      3. Download the Drive file — DriveError is mapped to a user-safe response.
      4. Analyze with Gemini — GeminiError is mapped to a user-safe response.
      5. Return the validated { person, transcript } JSON.

      Any unexpected exception is logged at console.error and surfaced as a generic 500. Raw upstream messages never reach the client.

      Parameters

      • request: Request

        Incoming POST /api/analyze request.

      • env: Env

        Worker environment (provides GEMINI_API_KEY).

      Returns Promise<Response>

      Either the analyzed JSON or a uniform { error } body.