Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
, 'test no password confirmation': function () {
var p = utils.mixin({}, _params),
user;
p.confirmPassword = 'fdsa';
var user = User.create(p);
// Error message should be customized
assert.ok(typeof user.errors.password != 'undefined');
}
render() {
// Attach the formGroupId to allow automatic focus when a label is clicked
const childrenWithProps = React.Children.map(this.props.children,
child => {
if (React.isValidElement(child) && isFunc(child.type)) {
return React.cloneElement(child, { formGroupId: this.formGroupId });
}
return child;
}
);
return <div>{childrenWithProps}</div>;
}
}
this.name = 'mysql';
this.type = 'sql';
this.config = _baseConfig;
this.client = null;
this.generator = generator.getGeneratorForAdapter(this);
utils.mixin(this.config, opts);
this.init.apply(this, arguments);
};
Adapter.prototype = new BaseAdapter();
Adapter.prototype.constructor = Adapter;
utils.mixin(Adapter.prototype, new (function () {
this.COLUMN_NAME_DELIMITER = '`';
// Pseudo-private -- utility and for testing only
this._getClient = function () {
return mysql.createConnection(this.config);
};
this._handleDisconnect = function (callback) {
var self = this;
setTimeout(function() {
self.client = self._getClient();
self.connect(callback);
}, Math.pow(3, reconnectAttempts) * 1000);
reconnectAttempts++;
};
var Adapter = function (options) {
var opts = options || {}
, config;
this.name = 'level';
this.config = this.loadConfig(_baseConfig, opts);
this.client = null;
this.db = null;
this.init.apply(this, arguments);
};
Adapter.prototype = new BaseAdapter();
Adapter.prototype.constructor = Adapter;
utils.mixin(Adapter.prototype, new (function () {
this._initLevel = function (config) {
var db
, sublevel;
db = level(config.db, {keyEncoding: 'utf8', valueEncoding: 'json'});
if (config.sublevel) {
// Load sublevel, and set db
sublevel = utils.file.requireLocal('level-sublevel');
db = sublevel(db);
db = db.sublevel(config.sublevel);
}
this.db = db;
};
window.geddy = {}
// require model
geddy.model = require('model');
// mix utilities into geddy
var utilities = require('utilities');
utilities.mixin(geddy, utilities);
// require socket.io-client
geddy.io = require('socket.io-client');
geddy.socket = geddy.io.connect('/');
geddy.io.listenForModelEvents = function (model) {
var events = [
'save'
, 'update'
, 'remove'
];
for (var e in events) {
(function (event) {
geddy.socket.on(model.modelName + ':' + event, function (data) {
var instance;
var geddy = global.geddy || {}
, EventEmitter = require('events').EventEmitter
, utils = require('utilities')
, pkg = require('../package');
// Set the One True Geddy Global
global.geddy = geddy;
utils.enhance(geddy, new EventEmitter());
utils.mixin(geddy, {version: pkg.version});
utils.mixin(geddy, utils);
utils.mixin(geddy, new (function () {
var _started = false
, _master
, _worker
this.start = function (options) {
var opts = options || {}
, App
, app
, worker
, config = require('./config')
, c = config.readConfig(opts);
geddy.config = c;
App = require('./app').App;
query._sqlMetadata = this._getSqlMetadata(query);
sql = this._createSelectStatementWithConditions(query);
processor = new EventedQueryProcessor(query, cb);
setTimeout(function () {
processor.process(self[fetch](sql));
}, 0);
return processor;
}
}
};
})());
// Mix in basic conversion methods
utils.mixin(Adapter.prototype, converter);
// Mix in query transformer methods
utils.mixin(Adapter.prototype, sqlTransformer);
EventedQueryProcessor = function (query, callback) {
this._source = null;
this._allItems = [];
this._allItemsHash = {};
this._lastMainModel = null;
this._rowEventName = query.model.getAdapter().name == 'mysql' ?
'result' : 'row';
this.models = {};
this.setQuery(query);
this.callback = callback;
};
var _readConfig = function () {
var opts = this.opts
, dir = process.cwd()
, baseConfig = require(dir + '/config/environment.js')
, envConfig;
this.config.environment = opts.environment || this.config.environment;
envConfig = require(dir + '/config/' + this.config.environment + '.js');
// Start with a blank slate, mix everything in
utils.mixin(this.config, baseConfig);
utils.mixin(this.config, envConfig);
utils.mixin(this.config, opts);
if (this.config.workers < 2) {
this.config.rotateWorkers = false;
}
}
/**
, 'setting default values': function () {
var p = utils.mixin({}, _params),
user;
delete p.firstName;
user = User.create(p);
assert.equal('Zerp', user.firstName);
}
app.init(_worker.config, function () {
geddy.emit('initialized');
utils.mixin(geddy, app);
_worker.startServer(function () {
geddy.emit('started');
});
});
});