/** * Module dependencies. */ var express = require('./../../lib/express'), sys = require('sys'); var app = express.createServer(); // Here we use the bodyDecoder middleware // to parse urlencoded request bodies // which populates req.body app.use(express.bodyDecoder()); // The methodOverride middleware allows us // to set a hidden input of _method to an arbitrary // HTTP method to support app.put(), app.del() etc app.use(express.methodOverride()); // Required by session app.use(express.cookieDecoder()); // Required by req.flash() for persistent // notifications app.use(express.session()); app.get('/', function(req, res){ // get ?name=foo var name = req.param('name') || ''; // Switch the button label based if we have a name var label = name ? 'Update' : 'Save'; // Buffer all flash messages. // Typically this would all be done in a template // however for illustration purposes we iterate // here. // The messages in req.flash() persist until called, // at which time they are flushed from the session var msgs = '