
Security News
Feross on TBPN: How North Korea Hijacked Axios
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.
@solid-soda/config
Advanced tools
Provides several classes to help you find, load, combine, autofill and validate configuration values of any kind.
Provides several classes to help you find, load, combine, autofill and validate configuration values of any kind.
Why this library:
process.env) in an appyarn add @solid-soda/config
In example app we want to use DotEnvConfiguration in dev environment and EnvConfiguraton in production. Just create a simple factory function:
import { DotEnvConfiguration, EnvConfiguraton } from '@solid-soda/config'
function isDev() {
return process.env.NODE_ENV === 'development'
}
export const getConfig = () => {
if (isDev()) {
return new DotEnvConfiguration('../.env')
}
return new EnvConfiguraton()
}
That is all. We can use getConfig in any place of our application, or pass the result to DI container, etc.
import { getConfig } from './config'
const secret = getConfig()
.get('APP_SECRET', 'DefaultSecret')
Every configuration implements Configuration interface.
@solid-soda/configuses nanoption for nullable values
import { Option } from 'nanoption'
interface Configuration {
get(key: string): Option<string>
getString(key: string): Option<string>
getNumber(key: string): Option<number>
getBoolean(key: string): Option<boolean>
getDate(key: string): Option<Date>
getOrElse(key: string, or: string): string
getStringOrElse(key: string, or: string): string
getNumberOrElse(key: string, or: number): number
getBooleanOrElse(key: string, or: boolean): boolean
getDateOrElse(key: string, or: Date): Date
getOrThrow(key: string): string
getStringOrThrow(key: string): string
getNumberOrThrow(key: string): number
getBooleanOrThrow(key: string): boolean
getDateOrThrow(key: string): Date
isDev(): boolean
isProd(): boolean
}
Method *OrThrow throws ParameterNotFound exception, if a value for the provided key is empty.
Library provides classes for comfortable loading of configs from different sources.
uses .env file to load configuration. Built over great dotenv lib.
Example:
import { DotEnvConfiguration } from '@solid-soda/config'
const config = new DotEnvConfiguration('./configs/.env')
uses process.env to load configuration.
Example:
import { EnvConfiguration } from '@solid-soda/config'
const config = new EnvConfiguration()
uses plain object as configuration source.
import { ExternalConfiguration } from '@solid-soda/config'
const config = new ExternalConfiguration({
apiToken: 'jkfdshfk323.fjkhdksf.aodsa34',
applySecurity: true,
})
can accept any file as configuration. You must pass fileParse as second argument to parse file.
import { FileConfiguration, jsonParse } from '@solid-soda/config'
const config = new FileConfiguration('./configs/params.json', jsonParse)
jsonParseAlso you can create the custom parser. It must be a function (file: stirng) => ConfigDict, where ConfigDict is object with string keys and string or undefined values.
Of course, you can create the custom Configuration. Just implement Configuration interface and use it.
Also, you can extend helper class AbstractConfiguration and implement only get and isDev methods.
The following configuration has no values and always returns empty Option.
import { AbstractConfiguration } from '@solid-soda/config'
class NeverConfiguration extends AbstractConfiguration {
public get = (key: string) => Option.of(null)
public isDev = () => true
}
Work in progress
Work in progress
Work in progress
FAQs
[](https://github.com/solid-soda/scripts)
The npm package @solid-soda/config receives a total of 16 weekly downloads. As such, @solid-soda/config popularity was classified as not popular.
We found that @solid-soda/config demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 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
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.

Security News
OpenSSF has issued a high-severity advisory warning open source developers of an active Slack-based campaign using impersonation to deliver malware.

Research
/Security News
Malicious packages published to npm, PyPI, Go Modules, crates.io, and Packagist impersonate developer tooling to fetch staged malware, steal credentials and wallets, and enable remote access.