Some safeties to URL handling
This commit is contained in:
parent
24e051b1e9
commit
d7cc8b2d51
|
@ -11,11 +11,14 @@ exports.initialize = function initializeSchema(schema, callback) {
|
||||||
if (schema.settings.url) {
|
if (schema.settings.url) {
|
||||||
var url = require('url');
|
var url = require('url');
|
||||||
var redisUrl = url.parse(schema.settings.url);
|
var redisUrl = url.parse(schema.settings.url);
|
||||||
var redisAuth = redisUrl.auth.split(':');
|
var redisAuth = (redisUrl.auth || '').split(':');
|
||||||
schema.settings.host = redisUrl.hostname;
|
schema.settings.host = redisUrl.hostname;
|
||||||
schema.settings.port = redisUrl.port;
|
schema.settings.port = redisUrl.port;
|
||||||
schema.settings.db = redisAuth[0];
|
|
||||||
schema.settings.password = redisAuth[1];
|
if (redisAuth.length == 2) {
|
||||||
|
schema.settings.db = redisAuth[0];
|
||||||
|
schema.settings.password = redisAuth[1];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
schema.client = redis.createClient(
|
schema.client = redis.createClient(
|
||||||
|
@ -23,7 +26,6 @@ exports.initialize = function initializeSchema(schema, callback) {
|
||||||
schema.settings.host,
|
schema.settings.host,
|
||||||
schema.settings.options
|
schema.settings.options
|
||||||
);
|
);
|
||||||
|
|
||||||
schema.client.auth(schema.settings.password);
|
schema.client.auth(schema.settings.password);
|
||||||
schema.client.on('connect', callback);
|
schema.client.on('connect', callback);
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,9 @@ function Schema(name, settings) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.settings = settings;
|
this.settings = settings;
|
||||||
|
|
||||||
|
// Disconnected by default
|
||||||
|
this.connected = false;
|
||||||
|
|
||||||
// create blank models pool
|
// create blank models pool
|
||||||
this.models = {};
|
this.models = {};
|
||||||
this.definitions = {};
|
this.definitions = {};
|
||||||
|
|
Loading…
Reference in New Issue