I'v been working in an API with Hono.js and Cloudflare Workers with hyperdrive and R2. Now I'm trying to setup the diferent environments the app is gonna run: Production (prod), Development (dev) and Local.
The problem I'm facing is that I can't get a clear way to define the environments in the wrangler documentation. For example for the R2 buckets there are two ways of definig the buckets:
[[r2_buckets]]
binding = 'MY_BUCKET' # <~ valid JavaScript variable name
bucket_name = '<YOUR_BUCKET_NAME>'
or this:
r2_buckets = [{
binding = 'MY_BUCKET' # <~ valid JavaScript variable name
bucket_name = '<YOUR_BUCKET_NAME>'
}]
But if I do it for Hyperdrive it's giving errors with the "{".
Also I don't get clear information of if the correct way to declare variables for every environment is this:
[env.prod]
vars = {
...
}
or this: [env.prod.vars]
After all the mess of developing a big API it's funny that I got stuck in the wrangler.toml file. I would appreciate help in how to write the wrangler.toml file to configure the local, prod, and dev environent for the Vars, Hyperdrive, R2Buckets, and also Unsave Bindings.