SPB Git

spb/worthdoing Public

Autonomous investigation agent that discovers, challenges, and ranks things genuinely worth doing — Claude + Firecrawl, Next.js 16, PostgreSQL

TypeScript 91.5% SQL 5.8% CSS 2.2%
1.1 KB · 33 lines typescript
Raw Blame History
1/**2 * WorthDoing.ai3 * Author: Simon-Pierre Boucher4 * Contact: contact@spboucher.ai5 * File: src/lib/env.ts6 * Description: Zod-validated server-side environment variables (never import from client code).7 */8import { z } from "zod";910const envSchema = z.object({11  ANTHROPIC_API_KEY: z.string().min(10),12  FIRECRAWL_API_KEY: z.string().min(10),13  DATABASE_URL: z.string().url(),14  PUBLIC_BASE_URL: z.string().url().default("https://www.worthdoing.ai"),15  CLAUDE_AGENT_MODEL: z.string().default("claude-opus-5"),16  CLAUDE_SYNTHESIS_MODEL: z.string().default("claude-opus-5"),17  NODE_ENV: z.enum(["development", "test", "production"]).default("development"),18});1920let cached: z.infer<typeof envSchema> | null = null;2122/** Validated environment. Throws a structured error at first server-side access if misconfigured. */23export function env(): z.infer<typeof envSchema> {24  if (cached) return cached;25  const parsed = envSchema.safeParse(process.env);26  if (!parsed.success) {27    const missing = parsed.error.issues.map((i) => i.path.join(".")).join(", ");28    throw new Error(`Invalid environment configuration: ${missing}`);29  }30  cached = parsed.data;31  return cached;32}33