default.js v0.0.3
default.js
simple file-based default configuration manager for using docker's data volume
Usage
Import
var defaultjs = require('default.js');
Initialize
new defaultjs(defaultConfigFilePath, userConfigFilePath);
var serverConfigManager = new defaultjs(
'./config/defaultConfig.json',
'./config/userConfig/serverConfig.json');
read configurations
var serverConfig = serverConfigManager.readConfigsSync();
console.log(serverConfig.somefield);
Methods
- initSync()
- init()
- copyDefaultSync()
- copyDefault()
- readConfigsSync()
- readConfigs()
- setConfigSync()
- setConfig()
- setConfigsSync()
- setConfigs()
initSync()
initSync();
validate current configuration file
and initialize new configuration
init()
init(callback);
validate current configuration file
and initialize new configuration
callback(error, data)
copyDefaultSync()
copyDefaultSync();
copy defaultConfigFile to userConfigFile
copyDefault()
copyDefault(callback);
copy defaultConfigFile to userConfigFile
callback(error, data)
readConfigsSync()
readConfigsSync();
read configuration from userConfigFile
return : configuration json
Example:
readConfigs()
readConfigs(callback)
read configuration from userConfigFile
- callback(error, data)
- parameters
- error
- data : configs json
- parameters
setConfigSync()
setConfigSync(key, value);
set key-value configuration to userConfigFile
setConfig()
setConfig(key, value, callback));
set key-value configuration to userConfigFile
callback(error)
Example :
setConfigsSync()
setConfigsSync(configs);
set json configuration set to userConfigFile
setConfigs()
setConfigs(configs, callback);
set json configuration set to userConfigFile
callback(error)
Example :
make a user-config file from the default-configuration file
Linkage with Docker
docker run -ti (imageName) -v CustomConfigurationFilePath(host):userConfigPath(in the container)
License
Copyright 2016 Noizbuster \noizbuster@noizbuster.com\
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at