Creating Runtime-Dependent Layers in Cloudflare Workers
Is it possible to make a layer that depends on a runtime input?
I'm using Cloudflare Workers, which provides the database instance like this:
I need to use several
but I get an error here:
I attempted to use the
Questions:
(a) is it correct to define a layer like
(b) is it possible to fix the error? or do I need to change both D1Live and DatabaseLive to functions accepting an
I'm using Cloudflare Workers, which provides the database instance like this:
I need to use several
env.<service> instances in different part of the code. In order to avoid having to pass env to each layer, I've attempted to do this:but I get an error here:
I attempted to use the
Config module, but as far as I could tell, it doesn't seem to like the fact the initial env.DB value isn't a string.Questions:
(a) is it correct to define a layer like
WorkerEnv.Live above that accepts an arg? (I'm passing env to it)(b) is it possible to fix the error? or do I need to change both D1Live and DatabaseLive to functions accepting an
env arg as well?