Configuration, environment, and session context.

System settings are stored encrypted in the database and accessed through a caching layer. Environment variables provide runtime configuration for the edge deployment.

Functions

f
buildFlashCookie(
id: string,
message: string,
succeeded: boolean
): string

Build a flash cookie containing a success or error message, keyed by ID

f
clearFlashCookie(id: string): string

Clear a keyed flash cookie (set after reading)

f
getBookingFee(): number

Get booking fee percentage from database. Returns 0 if not set.

f
getBunnyApiKey(): string

Get the Bunny CDN API key from environment

f
getCachedSession(): AuthSession | null | undefined

Return the cached session if already resolved, or undefined if not yet resolved

f
getCdnHostname(): string

Get the CDN hostname derived from the effective domain. Replaces ".bunny.run" with ".b-cdn.net" for the CNAME target.

f
getEffectiveDomain(): string

Get the effective domain synchronously (must call loadEffectiveDomain first).

f
getEmbedHosts(): Promise<string[]>

Get allowed embed hosts from database (encrypted, parsed to array) Returns empty array if not configured (embedding allowed from anywhere)

f
getEnv(key: string): string | undefined

Get an environment variable value Checks process.env first (Bunny Edge), falls back to Deno.env (local dev)

f
isAdminLevel(s: string): s is AdminLevel

Type guard: check if a string is a valid AdminLevel

f
isBunnyCdnEnabled(): boolean

Check if Bunny CDN pull zone management is enabled Requires BUNNY_API_KEY to be set

f
isContactField(s: string): s is ContactField

Type guard: check if an arbitrary string is a valid ContactField

f
isEventType(s: string): s is EventType

Type guard: check if an arbitrary string is a valid EventType

f
isPaidEvent(event: Pick<Event, "unit_price" | "can_pay_more">): boolean

Whether an event can accept payments (has a price or allows pay-what-you-want)

f
isPaymentsEnabled(): boolean

Check if payments are enabled (any provider configured with valid keys)

f
loadEffectiveDomain(requestUrl: string): string

Load the effective domain from DB, falling back to the request URL hostname.

f
parseFlashValue(value: string): { success?: string; error?: string; } | null

Parse a flash cookie value into type and message, or null if invalid

f
requireEnv(key: string): string

Get a required environment variable, throwing if not set. Use this instead of getEnv(key) as string when the variable must exist.

f
resetEffectiveDomain(): void

Reset effective domain cache (for testing).

f
runWithSessionContext<T>(fn: () => T): T

Run a function within a session-memoization scope

f
setCachedSession(session: AuthSession | null): void

Store the resolved session in the current request scope

f
setEffectiveDomainForTest(domain: string): void

Set effective domain directly (for testing).

Interfaces

Type Aliases

T
AdminEvent = Omit<EventWithCount, "slug_index">

Admin API event shape — all event fields except internal indices. Used by both admin JSON API and admin templates to ensure consistent field exposure. Snake_case keys match the DB schema.

T
ContactFields =
Pick<ContactInfo, "name" | "email">
& Partial<
Pick<ContactInfo, "phone" | "address" | "special_instructions">
>

Required name+email with optional phone/address/special_instructions from ContactInfo

T
EventFields = string

Contact fields setting for an event (comma-separated ContactField names, or empty for name-only)

T
EventType = "standard" | "daily"

Event type: standard (one-time) or daily (date-based booking)

T
PaymentProviderType = "stripe" | "square"

Supported payment provider identifiers

Variables

v
CONTACT_FIELDS: readonly ContactField[]

All valid contact field names (runtime array matching the ContactField union)