Created
June 13, 2012 14:05
-
-
Save fengmk2/2924280 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 淘宝指数 - 消失的密室 | |
*/ | |
var express = require('express'); | |
var formDataParser = express.bodyParser.parse['multipart/form-data']; | |
// dont parse file upload | |
delete express.bodyParser.parse['multipart/form-data']; | |
var fs = require('fs'); | |
var path = require('path'); | |
.......... | |
........... | |
........... | |
app.use(require('./lib/redirect')({ domain: 'taobao.com' })); | |
// handle file upload | |
app.use('/upload', function (req, res, next) { | |
if (req.body) { | |
return next(); | |
} | |
req.body = {}; | |
if ('GET' === req.method || 'HEAD' === req.method) { | |
return next(); | |
} | |
var contentType = (req.headers['content-type'] || '').split(';')[0]; | |
if (contentType !== 'multipart/form-data') { | |
return next(); | |
} | |
formDataParser(req, {}, next); | |
}); | |
app.use(express.bodyParser()); | |
app.use(express.cookieParser()); | |
app.use(express.session({ | |
secret: config.session_secret, | |
cookie: { path: '/', httpOnly: true, maxAge: 3600000 * 12 }, | |
store: new RedisStore(config.redisOptions) | |
})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment