From 280cb84240acf2af2bd9a28879a3f929231f474b Mon Sep 17 00:00:00 2001 From: Jonathan Spratley Date: Sun, 14 Dec 2014 17:44:45 -0800 Subject: [PATCH] sync --- routes/cms-routes.js | 26 ++++++++++++++++++++++++++ routes/rest.js | 6 ++---- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/routes/cms-routes.js b/routes/cms-routes.js index 1946918..f802315 100644 --- a/routes/cms-routes.js +++ b/routes/cms-routes.js @@ -6,6 +6,30 @@ module.exports.mount = function (config, app) { //Connect to database mongoose.connect(config.mongodb); + // CONNECTION EVENTS +// When successfully connected + mongoose.connection.on('connected', function () { + console.log('Mongoose default connection open to ' + dbURI); + }); + +// If the connection throws an error + mongoose.connection.on('error',function (err) { + console.log('Mongoose default connection error: ' + err); + }); + +// When the connection is disconnected + mongoose.connection.on('disconnected', function () { + console.log('Mongoose default connection disconnected'); + }); + +// If the Node process ends, close the Mongoose connection + process.on('SIGINT', function() { + mongoose.connection.close(function () { + console.log('Mongoose default connection disconnected through app termination'); + process.exit(0); + }); + }); + var server = http.createServer(app); require( './cms-auth' )( config, app ); @@ -16,6 +40,8 @@ module.exports.mount = function (config, app) { require( './cms-sockets' )( config, server ); require( './cms-server' )( config, app ); + + return server.listen(config.port || process.env.PORT, function () { util.log('App listening on port: ' + config.port + ''.verbose); util.log(util.inspect(config, {colors: true})); diff --git a/routes/rest.js b/routes/rest.js index 44e3fd4..33c38f9 100755 --- a/routes/rest.js +++ b/routes/rest.js @@ -41,8 +41,8 @@ var MESSAGES = { }; var DS = require('jps-ds').DS; var _ds = new DS({ - host: 'angularcms:angularcms@paulo.mongohq.com:10089/app19632340', - //host: 'localhost/angular-cms', + //host: 'angularcms:angularcms@paulo.mongohq.com:10089/app19632340', + host: 'localhost/angular-cms', models: { 'groups': { title: String, @@ -193,8 +193,6 @@ var RestResource = { }); }, - - //### get //I handle gathering records dynamically from a call to the v2 api. get: function (req, res, next) {