-
Book Overview & Buying
-
Table Of Contents
Mastering Web Application Development with Express
By :
Configurable middleware refers to functions that can be customized, meaning there are variables that are not hardcoded and can be passed as parameters to those functions.
Some of the most widely used configurable components are the static and the session middleware. For the first one, we can configure the path for the static resources along with some more advanced features, while the session middleware can accept parameters such as secret, key, and other settings, as shown in the following code:
var session = require('express-session');
app.use(express.static('/public'));
app.use(session({
secret: 'random chars',
key: 'session_id',
cookie: {
secure: true
}
}));As mentioned earlier in this chapter, the call to app.use() expects a function as a parameter in order to work properly. The router (this used to be the dispatcher from the Connect framework) invokes the middleware directly, because...
Change the font size
Change margin width
Change background colour