new Config()
Yocto config manager. Manage your configuration file (all / common / env & specific file)
Config file has priority. And priority is defined like a php ini system.
(Other file).json
< all.json
< common.json
< development.json
< stagging.json
< production.json
All specific data must be configured on a each correct file.
all.json : contains general data common.json : must contains all common data between each env development.json : must contains development data for development environnement staging.json : must contains stagging data for staging environnement production.json : must contains production data for production environnement
This Module use some security format rules based on Lusca NPM module : https://www.npmjs.com/package/lusca
- Cross Site Request Forgery (CSRF) headers : https://www.owasp.org/index.php/Cross-Site_Request_Forgery_(CSRF)
- Content Security Policy (CSP) headers : https://www.owasp.org/index.php/Content_Security_Policy
- MDN CSP usage : https://developer.mozilla.org/en-US/docs/Web/Security/CSP/Using_Content_Security_Policy
- X-FRAME-OPTIONS : https://www.owasp.org/index.php/Clickjacking
- Platform for Privacy Preferences Project (P3P) headers : http://support.microsoft.com/kb/290333
- HTTP Strict Transport Security (HSTS & Chrome HSTS preload) : https://www.owasp.org/index.php/HTTP_Strict_Transport_Security & https://hstspreload.appspot.com/
- XssProtection : http://blogs.msdn.com/b/ie/archive/2008/07/02/ie8-security-part-iv-the-xss-filter.aspx
Members
(static) base :String
Default base path
Type:
- String
(static) config :Object
Default config value
Type:
- Object
(static) env :String
Default env value
Type:
- String
(static) logger :Instance
Default logger instance. can be override by set function
Type:
- Instance
(static) prefix :String
Prefix to use in case of multiple configuration
Type:
- String
(static) schema :Object
Default schema validation for config validator
Type:
- Object
- Default Value:
- { express : schema.getExpress(), mongoose : schema.getMongoose(), passportJs : schema.getPassportJs(), render : schema.getRender(), router : schema.getRouter() }
- Source:
(static) state :Boolean
Default state value, true if config state is or false otherwise
Type:
- Boolean
(static) this.schema
Current schema to use for validation
Properties:
Name | Type | Description |
---|---|---|
schema |
Object |
Methods
addCustomSchema(name, value, enable, complete)
Add a custom schema on config
Parameters:
Name | Type | Description |
---|---|---|
name |
String | config name to add in schema |
value |
Object | config value to add in schema |
enable |
Boolean | true if we need to add auto enable of config |
complete |
Boolean | true if we need to add new config after existing |
autoEnableValidators(items) → {Boolean}
Auto enable validators schema for given list
Parameters:
Name | Type | Description |
---|---|---|
items |
Array | array of items to enable |
Returns:
true if all is ok false otherwise
- Type
- Boolean
enableExpress(complete) → {Boolean}
Enable Express config
Parameters:
Name | Type | Description |
---|---|---|
complete |
Boolean | true if we need to append new config after existing |
Returns:
true if all is ok falser otherwise
- Type
- Boolean
enableMongoose(complete) → {Boolean}
Enable Mongoose config
Parameters:
Name | Type | Description |
---|---|---|
complete |
Boolean | true if we need to append new config after existing |
Returns:
true if all is ok falser otherwise
- Type
- Boolean
enablePassportJs(complete) → {Boolean}
Enable PassportJs config
Parameters:
Name | Type | Description |
---|---|---|
complete |
Boolean | true if we need to append new config after existing |
Returns:
true if all is ok falser otherwise
- Type
- Boolean
enableRender(complete) → {Boolean}
Enable Yocto Render config
Parameters:
Name | Type | Description |
---|---|---|
complete |
Boolean | true if we need to append new config after existing |
Returns:
true if all is ok falser otherwise
- Type
- Boolean
enableRouter(complete) → {Boolean}
Enable Yocto Router config
Parameters:
Name | Type | Description |
---|---|---|
complete |
Boolean | true if we need to append new config after existing |
Returns:
true if all is ok falser otherwise
- Type
- Boolean
enableSchema(name, complete) → {Boolean}
Enable Specific schema config
Parameters:
Name | Type | Description |
---|---|---|
name |
String | default name to find in schema |
complete |
Boolean | true if we need to add new config after existing |
Returns:
true if all is ok falser otherwise
- Type
- Boolean
find(name, complete) → {Boolean}
Default find function, retreive a config from given name
Parameters:
Name | Type | Description |
---|---|---|
name |
String | wanted config |
complete |
String | true if we need to complete existing config with new |
Returns:
true if all is ok falser otherwise
- Type
- Boolean
get(name) → {Mixed}
Return correct property from given name
Parameters:
Name | Type | Description |
---|---|---|
name |
String | the property name |
Returns:
needed data
- Type
- Mixed
getConfig() → {Object}
Retreive default configuration
Returns:
loaded object
- Type
- Object
load() → {Object}
Default load function, load data from all.js constant file
Returns:
return current promise
- Type
- Object
loadPassport() → {Object}
Load password schema for current configuration
Returns:
return current promise
- Type
- Object
reload(base) → {Boolean}
Reload config from path
Parameters:
Name | Type | Description |
---|---|---|
base |
String | if base exists and is valid reassign base and reload |
Returns:
true if load succeed false otherwise
- Type
- Boolean
set(name, value) → {Boolean}
Default set function, a value to a specific params
Parameters:
Name | Type | Description |
---|---|---|
name |
String | current name to use |
value |
String | current value to assign on params name |
Returns:
true if all is ok false otherwise
- Type
- Boolean
setConfigPath(path) → {Boolean}
Set config path
Parameters:
Name | Type | Description |
---|---|---|
path |
String | default path to use |
Returns:
true if all is ok false otherwise
- Type
- Boolean