Describe the feature
Currently database connector options are embedded into the build output. It means value such as database credentials may be bundled.
We need a way to get the database config dynamically at runtime. Nitro now supports runtime config so we can get a method for free.
const config = {
url: useRuntimeConfig().database.url || bundledOptions.url
}
Inspired by env expansion, we also have a more flexible solution:
export default defineConfig({
database: {
default: {
connector: "postgresql",
options: {
url: "{{DATABASE_URL}}",
},
},
},
});
For non-string options such as port, we may need type metadata from db0 since environment variables are resolved as strings and we need to convert to number.
Should we consider only converting the required keys? Perhaps we also need db0 to provide the list of keys.
Additional information
Describe the feature
Currently database connector options are embedded into the build output. It means value such as database credentials may be bundled.
We need a way to get the database config dynamically at runtime. Nitro now supports runtime config so we can get a method for free.
Inspired by env expansion, we also have a more flexible solution:
For non-string options such as port, we may need type metadata from db0 since environment variables are resolved as strings and we need to convert to number.
Should we consider only converting the required keys? Perhaps we also need db0 to provide the list of keys.
Additional information