Adding Multiple Middleware Functions

You can assign as many middleware functions globally and to routes as you like. For example, the following code assigns the body-parser, cookie-parser and express-session middleware modules:

var express = require('express'),
var bodyParser = require('body-parser'),
var cookieParser = require('cookie-parser'),
var session = require('cexpress-session'),
var app = express();
app.use('/', bodyParser()).
use('/', cookieParser()).
use('/', session()));

Keep in mind that the order in which you assign the functions is the order in which they are applied during a request. Some middleware functions need to be added before others.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset