2.2.0 • Published 5 years ago
@wunderflats/configman v2.2.0
configman
Tool for defining and checking environment variables in one place.
npm install @wunderflats/configman
Usage
const envVars = ['PORT', 'HOSTNAME']
const configman = require('@wunderflats/configman')
.ensureAllSet(envVars)
http
.createServer()
.listen(configman.get('PORT'), configman.get('HOSTNAME'))
API
require('@wunderflats/configman')
const configman = require('@wunderflats/configman')
Returns an object of type Configman:
type Configman = {
ensureAllSet(environmentVariables: string[]): Configman,
get(environmentVariable: string): string
}
ensureAllSet()
configman.ensureAllSet(environmentVariables: string[]) : Configman
Checks if all environment variable are set and throws if not. Returns configman.
process.env.PORT = 1337
process.env.YAWP = undefined
configman.ensureAllSet(['PORT'])
console.log(configman.get('PORT')) // { PORT: 1337}
config = configman
.ensureAllSet(['YAWP']) // throws since `YAWP` is not set (part of `process.env`)
get()
configman.get(environmentVariable: string): string
Returns an object containing properties for all configured environment variables.
Throws if one of those variables is not set (part of process.env
) when
accessed.
process.env.PORT = 1337
process.env.YAWP = undefined
const PORT = configman
.get('PORT')
console.log(PORT) // 1337
const YAWP = configman
.get('YAWP') // throws since `YAWP` is not set (part of `process.env`)
2.2.0
5 years ago
2.1.0
5 years ago
2.0.4
8 years ago
2.0.3
8 years ago
2.0.2
8 years ago
2.0.1
8 years ago
2.0.0
8 years ago
1.0.3
8 years ago
1.0.1
8 years ago
1.0.0
8 years ago
0.1.0
8 years ago
0.0.10
8 years ago
0.0.9
8 years ago
0.0.8
8 years ago
0.0.7
8 years ago
0.0.6
8 years ago
0.0.5
8 years ago
0.0.4
8 years ago
0.0.3
8 years ago
0.0.2
8 years ago
0.0.1
8 years ago