Skip to content

Commit

Permalink
Update Express dependency to version 4
Browse files Browse the repository at this point in the history
Followed work done on this PR:
jaredhanson#152
  • Loading branch information
tregagnon committed Apr 22, 2015
1 parent c040217 commit e69f988
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 17 deletions.
23 changes: 16 additions & 7 deletions lib/cli/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,23 +175,27 @@ var viewsInitializer = [
var middlewareInitializer = [
'var express = require(\'express\')'
, ' , poweredBy = require(\'connect-powered-by\');'
, ' , favicon = require(\'static-favicon\')'
, ' , bodyParser = require(\'body-parser\')'
, ' , methodOverride = require(\'method-override\')'
, ' , errorHandler = require(\'errorhandler\');'
, ''
, 'module.exports = function() {'
, ' // Use middleware. Standard [Connect](http://www.senchalabs.org/connect/)'
, ' // middleware is built-in, with additional [third-party](https://github.com/senchalabs/connect/wiki)'
, ' // middleware available as separate modules.'
, ' if (\'development\' == this.env) {'
, ' this.use(express.logger());'
, ' this.use(require(\'morgan\')());'
, ' }'
, ''
, ' this.use(poweredBy(\'Maglev\'));'
, ' this.use(express.favicon());'
, ' this.use(favicon());'
, ' this.use(express.static(__dirname + \'/../../public\'));'
, ' this.use(express.urlencoded());'
, ' this.use(bodyParser());'
, ' this.use(methodOverride());'
, ' this.use(express.json());'
, ' this.use(express.methodOverride());'
, ' this.use(this.router);'
, ' this.use(express.errorHandler());'
, ' this.use(errorHandler());'
, '}'
, ''
].join(eol);
Expand Down Expand Up @@ -234,12 +238,17 @@ var packageJSON = [
, ' "version": "0.0.1",'
, ' "private": true,'
, ' "dependencies": {'
, ' "maglev": "0.4.x",'
, ' "maglev": "0.5.x",'
, ' "bootable": "0.2.x",'
, ' "bootable-environment": "0.2.x",'
, ' "express": "3.x.x",'
, ' "express": "4.x.x",'
, ' "connect-powered-by": "0.1.x",'
, ' "ejs": "0.8.x"'
, ' "morgan": "1.x.x",'
, ' "static-favicon": "1.x.x",'
, ' "body-parser": "1.x.x",'
, ' "method-override": "1.x.x",'
, ' "errorhandler": "1.x.x"'
, ' },'
, ' "scripts": {'
, ' "start": "node server.js"'
Expand Down
4 changes: 2 additions & 2 deletions lib/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Module dependencies.
*/
var router = require('actionrouter')
, mime = require('express').mime
, mime = require('express').static.mime
, utils = require('./utils')
, flatten = require('utils-flatten')
, dispatch = require('./middleware/dispatch')
Expand All @@ -27,7 +27,7 @@ function Controller() {
* - Checks query string params, ex: ?id=12
*
* To utilize request bodies, `req.body` should be an object. This can be done
* by using `express.bodyParser()` middleware.
* by using the module `body-parser`.
*
* For convenience, this function is aliased to `params`.
*
Expand Down
11 changes: 5 additions & 6 deletions lib/underlay/express.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ module.exports = function(env) {
return dispatch(self, controller, action);
});
this.__router.define(function(method, path, handler) {
app[method](path, handler);
self.router[method](path, handler);
});
this.__router.assist(function(name, entry) {
if (typeof entry == 'string') {
Expand All @@ -57,16 +57,15 @@ module.exports = function(env) {

// Forward function calls from Maglev to Express. This allows Maglev
// to be used interchangably with Express.
utils.forward(this, app, [ 'configure',
'get', 'set',
utils.forward(this, app, [ 'get', 'set',
'enabled', 'disabled',
'enable', 'disable',
'use', 'engine' ]);
this.express = app;
this.router = app.router;
this.router = express.Router();
this.locals = app.locals;
this.mime = express.mime;
this.mime = express.static.mime;

// Set the environment. This syncs Express with the environment supplied to
// the Maglev CLI.
this.set('env', env);
Expand Down
2 changes: 1 addition & 1 deletion lib/utils.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Module dependencies.
*/
var mime = require('express').mime;
var mime = require('express').static.mime;

/**
* Parse accept params `str` returning an
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"pkginfo": "0.3.0",
"commander": "2.7.1",
"co-prompt": "1.0.0",
"express": "3.20.2",
"express": "4.12.3",
"actionrouter": "0.1.0",
"bootable": "0.2.4",
"bootable-environment": "0.2.0",
Expand Down

0 comments on commit e69f988

Please sign in to comment.