June 2014
Intermediate to advanced
696 pages
38h 52m
English
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.
Read now
Unlock full access