diff --git a/config.js b/config.js index dee3e71..1257e1c 100644 --- a/config.js +++ b/config.js @@ -10,7 +10,10 @@ var config = { adress: 'ws://127.0.0.1:6680/mopidy/ws/', defaultPlaylist: 'Party 2015' }, - db: 'mongodb://localhost/livid', + db: { + queuePath: 'queue.db', + historyPath: 'history.db' + }, user: { voteDelay: 60 * 1000 } diff --git a/server.js b/server.js index f75ecf4..954ead5 100644 --- a/server.js +++ b/server.js @@ -1,34 +1,37 @@ var Hapi = require('hapi'), server = new Hapi.Server(), - mongoose = require('mongoose'), + nedb = require('nedb'), glob = require('glob'); +// Load configfile var config = require('./config.js'); -server.connection({ port: config.main.port }); -mongoose.connect(config.db); -var db = mongoose.connection; -db.on('error', function () { - throw new Error('unable to connect to database at ' + config.db); -}); +// Load database +var db = {}; +db.queue = new nedb({ filename: config.db.queuePath, autoload: true }); +db.history = new nedb({ filename: config.db.historyPath, autoload: true }); + -var models = glob.sync('./models/*.js'); -models.forEach(function (model) { - require(model); -}); -if (process.env.ENV !== 'prod') { - mongoose.connection.collections['queuetracks'].drop( function(err) { - console.log('old queue tracks dropped'); - }); -} +// var models = glob.sync('./models/*.js'); +// models.forEach(function (model) { +// require(model); +// }); +// if (process.env.ENV !== 'prod') { +// mongoose.connection.collections['queuetracks'].drop( function(err) { +// console.log('old queue tracks dropped'); +// }); +// } + +/* var socket = require('./modules/socketLogic.js'); socket.init(server.listener); var mopidy = require('./modules/mopidyCom.js'); mopidy.init(); +*/ server.views({ engines: { @@ -75,6 +78,9 @@ server.route({ }); +// Configure hapi server +server.connection({ port: config.main.port }); + server.start(function () { console.log('Server running at:', server.info.uri); });