How to retrieve database credentials from drizzle.config.ts
I'm attempting to retrieve Neon database credentials dynamically from
drizzle.config.ts
, instead of saving them in a .env, by running drizzle-kit push
. The issue, both methods I tried rely on top-level await and throw Top-level await is currently not supported with the "cjs" output format
exception.
1. @aws-sdk/client-ssm
example:
OR
2. SST Secrets https://docs.sst.dev/config#top-level-await
Is there a way to accomplish this from within drizzle.config.ts
?
I'm using "drizzle-kit": "^0.20.1"
and "drizzle-orm": "^0.29.0"
Config | SST
Working with environment variables and secrets in SST.
5 Replies
Maybe try using an IIFE:
Thank you, I tried this but unfortunately it doesn't resolve in-time before
defineConfig
ends up running
npm
synchronized-promise
Turn ES6 Promise into synchronize function call, a simple wrapper of deasync package. Latest version: 0.3.1, last published: 4 years ago. Start using synchronized-promise in your project by running
npm i synchronized-promise
. There are 27 other projects in the npm registry using synchronized-promise.I've also tried wrapping the whole config in an async function but it'll export a promise that way so seems like there is no other solution other than using this/reimplementing it yourself
thanks for looking into it!