Renaming usage of old connect middleware
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Tj Holowaychuk · committed by Tj Holowaychuk · parent bdbacb4 · Browse files · 10 files·+21 added−21 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
10 files+21 added−21 removed
- tests:+3 added−3 removed
- other:+18 added−18 removed
Provenance
- Commit
2a7a5ae- Tree
61db2fb- Author
Tj Holowaychuk <tj@vision-media.ca>- Committer
Tj Holowaychuk <tj@vision-media.ca>- Parent
bdbacb4
10 files changed+21 added−21 removed
modified:bin/express+2 added-2 removed
211 unmodified lines212 , ''213 , 'app.configure(function(){'214 , ' app.set(\'views\', __dirname + \'/views\');'215 , ' app.set(\'view engine\', \':TEMPLATE\');'216- , ' app.use(express.bodyDecoder());'216+ , ' app.use(express.bodyParser());'217 , ' app.use(express.methodOverride());{sess}{css}'218 , ' app.use(app.router);'219- , ' app.use(express.staticProvider(__dirname + \'/public\'));'219+ , ' app.use(express.static(__dirname + \'/public\'));'220 , '});'221 , ''222 , 'app.configure(\'development\', function(){'223 , ' app.use(express.errorHandler({ dumpExceptions: true, showStack: true })); '241 unmodified linesmodified:examples/auth/app.js+2 added-2 removed
12 unmodified lines131415161718171819202122104 unmodified linesExpand all12 unmodified lines
app.set('views', __dirname + '/views');app.set('view engine', 'ejs');
app.use(express.bodyDecoder());app.use(express.cookieDecoder());app.use(express.bodyParser());app.use(express.cookieParser());app.use(express.session({ secret: 'keyboard cat' }));
// Message helper, ideally we would use req.flash()// however this is more light-weight for an example104 unmodified linesExpand allmodified:examples/blog/app.js+3 added-3 removed
23 unmodified lines24252627282829303031323333343536376 unmodified lines23 unmodified lines// Middleware
app.configure(function(){ app.use(express.logger('\x1b[33m:method\x1b[0m \x1b[32m:url\x1b[0m :response-time')); app.use(express.bodyDecoder()); app.use(express.bodyParser()); app.use(express.methodOverride()); app.use(express.cookieDecoder()); app.use(express.cookieParser()); app.use(express.session({ secret: 'keyboard cat' })); app.use(app.router); app.use(express.staticProvider(__dirname + '/public')); app.use(express.static(__dirname + '/public')); app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));});
// Routes6 unmodified linesmodified:examples/cookies/app.js+2 added-2 removed
12 unmodified lines13 // Custom logger format14 express.logger({ format: '\x1b[1m:method\x1b[0m \x1b[33m:url\x1b[0m :response-time' }),15 16 // Provides req.cookies17- express.cookieDecoder(),17+ express.cookieParser(),18 19 // Parses x-www-form-urlencoded request bodies (and json)20- express.bodyDecoder()20+ express.bodyParser()21 );22 23 app.get('/', function(req, res){24 if (req.cookies.remember) {22 unmodified linesmodified:examples/form/app.js+2 added-2 removed
9 unmodified lines10 11 // Here we use the bodyDecoder middleware12 // to parse urlencoded request bodies13 // which populates req.body14-app.use(express.bodyDecoder());14+app.use(express.bodyParser());15 16 // The methodOverride middleware allows us17 // to set a hidden input of _method to an arbitrary18 // HTTP method to support app.put(), app.del() etc19 app.use(express.methodOverride());20 21 // Required by session22-app.use(express.cookieDecoder());22+app.use(express.cookieParser());23 24 // Required by req.flash() for persistent25 // notifications26 app.use(express.session({ secret: 'keyboard cat' }));53 unmodified linesmodified:examples/mvc/mvc.js+3 added-3 removed
13 unmodified lines14 // App settings and middleware15 16 function bootApplication(app) {17 app.use(express.logger({ format: ':method :url :status' }));18- app.use(express.bodyDecoder());18+ app.use(express.bodyParser());19 app.use(express.methodOverride());20- app.use(express.cookieDecoder());20+ app.use(express.cookieParser());21 app.use(express.session({ secret: 'keyboard cat' }));22 app.use(app.router);23- app.use(express.staticProvider(__dirname + '/public'));23+ app.use(express.static(__dirname + '/public'));24 25 // Example 500 page26 app.error(function(err, req, res){27 console.dir(err)121 unmodified linesmodified:examples/route-separation/app.js+2 added-2 removed
14 unmodified lines15 // Config16 17 app.set('view engine', 'ejs');18 app.set('views', __dirname + '/views');19-app.use(express.bodyDecoder());19+app.use(express.cookieParser());20 app.use(express.methodOverride());21-app.use(express.staticProvider(__dirname + '/public'));21+app.use(express.static(__dirname + '/public'));22 23 // General24 25 app.get('/', site.index);16 unmodified linesmodified:lib/request.js+2 added-2 removed
128 unmodified lines129 * - Checks urlencoded body params, ex: id=12130 *131 * To utilize urlencoded request bodies, `req.body`132 * should be an object. This can be done by using133- * the `connect.bodyDecoder` middleware.133+ * the `connect.bodyParser` middleware.134 *135 * @param {String} name136 * @param {Mixed} defaultValue137 * @return {String}8 unmodified lines146 // Query string params147 if (this.query[name] !== undefined) {148 return this.query[name]; 149 }150- // Request body params via connect.bodyDecoder150+ // Request body params via connect.bodyParser151 if (this.body && this.body[name] !== undefined) {152 return this.body[name];153 }154 return defaultValue;136 unmodified linesmodified:test/express.test.js+2 added-2 removed
258 unmodified lines259 'test #configure() immediate call': function(){260 var app = express.createServer();261 262 app.configure(function(){263- app.use(connect.bodyDecoder());263+ app.use(connect.bodyParser());264 });265 266 app.post('/', function(req, res){267 res.send(req.param('name') || 'nope');57 unmodified lines325 326 'test middleware precedence': function(){327 var app = express.createServer();328 329- app.use(connect.bodyDecoder());329+ app.use(connect.bodyParser());330 331 assert.equal(2, app.stack.length);332 333 app.post('/', function(req, res){192 unmodified linesmodified:test/request.test.js+1 added-1 removed
94 unmodified lines95 },96 97 'test #param()': function(){98 var app = express.createServer(99- connect.bodyDecoder()99+ connect.bodyParser()100 );101 102 app.get('/user/:id?', function(req, res){103 res.send('user ' + req.param('id', 'unknown'));200 unmodified lines