// Expose modules in ./support for demo purposes require.paths.unshift(__dirname + '/../../support'); /** * Module dependencies. */ var express = require('../../lib/express'); var app = express.createServer(); // Here we use the bodyDecoder middleware // to parse urlencoded request bodies // which populates req.body app.use(express.bodyParser()); // 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.cookieParser()); // Required by req.flash() for persistent // notifications app.use(express.session({ secret: 'keyboard cat' })); 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 = '