thdxr
06/15/2021, 3:05 PMSimon Reilly
06/15/2021, 3:13 PMthdxr
06/15/2021, 3:30 PMthdxr
06/15/2021, 3:30 PMSimon Reilly
06/15/2021, 3:32 PMJay
Dennis Dang
06/15/2021, 11:34 PMDennis Dang
06/15/2021, 11:34 PMthdxr
06/16/2021, 1:05 AMthdxr
06/16/2021, 1:06 AMthdxr
06/16/2021, 3:43 AMthdxr
06/16/2021, 3:43 AMimport { SecretsManager } from "aws-sdk"
import deasync from "deasync"
const sm = new SecretsManager()
const DefaultConfig = {
BUCKET_RENDER: "",
URL_REST: "<https://localhost:1313>",
URL_WEB: "<https://localhost:8080>",
MAIL_ADAPTER: "console",
SENDGRID_API_KEY: "",
}
type ConfigType = typeof DefaultConfig
export const Config = {} as ConfigType
function load(cb: any) {
sm.getSecretValue(
{
SecretId: "dev/node",
},
(_err, response) => {
const config = JSON.parse(response.SecretString as string)
for (let [key, value] of Object.entries(DefaultConfig)) {
Config[key as keyof ConfigType] =
process.env[key] || config[key] || value
}
console.log(Config)
cb()
}
)
}
deasync(load)()
thdxr
06/16/2021, 3:44 AMSimon Reilly
06/16/2021, 6:35 AMconst resp = await ssm.getSecretValue({
SecretId: 'dev/node'
}).promise()
I think alot of the aws-sdk methods support returning the promisethdxr
06/16/2021, 12:47 PMthdxr
06/16/2021, 12:54 PMSimon Reilly
06/16/2021, 12:55 PMthdxr
06/16/2021, 1:53 PMesm
which means setting type: "module"
to true. This makes it so require statements cannot be used.
As part of the deploy process a script gets generated at .build/run.js
which does use require statements and is unable to run. Possibly can fix it by renaming it to .build/run.cjs
Frank
thdxr
06/16/2021, 10:39 PM