-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
I want to use this library in the slack deno sdk. But, slack hosts your code for you, and runs it in a sandboxed deno runtime. One of the restrictions they place is they disallow access to process.env.
If I pass in my full databaseUrl, then this library wouldn't need to go looking at process.env to find the fallbacks/default.
Can we make it so that we only access process.env when absolutely needed? It looks like we do this in not that many places, most of which look trivial to make lazy: https://github.com/search?q=repo%3Abrianc%2Fnode-postgres%20process.env&type=code
This one call site looks slightly trickier:
node-postgres/packages/pg/lib/index.js
Lines 37 to 40 in 8d493f3
| if (typeof process.env.NODE_PG_FORCE_NATIVE !== 'undefined') { | |
| module.exports = new PG(require('./native')) | |
| } else { | |
| module.exports = new PG(Client) |
Either
- we figure out how to wrap this in a try/catch (would require adding deno-specific error handling I think)
- make it possible to pass
force_nativeas an explicit config value, and only look it up from process.env if it isn't set explicitly. Then in my app code I could pass it explicitly to avoid the lookup.
Any interest in this? What's the path forward if so? Could you do the PR or would I need to?
Related: neondatabase/serverless#179