Permalink
Browse files

Updates Connect from v2.9.0 to v2.30.2

  • Loading branch information...
1 parent f9965b2 commit 3f2298da2c115c7c6ca17ad2ebfc5415a26c26aa @kennethormandy kennethormandy committed Sep 17, 2015
Showing with 53 additions and 48 deletions.
  1. +28 −26 lib/index.js
  2. +16 −17 lib/middleware.js
  3. +9 −5 package.json
View
@@ -12,46 +12,48 @@ var pkg = require('../package.json')
/**
* Server
*
- * Host a single Harp Application.
+ * Host a single Harp application.
*
*/
exports.server = function(dirPath, options, callback){
- return connect.createServer(
- middleware.regProjectFinder(dirPath),
- middleware.setup,
- middleware.basicAuth,
- middleware.underscore,
- middleware.mwl,
- middleware.static,
- middleware.poly,
- middleware.process,
- middleware.fallback
- ).listen(options.port || 9966, options.ip, callback)
+ var app = connect()
+ app.use(middleware.regProjectFinder(dirPath))
+ app.use(middleware.setup)
+ app.use(middleware.basicAuth)
+ app.use(middleware.underscore)
+ app.use(middleware.mwl)
+ app.use(middleware.static)
+ app.use(middleware.poly)
+ app.use(middleware.process)
+ app.use(middleware.fallback)
+ app.listen(options.port || 9966, options.ip, callback)
+
+ return app
}
/**
* Multihost
*
- * Host a single Harp Application.
+ * Host multiple Harp applications.
*
*/
exports.multihost = function(dirPath, options, callback){
- return connect.createServer(
- middleware.notMultihostURL,
- middleware.index(dirPath),
- middleware.hostProjectFinder(dirPath),
- middleware.setup,
- middleware.basicAuth,
- middleware.underscore,
- middleware.mwl,
- middleware.static,
- middleware.poly,
- middleware.process,
- middleware.fallback
- ).listen(options.port || 9000, callback)
+ var app = connect()
+ app.use(middleware.notMultihostURL)
+ app.use(middleware.index(dirPath))
+ app.use(middleware.hostProjectFinder(dirPath))
+ app.use(middleware.setup)
+ app.use(middleware.basicAuth)
+ app.use(middleware.underscore)
+ app.use(middleware.mwl)
+ app.use(middleware.static)
+ app.use(middleware.poly)
+ app.use(middleware.process)
+ app.use(middleware.fallback)
+ app.listen(options.port || 9000, callback)
}
/**
View
@@ -6,11 +6,11 @@ var terraform = require('terraform')
var pkg = require('../package.json')
var skin = require('./skin')
var connect = require('connect')
-
-var send = require('../node_modules/connect/node_modules/send')
- , utils = require('../node_modules/connect/lib/utils')
- , parse = utils.parseUrl
- , url = require('url')
+var send = require('send')
+var utilsPause = require('pause')
+var utilsEscape = require('escape-html')
+var parse = require('parseurl')
+var url = require('url')
exports.notMultihostURL = function(req, rsp, next){
var host = req.headers.host
@@ -335,7 +335,7 @@ exports.static = function(req, res, next) {
if ('GET' != req.method && 'HEAD' != req.method) return next();
var pathn = parse(req).pathname;
- var pause = utils.pause(req);
+ var pause = utilsPause(req);
function resume() {
next();
@@ -348,7 +348,7 @@ exports.static = function(req, res, next) {
var pathname = url.parse(req.originalUrl).pathname;
res.statusCode = 301;
res.setHeader('Location', pathname + '/');
- res.end('Redirecting to ' + utils.escape(pathname) + '/');
+ res.end('Redirecting to ' + utilsEscape(pathname) + '/');
}
function error(err) {
@@ -362,17 +362,16 @@ exports.static = function(req, res, next) {
}
var serve = function(pathn){
- send(req, pathn)
- .maxage(options.maxAge || 0)
- .root(req.setup.publicPath)
- .hidden(options.hidden)
- .on('error', error)
- .on('directory', directory)
- .pipe(res)
+ send(req, pathn, {
+ maxage: options.maxAge || 0,
+ root: req.setup.publicPath,
+ hidden: options.hidden
+ })
+ .on('error', error)
+ .on('directory', directory)
+ .pipe(res)
}
-
serve(pathn)
-
}
/**
@@ -485,7 +484,7 @@ exports.process = function(req, rsp, next){
// 301 redirect
rsp.statusCode = 301
rsp.setHeader('Location', prospectCleanPath)
- rsp.end('Redirecting to ' + utils.escape(prospectCleanPath))
+ rsp.end('Redirecting to ' + utilsEscape(prospectCleanPath))
}
} else {
View
@@ -34,14 +34,18 @@
"url": "https://github.com/sintaxi/harp.git"
},
"dependencies": {
- "terraform": "0.12.0",
- "commander": "2.0.0",
- "connect": "2.9.0",
"async": "0.2.9",
+ "commander": "2.0.0",
+ "connect": "2.30.2",
+ "download-github-repo": "0.1.3",
+ "envy-json": "0.2.1",
+ "escape-html": "1.0.3",
"fs-extra": "0.18.2",
"mime": "1.2.11",
- "download-github-repo": "0.1.3",
- "envy-json": "0.2.1"
+ "parseurl": "1.3.0",
+ "pause": "0.1.0",
+ "send": "0.13.0",
+ "terraform": "0.12.0"
},
"devDependencies": {
"cheerio": "0.19.0",

0 comments on commit 3f2298d

Please sign in to comment.