Configuration

Gateway YAML

Complete YAML configuration reference, environment variable substitution, and startup validation rules.

gateway.yaml Reference

HTTP PostgreSQL Gateway loads configuration from gateway.yaml in the working directory on startup. It also loads .env if present.


Environment Variable Substitution

Any YAML string value can reference an environment variable using ${VARIABLE} or provide a default fallback using ${VARIABLE:-fallback}:

database: url: "${DATABASE_URL:-postgresql://postgres:postgres@127.0.0.1:5432/postgres}"
  • If an environment variable is set before startup, it takes precedence over .env.
  • If a referenced variable is missing and no fallback is provided, the gateway fails startup validation.
  • An empty variable (e.g. VAR="") counts as set.

Complete gateway.yaml Reference

version: 1 server: host: "0.0.0.0" # Listen IP (use 127.0.0.1 for local loopback only) port: 8080 # Listen port (1 to 65535) database: url: "${DATABASE_URL:-postgresql://postgres:postgres@127.0.0.1:5432/postgres}" exposeErrorDetails: false # Expose PostgreSQL detail and hint in errors queryUrls: {} # Optional map of database names to default login URLs pool: min: 2 # Admin pool minimum size queryMin: 2 # Prewarmed connections per query login max: 50 # Max size for admin pool and each query pool maxGlobalQueries: 100 # Process-wide cap across all query pools connectionTimeoutMillis: 10000 # Physical connection opening timeout checkoutTimeoutMillis: 10000 # Session acquisition & verification deadline growthIntervalMillis: 0 # Delay between opening additional connections maxConcurrentOpenings: 4 # Concurrent openings per pool when waiting statementTimeoutMillis: 30000 # PostgreSQL statement_timeout (30s) queryTimeoutMillis: 35000 # Client query execution deadline (35s) redis: enabled: true # Set to false for in-memory local dev mode: external # accepts external or managed url: "${REDIS_URL:-redis://127.0.0.1:6379}" ratelimit: enabled: true # Enable rate limiting requestPerMinute: 1000 # Requests per API key per 60-second window requestPerMinutePerIp: 1000 # Requests per IP per 60-second window (pre-auth) whitelistedIPs: [] # Exempt IPv4/IPv6 IPs and CIDRs (e.g. ["10.0.0.0/8"]) transactions: retentionDays: 30 # Days to retain transaction records & tombstones analytics: enabled: true # Collect query usage and failed query records directory: "./data/analytics" # Storage directory for analytics.sqlite retentionDays: 30 # Retention for failed query records maxStorageBytes: 67108864 # Quota in bytes (64 MiB, minimum 1 MiB) storeFullSql: false # If false, sanitizes literals and comments

Settings Reference Table

SettingDefaultTypeDescription
version1integerConfiguration format version. Required.
server.host0.0.0.0stringBind address. Use 127.0.0.1 behind local reverse proxies.
server.port8080integerTCP port from 1 to 65535.
database.urlRequiredstringPostgreSQL connection string for administrative operations.
database.exposeErrorDetailsfalsebooleanWhen true, includes PostgreSQL detail and hint in responses.
database.queryUrls{}objectExplicit database-to-URL mappings for default query logins.
database.pool.min2integerMinimum connections in administrative pool.
database.pool.queryMin1integerPrewarmed connections kept per query login pool.
database.pool.max20integerMax connections in administrative pool and per query pool.
database.pool.maxGlobalQueries40integerGlobal process cap across all query pools.
database.pool.connectionTimeoutMillis10000integerMax time (ms) to open a physical PostgreSQL TCP connection.
database.pool.checkoutTimeoutMillis10000integerMax time (ms) a request waits for a verified pooled connection.
database.pool.growthIntervalMillis0integerThrottle delay (ms) between scheduled pool expansions.
database.pool.maxConcurrentOpenings4integerMax concurrent physical openings per pool.
database.pool.statementTimeoutMillis30000integerPostgreSQL statement timeout (ms) applied at checkout.
database.pool.queryTimeoutMillis35000integerClient-side query timeout (ms) for immediate SQL.
redis.enabledtruebooleanConnect to Redis. Set false for local in-memory operation.
redis.urlRequiredstringRedis connection URL when redis.enabled is true.
ratelimit.enabledtruebooleanEnable request rate limiting.
ratelimit.requestPerMinute1000integerMax requests per authenticated API key per minute.
ratelimit.requestPerMinutePerIp1000integerMax requests per client IP per minute.
ratelimit.whitelistedIPs[]arrayIPs or CIDR blocks exempt from per-IP rate limits.
transactions.retentionDays30integerDays to retain async query outcomes and transaction receipts.
analytics.enabledtruebooleanCollect query metrics in local SQLite database.
analytics.directory./data/analyticsstringPath where analytics.sqlite is written.
analytics.retentionDays30integerRetention for failed-query records (counters are cumulative).
analytics.maxStorageBytes67108864integerMax SQLite storage footprint in bytes (minimum 1048576).
analytics.storeFullSqlfalsebooleanWhen false, auto-redacts literals and comments in failed SQL.

Startup Validation Rules

The gateway strictly validates the entire configuration before opening any database or network socket:

  • server.port must be an integer between 1 and 65535.
  • Pool minimums (min, queryMin) cannot exceed pool.max.
  • Pool timeouts and capacity caps must be positive integers (> 0).
  • If redis.enabled: true, redis.url must be a non-empty string.
  • ratelimit.whitelistedIPs entries must be valid IPv4 or IPv6 addresses or CIDRs.
  • analytics.maxStorageBytes must be at least 1 MiB (1048576 bytes).
Copyright © 2026