name = "zync-public-api"
main = "src/index.ts"
compatibility_date = "2026-05-30"
compatibility_flags = ["nodejs_compat"]

[placement]
mode = "smart"

# Hyperdrive → Neon Postgres
[[hyperdrive]]
binding = "HYPERDRIVE"
id = "PLACEHOLDER_HYPERDRIVE_ID"

# Rate-limit KV for per-key counters
[[kv_namespaces]]
binding = "RATELIMIT_KV"
id = "PLACEHOLDER_RATELIMIT_KV_ID"

# Shared auth rate-limiter KV (same namespace as login endpoint in zync-api)
[[kv_namespaces]]
binding = "RATE_LIMITER_AUTH"
id = "PLACEHOLDER_AUTH_RATE_LIMITER_KV_ID"

# wave-12: api-usage-quota-ui — per-key request counter (write binding)
[[analytics_engine_datasets]]
binding = "API_USAGE"
dataset = "api_usage"

[env.preview]
name = "zync-public-api-preview"
workers_dev = true

[env.production]
name = "zync-public-api"
routes = [
  { pattern = "api.zync.is/v1/*", zone_name = "zync.is" }
]

[[env.production.hyperdrive]]
binding = "HYPERDRIVE"
id = "PLACEHOLDER_HYPERDRIVE_ID"

[[env.production.kv_namespaces]]
binding = "RATELIMIT_KV"
id = "PLACEHOLDER_RATELIMIT_KV_ID"

[[env.production.kv_namespaces]]
binding = "RATE_LIMITER_AUTH"
id = "PLACEHOLDER_AUTH_RATE_LIMITER_KV_ID"

[[env.production.analytics_engine_datasets]]
binding = "API_USAGE"
dataset = "api_usage"
