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 commentsSettings Reference Table
| Setting | Default | Type | Description |
|---|---|---|---|
version | 1 | integer | Configuration format version. Required. |
server.host | 0.0.0.0 | string | Bind address. Use 127.0.0.1 behind local reverse proxies. |
server.port | 8080 | integer | TCP port from 1 to 65535. |
database.url | Required | string | PostgreSQL connection string for administrative operations. |
database.exposeErrorDetails | false | boolean | When true, includes PostgreSQL detail and hint in responses. |
database.queryUrls | {} | object | Explicit database-to-URL mappings for default query logins. |
database.pool.min | 2 | integer | Minimum connections in administrative pool. |
database.pool.queryMin | 1 | integer | Prewarmed connections kept per query login pool. |
database.pool.max | 20 | integer | Max connections in administrative pool and per query pool. |
database.pool.maxGlobalQueries | 40 | integer | Global process cap across all query pools. |
database.pool.connectionTimeoutMillis | 10000 | integer | Max time (ms) to open a physical PostgreSQL TCP connection. |
database.pool.checkoutTimeoutMillis | 10000 | integer | Max time (ms) a request waits for a verified pooled connection. |
database.pool.growthIntervalMillis | 0 | integer | Throttle delay (ms) between scheduled pool expansions. |
database.pool.maxConcurrentOpenings | 4 | integer | Max concurrent physical openings per pool. |
database.pool.statementTimeoutMillis | 30000 | integer | PostgreSQL statement timeout (ms) applied at checkout. |
database.pool.queryTimeoutMillis | 35000 | integer | Client-side query timeout (ms) for immediate SQL. |
redis.enabled | true | boolean | Connect to Redis. Set false for local in-memory operation. |
redis.url | Required | string | Redis connection URL when redis.enabled is true. |
ratelimit.enabled | true | boolean | Enable request rate limiting. |
ratelimit.requestPerMinute | 1000 | integer | Max requests per authenticated API key per minute. |
ratelimit.requestPerMinutePerIp | 1000 | integer | Max requests per client IP per minute. |
ratelimit.whitelistedIPs | [] | array | IPs or CIDR blocks exempt from per-IP rate limits. |
transactions.retentionDays | 30 | integer | Days to retain async query outcomes and transaction receipts. |
analytics.enabled | true | boolean | Collect query metrics in local SQLite database. |
analytics.directory | ./data/analytics | string | Path where analytics.sqlite is written. |
analytics.retentionDays | 30 | integer | Retention for failed-query records (counters are cumulative). |
analytics.maxStorageBytes | 67108864 | integer | Max SQLite storage footprint in bytes (minimum 1048576). |
analytics.storeFullSql | false | boolean | When 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.portmust be an integer between1and65535.- Pool minimums (
min,queryMin) cannot exceedpool.max. - Pool timeouts and capacity caps must be positive integers (
> 0). - If
redis.enabled: true,redis.urlmust be a non-empty string. ratelimit.whitelistedIPsentries must be valid IPv4 or IPv6 addresses or CIDRs.analytics.maxStorageBytesmust be at least 1 MiB (1048576bytes).
