From 78057dca3c16b430df0d6b22756c7610bf4619d7 Mon Sep 17 00:00:00 2001 From: reality Date: Thu, 4 Sep 2014 14:19:23 +0000 Subject: [PATCH] update web to use new express version --- modules/warning/pages.js | 3 +-- modules/web/web.js | 20 +++++++++++--------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/modules/warning/pages.js b/modules/warning/pages.js index 0c4cf08..298db12 100644 --- a/modules/warning/pages.js +++ b/modules/warning/pages.js @@ -39,7 +39,7 @@ var pages = function(dbot) { var server = req.params.server, user = req.params.uid; - dbot.api.users.resolveUser(server, user, function(user) { + dbot.api.users.resolveUser(server, user, function(err, user) { var warnings = []; this.db.search('warnings', { 'server': server, @@ -54,7 +54,6 @@ var pages = function(dbot) { callback(false); }); }, function(err) { - console.log(warnings); res.render('warnings', { 'name': dbot.config.name, 'server': server, diff --git a/modules/web/web.js b/modules/web/web.js index f15f41d..b7f458d 100644 --- a/modules/web/web.js +++ b/modules/web/web.js @@ -4,7 +4,11 @@ var express = require('express'), flash = require('connect-flash'), _ = require('underscore')._, fs = require('fs'), - LocalStrategy = require('passport-local').Strategy; + LocalStrategy = require('passport-local').Strategy, + cookieParser = require('cookie-parser'); + bodyParser = require('body-parser'); + expressSession = require('express-session'); + methodOverride = require('method-override'); var webInterface = function(dbot) { this.config = dbot.config.modules.web; @@ -14,15 +18,14 @@ var webInterface = function(dbot) { this.app.use(express.static(this.pub)); this.app.set('view engine', 'jade'); - this.app.use(express.cookieParser()); - this.app.use(express.bodyParser()); - this.app.use(express.methodOverride()); - this.app.use(express.session({ 'secret': 'wat' })); + this.app.use(cookieParser()); + this.app.use(methodOverride()); + this.app.use(expressSession({ 'secret': 'wat' })); + this.app.use(bodyParser()); this.app.use(flash()); this.app.use(passport.initialize()); this.app.use(passport.session()); - this.app.use(this.app.router); passport.serializeUser(function(user, done) { done(null, user.id); @@ -46,7 +49,7 @@ var webInterface = function(dbot) { 'Please provide a valid server (Servers: ' + _.keys(dbot.config.servers).join(', ') + ')' }); - dbot.api.users.resolveUser(server, username, function(user) { + dbot.api.users.resolveUser(server, username, function(err, user) { if(user) { this.api.getWebUser(user.id, function(webUser) { if(webUser) { @@ -95,8 +98,7 @@ var webInterface = function(dbot) { this.onLoad = function() { this.reloadPages(); - - var routes = _.pluck(dbot.modules.web.app.routes.get, 'path'), + var routes = _.pluck(_.without(_.pluck(this.app._router.stack, 'route'), undefined), 'path'), moduleNames = _.keys(dbot.modules); _.each(moduleNames, function(moduleName) {