name = "api"
main = "src/worker.ts"
compatibility_date = "2023-11-06"

compatibility_flags = [ "nodejs_compat" ]


## these are in local dev
[durable_objects]
bindings = [
  {name = "DO_RATELIMIT", class_name = "DurableObjectRatelimiter"  },
  {name = "DO_USAGELIMIT", class_name = "DurableObjectUsagelimiter"  }
]

 [[migrations]]
 tag = "v1"
 new_classes = ["DurableObjectRatelimiter"]
 [[migrations]]

 tag = "v2"
 new_classes = ["DurableObjectUsagelimiter"]

[env.development]
route = { pattern = "development-api.unkey.dev", custom_domain = true }
vars = {ENVIRONMENT = "development"}



[env.development.queues]
producers = [
  { queue = "logs-development", binding = "LOGS"},
  { queue = "metrics-development", binding = "METRICS"},
  { queue = "analytics-development", binding = "ANALYTICS"},
]
 

[env.development.durable_objects]
 bindings = [
 {name = "DO_RATELIMIT", class_name = "DurableObjectRatelimiter"  },
  {name = "DO_USAGELIMIT", class_name = "DurableObjectUsagelimiter"  }
]

[env.preview]
vars = {  ENVIRONMENT = "preview" }
route = { pattern = "preview-api.unkey.dev", custom_domain = true }


[env.preview.queues]
producers = [
  { queue = "logs-preview", binding = "LOGS"},
  { queue = "metrics-preview", binding = "METRICS"},
  { queue = "analytics-preview", binding = "ANALYTICS"},
]
 
[env.preview.durable_objects]
 bindings = [
  {name = "DO_RATELIMIT", class_name = "DurableObjectRatelimiter"},
  {name = "DO_USAGELIMIT", class_name = "DurableObjectUsagelimiter"  }

]

# canary is a special environment that is used to test new code by a small percentage of users before it is rolled out to the rest of the world.
# all settings must be the same as production, except for the route pattern
[env.canary]
vars = {  ENVIRONMENT = "canary"}
route = { pattern = "canary.unkey.dev", custom_domain = true}


[env.canary.queues]
producers = [
  { queue = "logs-production", binding = "LOGS"},
  { queue = "metrics-production", binding = "METRICS"},
  { queue = "analytics-production", binding = "ANALYTICS"},
]
 

[env.canary.durable_objects]
 bindings = [
  {name = "DO_RATELIMIT", class_name = "DurableObjectRatelimiter"  },
  {name = "DO_USAGELIMIT", class_name = "DurableObjectUsagelimiter"  }
]

[env.production]
vars = {  ENVIRONMENT = "production"}
route = { pattern = "api.unkey.dev", custom_domain = true}
logpush = true


[env.production.queues]
producers = [
  { queue = "logs-production", binding = "LOGS"},
  { queue = "metrics-production", binding = "METRICS"},
  { queue = "analytics-production", binding = "ANALYTICS"},
]
 
[env.production.durable_objects]
 bindings = [
  {name = "DO_RATELIMIT", class_name = "DurableObjectRatelimiter"  },
  {name = "DO_USAGELIMIT", class_name = "DurableObjectUsagelimiter"  }
]


