Support env variables in DB config
Describe the feature
export default defineNitroConfig({
database: {
default: {
connector: 'sqlite',
options: { name: 'db' }
},
users: {
connector: 'postgresql',
url: 'postgresql://username:password@hostname:port/database_name'
}
}
})
Currently we define pgsql connection information in a configuration file. I think it's dangerous to expose connection information in config files
Additional information
- [ ] Would you be willing to help implement this feature?
Is there any progress on this? Was experimenting with using db0 with Nitro and this feels very awkward for configuration. Maybe just a set of standard env vars we can override.. e.g., NITRO_DB_DEFAULT_NAME=db or NITRO_DB_USERS_URL
Yes, we should tackle this. Main thing is that since connector options are in total control of db0 connectors, we might need to expose this feature for db0 first. feel free to raise an issue there to track.
Maybe this could be somehow hooked up to useRuntimeConfig?