Skip to content

Commit

Permalink
Switched everything to nconf & cleaned up some files
Browse files Browse the repository at this point in the history
Signed-off-by: Henry Gressmann <[email protected]>
  • Loading branch information
explodingcamera committed Jul 10, 2016
1 parent a9f8758 commit d9e2bb4
Show file tree
Hide file tree
Showing 14 changed files with 914 additions and 746 deletions.
12 changes: 6 additions & 6 deletions socketserver/SC.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// API reference: https://developers.soundcloud.com/docs/api/reference#track

var https = require('https');
var util = require('util');
var log = new (require('basic-logger'))({showTimestamp: true, prefix: "SC"});
var querystring = require('querystring');
var config = require('../serverconfig');
var key = config.apis.SC.key;
const https = require('https');
const util = require('util');
const log = new (require('basic-logger'))({showTimestamp: true, prefix: "SC"});
const querystring = require('querystring');
const nconf = require('nconf');
const key = nconf.get('apis:SC:key');

var SC = function(){
};
Expand Down
6 changes: 3 additions & 3 deletions socketserver/YT.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ var util = require('util');
var log = new (require('basic-logger'))({showTimestamp: true, prefix: "YT"});
var querystring = require('querystring');
var Duration = require("durationjs");
var config = require('../serverconfig');
var key = key = config.apis.YT.key;
const nconf = require('nconf');
const key = nconf.get('apis:YT:key');

https.globalAgent.keepAlive = true;
https.globalAgent.keepAliveMsecs = 60e3;
Expand Down Expand Up @@ -146,7 +146,7 @@ YT.prototype.search = function(query, callback){
key: key
};

if (config.apis.YT.restrictSearchToMusic)
if (nconf.get('apis:YT:restrictSearchToMusic'))
inObj.videoCategoryId = 10; // This is restricting the search to things categorized as music

var url = "https://www.googleapis.com/youtube/v3/search?" + querystring.stringify(inObj);
Expand Down
15 changes: 9 additions & 6 deletions socketserver/database.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
var config = require('../serverconfig');
const nconf = require('nconf');

function Database(){
config.db.dbType = config.db.dbType.toLowerCase() || 'level';

switch(config.db.dbType){
function Database() {
nconf.defaults({
'db:dbType': 'level'
});
switch (nconf.get('db:dbType')) {
case 'level':
return require('./db_level');
case 'mysql':
return require('./db_mysql');
case 'mongo':
return require('./db_mongo');
default:
return require('./db_level');
}
}

module.exports = new Database();
module.exports = new Database();
10 changes: 5 additions & 5 deletions socketserver/database_util.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
var Hash = require('./hash');
const Hash = require('./hash');

function DBUtils(){}
function DBUtils() {}

DBUtils.prototype.makePass = function(inPass, salt) {
DBUtils.prototype.makePass = function (inPass, salt) {
return Hash.md5(('' + inPass) + (salt || '')).toString();
};

DBUtils.prototype.validateEmail = function(email) {
DBUtils.prototype.validateEmail = function (email) {
return /^.+@.+\..+$/.test(email);
};

DBUtils.prototype.validateUsername = function(un) {
DBUtils.prototype.validateUsername = function (un) {
return /^[a-z0-9_-]{3,20}$/i.test(un);
};

Expand Down
Loading

0 comments on commit d9e2bb4

Please sign in to comment.