As we have already seen in previous chapters, the basis of all Node.js applications is the file where we set up all the dependencies and instantiate the application. In this case, we use the app.js file, but you can use any name.
Create a file called app.js and add the following code:
// Node dependencies var express = require('express'); var path = require('path'); var favicon = require('serve-favicon'); var logger = require('morgan'); var cookieParser = require('cookie-parser'); var bodyParser = require('body-parser'); // Setup application routes var routes = require('./routes/index'); // Create a Express application var app = express(); // Defining the env variable process for development var env = process.env.NODE_ENV || 'development'; app.locals.ENV = env; app.locals.ENV_DEVELOPMENT = env == 'development'; // Setup view engine to use EJS (Embedded...