August 2016
Intermediate to advanced
376 pages
6h 33m
English
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 ...Read now
Unlock full access