June 2016
Beginner
248 pages
5h 18m
English
We've actually already used several Node.js modules and created some of our own. Let's look again at our application from Chapter 2, Getting Started with Node.js.
The following code is from routes/index.js and routes/users.js:
module.exports = router;
The following is the code from app.js:
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');
var routes = require('./routes/index');
var users = require('./routes/users');Each of our routes (index and users) is a module. They expose their functionality using the built-in module object, which is defined by Node.js ...
Read now
Unlock full access