Config

Config

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

Author:
Source:

Members

(static) base :String

Default base path

Type:
  • String
Source:

(static) config :Object

Default config value

Type:
  • Object
Default Value:
  • {}
Source:

(static) env :String

Default env value

Type:
  • String
Default Value:
  • development
Source:

(static) logger :Instance

Default logger instance. can be override by set function

Type:
  • Instance
Source:

(static) prefix :String

Prefix to use in case of multiple configuration

Type:
  • String
Source:

(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
Default Value:
  • false
Source:

(static) this.schema

Current schema to use for validation

Properties:
Name Type Description
schema Object
Default Value:
  • {}
Source:

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

Source:

autoEnableValidators(items) → {Boolean}

Auto enable validators schema for given list

Parameters:
Name Type Description
items Array

array of items to enable

Source:
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

Source:
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

Source:
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

Source:
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

Source:
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

Source:
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

Source:
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

Source:
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

Source:
Returns:

needed data

Type
Mixed

getConfig() → {Object}

Retreive default configuration

Source:
Returns:

loaded object

Type
Object

load() → {Object}

Default load function, load data from all.js constant file

Source:
Returns:

return current promise

Type
Object

loadPassport() → {Object}

Load password schema for current configuration

Source:
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

Source:
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

Source:
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

Source:
Returns:

true if all is ok false otherwise

Type
Boolean