Description
Current implementation doesn't support a case when all wrangler.jsonc
files have to be collected from each layer in nuxt.options._layers
and merged to one.
https://github.com/nitrojs/nitro-cloudflare-dev/blob/main/src/index.ts#L29
E.g. I have DDD architecture with Nuxt Layers in a monorepo:
- apps/app
- layers/cms
- layers/ecommerce
I want to have different bindings per each layer
- layers/core/wrangler.jsonc //
KV_CORE
- layers/cms/wrangler.jsonc //
D1_DB_CMS
- layers/ecommerce/wrangler.jsonc
D1_DB_ECOMMERCE
But in current implementation I have to store all bindings definitely at apps/app/wrangler.jsonc
that breaks the idea of the architecture.
Another potential option that could be even better.
I'd like to have something like in nuxt.config.ts
export default defineNuxtConfig({
modules: ['nitro-cloudflare-dev'],
nitro: {
preset: 'cloudflare-pages',
cloudflareDev: {
wrangler: {
bindings: {
kv_namespaces: [],
d1_databases: [],
// other bindings
}
}
}
},
})
It will allow to put this info per each layer like
layers/cms/nuxt.config.ts
:
// nitro -> cloudflareDev -> wrangler -> bindings
d1_databases: [{
binding: 'D1_DB_CMS',
database_name: 'cms',
database_id: process.env.D1_DB_CMS_ID,
// migrations_dir: '' // this field has to be auto-generated during merging to put the migrations dir in the end application apps/app
}]
layers/ecommerce/nuxt.config.ts
:
// nitro -> cloudflareDev -> wrangler -> bindings
d1_databases: [{
binding: 'D1_DB_ECOMMERCE',
database_name: 'ecommerce',
database_id: process.env.D1_DB_ECOMMERCE_ID,
// migrations_dir: '' // this field has to be auto-generated during merging to put the migrations dir in the end application apps/app
}]
As a result, all values have to be merged to the result apps/app/wrangler.jsonc
file.