Skip to content

Conversation

@nonword
Copy link
Member

@nonword nonword commented Nov 10, 2025

Initial implementation of common Node config loader and logger

https://newyorkpubliclibrary.atlassian.net/browse/SCC-4788

Copy link

@charmingduchess charmingduchess left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple small notes. Would you also be open to figuring out how to publish this as both CJS and ESM compatible?

lib/kms.js Outdated
try {
response = await client.send(command)
} catch (e) {
throw new KmsError(`${e.name} during decrypt command`, { cause: e })

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we put the recommendation to use AWS_PROFILE=nypl-digital-dev in this error message? these errors will be logged in other repos, and the readme recommendation won't be easily accessible

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added code to identify auth error and suggest using the env var.

lib/config.js Outdated
*
* @return {Promise<object>} An object with all decrypted config
* **/
const loadConfig = (envName = process.env.ENVIRONMENT || 'production') => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should not have a default here. I can see cases like running a bulk index script where a bad path could cause a premature update to production data.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. Env name is now required.

@nonword
Copy link
Member Author

nonword commented Nov 12, 2025

CJS and ESM compatible?

Open to that. At a glance it seems that might pair well with doing a basic conversion to typescript, since it looks like dual support may require distinct builds anyway. I'll look into it, but it might need to be a separate effort.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants