How can you load environment variables from an API and set them into config?
See original GitHub issueFrom Romil Shah on Slack
I am not trying to set the process.env as it’s not compatible as per case. My setting variables are in form of JSON object along with nested too so It will not make sense to set in process.env as that will be similar to just key/value pair as flat level.
So I am trying to fetch the setting values from an api and setting it into a singleton constant object which can be accessible into various config files such as api.ts, sequelize.ts etc. With the previous version of actionhero this was working for me as I was loading the setting values with async request in boot.js but after upgration, with server.ts this is not working for me.
Because, all the config files are loaded first before server.ts, so I cannot set the singleton object from server.ts
What’s the process to do something async in `server.ts, set a process.env variable before the config is initialized?
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (8 by maintainers)
Top GitHub Comments
In https://github.com/actionhero/actionhero/pull/1511, I’ve changed the default import statement of Actionhero within
server.ts
to make it simpler to modify the env.Here’s an example project that shows how to modify
process.env
via an async function before importing Actionhero https://github.com/actionhero/example-with-custom-env