
Security News
Package Maintainers Call for Improvements to GitHub’s New npm Security Plan
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
@6river/configr
Advanced tools
Configr is a library that provides a set of TypeScript decorators to inject configuration params into class properties.
Configr is a library that provides a set of TypeScript decorators to inject configuration params into class properties.
// Given is expected configuration received from some remote service or
// is read from the file or....
const config = {
env: 'debug',
log: {
level: 'DEBUG',
format: '%h %l %u %t \"%r\" %>s %b'
}
};
// Basic Usage
@Config()
class Foo {
@ConfigParam()
readonly env: string;
// by default property name is used as a path to access config parameter,
// but path can elso be specified:
@ConfigParam('log.level')
readonly logLevel: string;
// with default specified
@ConfigParam('log.format')
readonly logFormat: string = ''%h %l %u';
}
// The root path can be specified on class level
@Config({root: 'log'})
class Logger {
@ConfigParam()
level string;
@ConfigParam()
format string;
}
// suppose we have configuration fetched from remote service
function loadConfig() {
return fetch('http://example.com/config.json')
.then(function(response) {
return response.json();
})
.then(function(cfg) {
// Apply loaded config to annotated properties.
// This method should be calledonce.
// It's not forbidden to call it many times but
// all subsequent calls just have no effect.
return configResolve(cfg);
});
}
// as soon as config is loaded and resolved it's safe to use
// our objects that rely on its parameters:
async function useit() {
await loadConfig(cfg);
const foo = new Foo();
const log = new Logger();
}
Parser can be specified as an additional option for @ConfigParam
decorator:
const cfg = {
logLevels: ['ERROR', 'INFO', 'DEBUG']
};
class LogLevel {
constructor(public label: string) {}
}
function parseLogLevels(levels: string[]): LogLevel[] {
return labels.map((level) => new LogLevel(level));
}
@Config()
class Foo {
@ConfigParam({parser: parseLogLevels})
readonly logLevels: LogLevel[];
}
FAQs
Configr is a library that provides a set of TypeScript decorators to inject configuration params into class properties.
The npm package @6river/configr receives a total of 32 weekly downloads. As such, @6river/configr popularity was classified as not popular.
We found that @6river/configr demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 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
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.