Skip to content

Commit 3f2298d

Browse files
Updates Connect from v2.9.0 to v2.30.2
1 parent f9965b2 commit 3f2298d

File tree

3 files changed

+53
-48
lines changed

3 files changed

+53
-48
lines changed

lib/index.js

+28-26
Original file line numberDiff line numberDiff line change
@@ -12,46 +12,48 @@ var pkg = require('../package.json')
1212
/**
1313
* Server
1414
*
15-
* Host a single Harp Application.
15+
* Host a single Harp application.
1616
*
1717
*/
1818

1919
exports.server = function(dirPath, options, callback){
20-
return connect.createServer(
21-
middleware.regProjectFinder(dirPath),
22-
middleware.setup,
23-
middleware.basicAuth,
24-
middleware.underscore,
25-
middleware.mwl,
26-
middleware.static,
27-
middleware.poly,
28-
middleware.process,
29-
middleware.fallback
30-
).listen(options.port || 9966, options.ip, callback)
20+
var app = connect()
21+
app.use(middleware.regProjectFinder(dirPath))
22+
app.use(middleware.setup)
23+
app.use(middleware.basicAuth)
24+
app.use(middleware.underscore)
25+
app.use(middleware.mwl)
26+
app.use(middleware.static)
27+
app.use(middleware.poly)
28+
app.use(middleware.process)
29+
app.use(middleware.fallback)
30+
app.listen(options.port || 9966, options.ip, callback)
31+
32+
return app
3133
}
3234

3335

3436
/**
3537
* Multihost
3638
*
37-
* Host a single Harp Application.
39+
* Host multiple Harp applications.
3840
*
3941
*/
4042

4143
exports.multihost = function(dirPath, options, callback){
42-
return connect.createServer(
43-
middleware.notMultihostURL,
44-
middleware.index(dirPath),
45-
middleware.hostProjectFinder(dirPath),
46-
middleware.setup,
47-
middleware.basicAuth,
48-
middleware.underscore,
49-
middleware.mwl,
50-
middleware.static,
51-
middleware.poly,
52-
middleware.process,
53-
middleware.fallback
54-
).listen(options.port || 9000, callback)
44+
var app = connect()
45+
app.use(middleware.notMultihostURL)
46+
app.use(middleware.index(dirPath))
47+
app.use(middleware.hostProjectFinder(dirPath))
48+
app.use(middleware.setup)
49+
app.use(middleware.basicAuth)
50+
app.use(middleware.underscore)
51+
app.use(middleware.mwl)
52+
app.use(middleware.static)
53+
app.use(middleware.poly)
54+
app.use(middleware.process)
55+
app.use(middleware.fallback)
56+
app.listen(options.port || 9000, callback)
5557
}
5658

5759
/**

lib/middleware.js

+16-17
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ var terraform = require('terraform')
66
var pkg = require('../package.json')
77
var skin = require('./skin')
88
var connect = require('connect')
9-
10-
var send = require('../node_modules/connect/node_modules/send')
11-
, utils = require('../node_modules/connect/lib/utils')
12-
, parse = utils.parseUrl
13-
, url = require('url')
9+
var send = require('send')
10+
var utilsPause = require('pause')
11+
var utilsEscape = require('escape-html')
12+
var parse = require('parseurl')
13+
var url = require('url')
1414

1515
exports.notMultihostURL = function(req, rsp, next){
1616
var host = req.headers.host
@@ -335,7 +335,7 @@ exports.static = function(req, res, next) {
335335

336336
if ('GET' != req.method && 'HEAD' != req.method) return next();
337337
var pathn = parse(req).pathname;
338-
var pause = utils.pause(req);
338+
var pause = utilsPause(req);
339339

340340
function resume() {
341341
next();
@@ -348,7 +348,7 @@ exports.static = function(req, res, next) {
348348
var pathname = url.parse(req.originalUrl).pathname;
349349
res.statusCode = 301;
350350
res.setHeader('Location', pathname + '/');
351-
res.end('Redirecting to ' + utils.escape(pathname) + '/');
351+
res.end('Redirecting to ' + utilsEscape(pathname) + '/');
352352
}
353353

354354
function error(err) {
@@ -362,17 +362,16 @@ exports.static = function(req, res, next) {
362362
}
363363

364364
var serve = function(pathn){
365-
send(req, pathn)
366-
.maxage(options.maxAge || 0)
367-
.root(req.setup.publicPath)
368-
.hidden(options.hidden)
369-
.on('error', error)
370-
.on('directory', directory)
371-
.pipe(res)
365+
send(req, pathn, {
366+
maxage: options.maxAge || 0,
367+
root: req.setup.publicPath,
368+
hidden: options.hidden
369+
})
370+
.on('error', error)
371+
.on('directory', directory)
372+
.pipe(res)
372373
}
373-
374374
serve(pathn)
375-
376375
}
377376

378377
/**
@@ -485,7 +484,7 @@ exports.process = function(req, rsp, next){
485484
// 301 redirect
486485
rsp.statusCode = 301
487486
rsp.setHeader('Location', prospectCleanPath)
488-
rsp.end('Redirecting to ' + utils.escape(prospectCleanPath))
487+
rsp.end('Redirecting to ' + utilsEscape(prospectCleanPath))
489488
}
490489

491490
} else {

package.json

+9-5
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,18 @@
3434
"url": "https://github.com/sintaxi/harp.git"
3535
},
3636
"dependencies": {
37-
"terraform": "0.12.0",
38-
"commander": "2.0.0",
39-
"connect": "2.9.0",
4037
"async": "0.2.9",
38+
"commander": "2.0.0",
39+
"connect": "2.30.2",
40+
"download-github-repo": "0.1.3",
41+
"envy-json": "0.2.1",
42+
"escape-html": "1.0.3",
4143
"fs-extra": "0.18.2",
4244
"mime": "1.2.11",
43-
"download-github-repo": "0.1.3",
44-
"envy-json": "0.2.1"
45+
"parseurl": "1.3.0",
46+
"pause": "0.1.0",
47+
"send": "0.13.0",
48+
"terraform": "0.12.0"
4549
},
4650
"devDependencies": {
4751
"cheerio": "0.19.0",

0 commit comments

Comments
 (0)