0.7.1 • Published 6 years ago
twconf v0.7.1
twconf
Attention: this is beta version. Use it in production with caution.
NodeJS module for strictly configuration from environment variables.
import TwConf from 'twconf';
const conf = new TwConf({
'database.mongodb.uri': {
comment: 'MongoDB connection URI',
simple: 'mongodb://localhost/test1',
type: new TwConf.Types.StringType({ allowed: [ /mongodb\:/ ] }),
required: true,
preTransforms: [ /* function(value: string).<any> */ ],
postTransforms: [ /* function(value: any).<any> */ ],
validators: [
value => value !== 'mongodb://localhost/test',
],
},
});
conf.get('database.mongodb.hostname'); // get config value
conf.toString(); // get JSON version of config
String-defined type
new TwConf({
nodeEnv: {
type: 'string',
allowed: ['development', 'test', 'production'],
default: 'development',
},
});
Object-defined type
new TwConf({
nodeEnv: {
type: {
name: 'string',
allowed: ['development', 'test', 'production'],
},
default: 'development',
},
});
Available types:
- Boolean
- no options
- Float
- min: number - minimal value for field
- max: number - maximum value for field
- precision: number - count of number after dot
- Int
- min: number - minimal value for field
- max: number - maximum value for field
- IpAddress
- version: number (4|6) - IP address standard version
- Number
- min: number - minimal value for field
- max: number - maximum value for field
- String
- minLength: number - mininal length of string
- maxLength: number - maximum length of string
- allowed: Array.<(string|RegExp)> - allowed values of this field
Roadmap
- Add a typification by string
- Add a typification by object with options and name
- Increase the percentage of code coverage
- Fix incorrect throwing invalid values
- Add typescript definitions
- Migrate tests to Ava
0.7.1
6 years ago
0.7.0
6 years ago
0.6.1
7 years ago
0.6.0
7 years ago
0.5.0
7 years ago
0.4.6
7 years ago
0.4.5
7 years ago
0.4.4
7 years ago
0.4.3
7 years ago
0.4.2
7 years ago
0.4.1
7 years ago
0.4.0
7 years ago
0.3.5
7 years ago
0.3.4
7 years ago
0.3.3
7 years ago
0.3.2
7 years ago
0.3.1
7 years ago
0.3.0
7 years ago
0.2.5
7 years ago
0.2.4
7 years ago
0.2.3
7 years ago
0.2.2
7 years ago
0.2.1
7 years ago
0.2.0
7 years ago
0.1.0
7 years ago
1.0.0
7 years ago