Skip to content

GatewayConfig

Defined in: src/core/types.ts:17

Top-level gateway configuration

optional adapter: GatewayAdapter

Defined in: src/core/types.ts:65

Runtime adapter providing store implementations and runtime-specific capabilities (e.g. waitUntil, dispatchBinding). Created via adapter factories like cloudflareAdapter(), memoryAdapter(), etc.


optional admin: boolean | AdminConfig

Defined in: src/core/types.ts:73

Admin introspection API. Exposes ___gateway/* routes for operational visibility.

  • true — enable with defaults (no auth)
  • AdminConfig object — full customization
  • false / undefined — disabled (default)

optional basePath: string

Defined in: src/core/types.ts:21

Base path prefix for all routes (e.g. “/api”)


optional debug: string | boolean

Defined in: src/core/types.ts:48

Enable internal debug logging for gateway operators.

  • true — log all namespaces
  • false / undefined — disabled (default, zero overhead)
  • string — comma-separated glob patterns to filter namespaces

Namespaces: stoma:gateway, stoma:pipeline, stoma:upstream, stoma:policy:* (e.g. stoma:policy:cache, stoma:policy:jwt-auth)

Output goes to console.debug() which is captured by wrangler tail and Cloudflare Workers Logs.

createGateway({ debug: true, ... }) // everything
createGateway({ debug: "stoma:gateway,stoma:upstream", ... }) // core only
createGateway({ debug: "stoma:policy:*", ... }) // policies only

optional debugHeaders: boolean | DebugHeadersConfig

Defined in: src/core/types.ts:97

Enable client-requested debug headers.

When enabled, clients can send an x-stoma-debug request header listing the debug values they want returned as response headers. Policies contribute debug data via setDebugHeader from the SDK — only requested values are included in the response.

  • true — enable with defaults
  • DebugHeadersConfig — full customization (request header name, allowlist)
  • false / undefined — disabled (default, zero overhead)
// Client request:
GET /api/users
x-stoma-debug: x-stoma-cache-key, x-stoma-cache-ttl
// Response includes:
x-stoma-cache-key: GET:http://example.com/api/users
x-stoma-cache-ttl: 300

optional defaultErrorMessage: string

Defined in: src/core/types.ts:57

Default error message for unexpected (non-GatewayError) errors. Default: "An unexpected error occurred".


optional defaultMethods: HttpMethod[]

Defined in: src/core/types.ts:55

Default HTTP methods for routes that don’t specify methods. Default: ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"].


optional defaultPolicyPriority: number

Defined in: src/core/types.ts:59

Default priority for policies that don’t specify one. Default: 100.


optional name: string

Defined in: src/core/types.ts:19

Gateway name, used in logs and metrics


optional onError: (error, c) => Response | Promise<Response>

Defined in: src/core/types.ts:27

Global error handler

Error

unknown

Response | Promise<Response>


optional policies: Policy[]

Defined in: src/core/types.ts:25

Global policies applied to all routes


optional requestIdHeader: string

Defined in: src/core/types.ts:50

Response header name for the request ID. Default: "x-request-id".


routes: RouteConfig[]

Defined in: src/core/types.ts:23

Route definitions