Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
@types/convict
Advanced tools
TypeScript definitions for convict
@types/convict provides TypeScript type definitions for the convict configuration management library. Convict helps manage configuration files in Node.js applications by defining a schema for configuration, validating it, and providing default values.
Define Configuration Schema
This feature allows you to define a schema for your configuration, specifying the format, default values, and environment variables.
const convict = require('convict');
const config = convict({
env: {
doc: 'The application environment.',
format: ['production', 'development', 'test'],
default: 'development',
env: 'NODE_ENV'
},
port: {
doc: 'The port to bind.',
format: 'port',
default: 8080,
env: 'PORT'
}
});
Load Configuration from Files
You can load configuration values from JSON files based on the environment, making it easy to manage different configurations for different environments.
config.loadFile('./config/' + config.get('env') + '.json');
Validate Configuration
Convict can validate the configuration against the schema, ensuring that all required fields are present and have the correct format.
config.validate({ allowed: 'strict' });
Get Configuration Values
You can easily retrieve configuration values using the `get` method.
const port = config.get('port');
The 'config' package provides a similar way to manage configuration files in Node.js applications. It supports multiple configuration files for different environments and allows for hierarchical configurations. Unlike convict, it does not enforce a schema or validation.
The 'dotenv' package loads environment variables from a .env file into process.env. It is simpler than convict and does not provide schema validation or hierarchical configuration, but it is very useful for managing environment variables in development.
The 'nconf' package is a hierarchical configuration manager for Node.js. It supports multiple configuration sources such as command-line arguments, environment variables, and configuration files. Unlike convict, it does not enforce a schema but provides more flexibility in configuration sources.
npm install --save @types/convict
This package contains type definitions for convict (https://github.com/mozilla/node-convict).
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/convict.
These definitions were written by Wim Looman, Vesa Poikajärvi, Eli Young, Suntharesan Mohan, Igor Strebezhev, and Peter Somogyvari.
FAQs
TypeScript definitions for convict
We found that @types/convict demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.