index.js
var express = require('express');
var router = express.Router();
// var count = 0;
// // middleware
// router.use(function(req, res, next) {
// count = count + 1;
// console.log("Received " + count + " requests");
// next();
// });
/* GET home page. */
router.get('/', function(req, res, next) {
res.render('index', { title: 'Express' });
});
router.get('/brew', function(req, res, next) {
var query = req.query;
if(query['drink'] == "tea"){
res.send("A delicious cup of tea!");
}
else if(query['drink'] == "coffee"){
res.sendStatus(418);
}
else {
res.sendStatus(400);
}
});
var previousMessage = "first";
router.post('/pass-it-on', function(req, res, next) {
var body = req.body;
if(typeof body['message'] == 'undefined' || body['message'] =