Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
hook (when, action, method) {
// if object is given
// iterate and call .hook()
// for each entry
if (is.object(when)) {
let hooks = when;
let keys = Object.keys(hooks);
keys.forEach(key => {
let [when, action] = key.split(':');
let method = hooks[key];
this.hook(when, action, method);
});
return;
}
// if array is given
// iterate and call .hook()
// for each item
where (key, value) {
// if object was passed instead of key-value pair
// iterate over that object and call .where(key, value)
if (is.object(key)) {
let conditions = key;
let keys = Object.keys(conditions);
keys.forEach(key => {
this.where(key, conditions[key]);
});
}
if (is.string(key)) {
// if only one argument was supplied
// save the key in this.lastKey
// for future methods, like .equals()
if (is.undefined(value)) {
this.lastKey = key;
return this;
}
Query.prototype.where = function where(key, value) {
var _this = this;
// if object was passed instead of key-value pair
// iterate over that object and call .where(key, value)
if (is.object(key)) {
(function () {
var conditions = key;
var keys = Object.keys(conditions);
keys.forEach(function (key) {
return _this.where(key, conditions[key]);
});
})();
}
if (is.string(key)) {
// if only one argument was supplied
// save the key in this.lastKey
// for future methods, like .equals()
if (is.undefined(value)) {
this.lastKey = key;
Model.prototype.set = function (key, value) {
// if object passed instead of key-value pair
// iterate and call set on each item
if (is.object(key)) {
let attrs = key;
let keys = Object.keys(attrs);
let self = this;
keys.forEach(function (key) {
self.set(key, attrs[key]);
});
return;
}
// check if the value actually changed
let previousValue = this.get(key);
if (previousValue !== value) {
constructor(options) {
this.COMMAND_CLEAN_SHUTDOWN = '#CS#';
this.options = { delimiter: '.', iface: 'eth0', debug: false, secret: 'dot' };
if (is.object(options) && is.not.array(options))
this.options = Object.assign(this.options, options);
}
.then(r => {
if (r instanceof Buffer) return r.toString();
else if (r instanceof Array || is.object(r)) return JSON.stringify(r);
else if (is.not.existy(r) || is.nan(r)) throw new Exception('invalid value');
else return r.toString();
})
.then(d => {
post(service, method, options) {
if (is.object(method)) {
options = method;
method = null;
}
return this._request('post', service, method, options);
}
this._registry.get(service).then(address => {
if (is.string(address) && is.not.empty(address) && address.includes(':')) {
let url = `http://${ address }/${ service }`;
if (is.string(method)) url += `/${ method }`;
const request = { method: httpMethod, url };
options = is.object(options) && is.not.array(options) ? options : {};
if (httpMethod === 'get' || httpMethod === 'delete')
request.params = options;
else request.data = options;
axios(request)
.then(r => {
this._logger.info(request, 'success');
resolve(r);
})
.catch(e => {
this._logger.error({ httpMethod, service, method, options }, e.message);
reject(e);
});
} else {
this._logger.error({ httpMethod, service, method, options }, 'unknown service');
reject(new Error('UNKNOWN_SERVICE'));
}
exclude (key, value) {
if (is.array(key)) {
let fields = key;
fields.forEach(key => {
this.exclude(key);
});
}
if (is.object(key)) {
let fields = key;
let keys = Object.keys(fields);
keys.forEach(key => {
this.exclude(key, fields[key]);
});
}
if (is.string(key)) {
this.options.fields[key] = value == undefined ? 0 : value;
}
return this;
}
if (usage === 'bird' && is.object(config.birdConfig)) {
var birdconf = config.birdConfig;
var server = {};
var TranspondRules = {};
server[port] = {
basePath: path.join(currentPath, birdconf.basePath)
};
TranspondRules[port] = {
targetServer: birdconf.targetServer,
ajaxOnly: birdconf.ajaxOnly
};
bird.start(server, TranspondRules, birdconf.toolsConf);
logger.info('Bird server runing at port: ' + port + '.');
}
else if (usage && is.object(config.serverConfig)) {
config.serverConfig.port = port;
connect.server(config.serverConfig);
logger.info('connect server runing at port: ' + port + '.');
}
}