
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
@nypl/node-utils
Advanced tools
This module contains common Node utilities for NYPL components.
npm i --save @nypl/node-utils
To load and decrypt config:
loadConfig(envName) {Promise<object>}
envName {string} - Indicates what file to read config from (i.e. ./config/{envName}.yaml)As a convenience, after initialization (via above) you may use this function to retrieve select config syncronously:
getConfig() {object} - Get previously retrieved config syncronously.
const { config } = require('@nypl/node-utils')
// or import { config } from '@nypl/node-utils'
const init = async () => {
// Destructure the variables you want from the initial loadConfig call:
const { LOG_LEVEL } = await config.loadConfig()
// Subsequent loadConfig calls use cached config:
const { OTHER_VAR } = await config.loadConfig()
...
// As a convenience, getConfig provides sync access to all config after initial load:
const { CLIENT_ID: id, CLIENT_SECRET: secret } = config.getConfig()
const client = SomeClient({ id, secret })
}
Config files must be structured like this:
PLAINTEXT_VARIABLES:
one: ...
two: ...
ENCRYPTED_VARIABLES:
three: ...
If you encounter KmsError: CredentialsProviderError during decrypt command, you may need to indicate the AWS profile to use by setting, for example, AWS_PROFILE=nypl-digital-dev.
To print log entries:
logger.(error|warning|info|debug)(message, obj?) - Print entry to log
message {string} - The message to printobj {object} - An optional plainobject with properties to include in the log entryThe logger comes pre-initialized, but you may want to re-initialize it if some env vars changed:
logger.initialize(config?)
config {object} - Optional plainobject defining json {bool} and/or level {string}To simply change the log level:
logger.setLevel(level) - Convenience for setting log level directly
level {string} - Set level to 'error', 'warn', 'info', 'debug'const { logger, config } = require('@nypl/node-utils')
// or import { logger, config } from '@nypl/node-utils'
const init = () => {
await config.loadConfig()
logger.initialize()
logger.info('Something happened', { id: '...' })
}
FAQs
A collection of common utilities for NYPL Node apps
We found that @nypl/node-utils demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 13 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.