Reputation: 1
I´m using gcp secrets manager (cloud service), and in my code I use the package @google-cloud/secret-manager to get them.
like this:
const [version] = await client.accessSecretVersion({
name: name_here
})
const responsePayload = Dotenv.parse(version?.payload?.data.toString());
await this.setDatabase(responsePayload)
Well after that I use this functions setDatabase to put this payload on a config object, that I created more above in the code.
The problems is that, in other scripts, is imported this config object before the load of the setDatabase() in order to connect knex with dabatase, but in time of load the imports the config object is still blank.
Maybe somes pics will clarify:
console.log of config.database before loaded
console.log of config in other moment after loaded
Anyone has a tip for it?
Upvotes: 0
Views: 97
Reputation: 375
well I would put all of your initialization tasks into one place, and do them in the sequence you want, so there isn't a cross dependency between common includes. It will give you a cleaner result when your init code is isolated like this.
Upvotes: 1