I'm trying to adapt an Express app to CloudFlare Functions. As I understand it, Functions/serverless doesn't really support anything that needs to read from a file system. And so the advice apparently is to subsume my config values into my wrangler.toml
file.
Here's my JSON:
{
"zero": "etc",
"one": {
"two": {
"three": "four"
}
}
}
This JSON-to-TOML util gave me:
zero = "etc"
[one.two]
three = "four"
I put that into my wrangler.toml
right under the [vars]
section heading and start the server, which it tells me:
Your worker has access to the following bindings:
- Vars:
- zero: "etc"
Why aren't my nested values coming through?
You could use the command-line tool
tomlq
from kislyuk/yq to automate the JSON-to-TOML conversion. A provided filter is run internally using jqlang/jq, so any kind of transformation can be applied to it on the fly. For example, given your JSON sample asinput.json
, to wrap everything below[vars]
you can run: