'use strict';

// Module dependencies.
var express = require('express'),
    path = require('path'),
    fs = require('fs'),
    methodOverride = require('method-override'),
    morgan = require('morgan'),
    bodyParser = require('body-parser'),
    errorhandler = require('errorhandler');

var app = module.exports = exports.app = express();

app.locals.siteName = "MongooseGettingStarted";

// Connect to database
var db = require('./config/db');

app.use(express.static(__dirname + '/public'));

// Bootstrap models
var modelsPath = path.join(__dirname, 'models');
fs.readdirSync(modelsPath).forEach(function (file) {
    require(modelsPath + '/' + file);
});

var env = process.env.NODE_ENV || 'development';

if ('development' == env) {
    app.use(morgan('dev'));
    app.use(errorhandler({
        dumpExceptions: true,
        showStack: true
    }));
    app.set('view options', {
        pretty: true
    });
}


if ('test' == env) {
    app.use(morgan('test'));
    app.set('view options', {
        pretty: true
    });
}

if ('production' == env) {
    app.use(morgan());
    app.use(express.errorHandler());
}



app.engine('html', require('ejs').renderFile);
app.set('view engine', 'html');
app.use(methodOverride());
app.use(bodyParser());
// Router needs to be last
//app.use(app.router);

// Bootstrap routes/api
var routesPath = path.join(__dirname, 'routes');
fs.readdirSync(routesPath).forEach(function (file) {
    require(routesPath + '/' + file)(app);
});

// Start server
var port = process.env.PORT || 3000;
app.listen(port, function () {
    console.log('Express server listening on port %d in %s mode', port, app.get('env'));
});
@@ -365,30 +365,36 @@
  = %22
-MongooseGettingStarted
+%3C%25= _.capitalize(appname) %25%3E
 %22;%0A%0A
@@ -454,57 +454,8 @@
 );%0A%0A
-app.use(express.static(__dirname + '/public'));%0A%0A
 // B
@@ -564,34 +564,32 @@
 nction (file) %7B%0A
-  
   require(models
@@ -608,16 +608,16 @@
  file);%0A
+
 %7D);%0A%0Avar
@@ -871,17 +871,16 @@
  %7D);%0A%7D%0A%0A
-%0A
 if ('tes
@@ -1073,18 +1073,16 @@
 ());%0A%7D%0A%0A
-%0A%0A
 app.engi
@@ -1205,58 +1205,8 @@
 ());
-%0A// Router needs to be last%0A//app.use(app.router);
 %0A%0A//
@@ -1311,33 +1311,32 @@
 forEach(function
- 
 (file) %7B%0A    req
@@ -1328,18 +1328,16 @@
 file) %7B%0A
-  
   requir
@@ -1458,18 +1458,16 @@
 on () %7B%0A
-  
   consol

Update the code base as per expressjs 4.0