Skip to content

Open-source status page, incident response and uptime monitoring

2.5 KB
Raw Blame
import { monitorRegions } from "@openstatus/db/src/schema/constants";
import { createEnv } from "@t3-oss/env-core";
import { z } from "zod";

export const env = createEnv({
  server: {
    UNKEY_API_ID: z.string().min(1),
    UNKEY_TOKEN: z.string().min(1),
    TINY_BIRD_API_KEY: z.string().min(1),
    TINYBIRD_URL: z.string().default("https://api.tinybird.co"),
    TINYBIRD_NOOP: z.stringbool().catch(false),
    UPSTASH_REDIS_REST_URL: z.string().min(1),
    UPSTASH_REDIS_REST_TOKEN: z.string().min(1),
    FLY_REGION: z.enum(monitorRegions),
    CRON_SECRET: z.string(),
    SCREENSHOT_SERVICE_URL: z.string(),
    QSTASH_TOKEN: z.string(),
    NODE_ENV: z.string().prefault("development"),
    SUPER_ADMIN_TOKEN: z.string(),
    RESEND_API_KEY: z.string(),
    AXIOM_TOKEN: z.string(),
    AXIOM_DATASET: z.string(),
    SLACK_SIGNING_SECRET: z.string().optional(),
    SLACK_CLIENT_ID: z.string().optional(),
    SLACK_CLIENT_SECRET: z.string().optional(),
    SLACK_REDIRECT_URI: z.string().optional(),
    AI_GATEWAY_API_KEY: z.string().optional(),
    // Fixed, not derived from the request host, so OAuth metadata is stable
    // behind proxies. Defaults resolve in `routes/oauth/config.ts`.
    OAUTH_ISSUER: z.url().optional(),
    DASHBOARD_URL: z.url().optional(),
    // Overload guards, per machine. `skipValidation` never runs these schemas,
    // so defaults live in `libs/middlewares/limits.ts`.
    API_MAX_IN_FLIGHT: z.coerce.number().optional(),
    API_RATE_LIMIT_PER_MINUTE: z.coerce.number().optional(),
    API_RATE_LIMIT_BURST_PER_10S: z.coerce.number().optional(),
    API_RATE_LIMIT_WRITES_PER_MINUTE: z.coerce.number().optional(),
    API_RATE_LIMIT_PUBLIC_PER_MINUTE: z.coerce.number().optional(),
  },

  /**
   * What object holds the environment variables at runtime. This is usually
   * `process.env` or `import.meta.env`.
   */
  runtimeEnv: process.env,

  /**
   * By default, this library will feed the environment variables directly to
   * the Zod validator.
   *
   * This means that if you have an empty string for a value that is supposed
   * to be a number (e.g. `PORT=` in a ".env" file), Zod will incorrectly flag
   * it as a type mismatch violation. Additionally, if you have an empty string
   * for a value that is supposed to be a string with a default value (e.g.
   * `DOMAIN=` in an ".env" file), the default value will never be applied.
   *
   * In order to solve these issues, we recommend that all new projects
   * explicitly specify this option as true.
   */
  skipValidation: true,
});