Configuring Express Settings

Express provides several application settings that control the behavior of the Express server. These settings define the environment as well as how Express handles JSON parsing, routing, and views. Table 18.1 lists the settings that can be defined on an express object.

Image

Table 18.1 Express application settings

The express object provides the set(setting, value) and enable(setting) and disable(setting) methods to set values for the application settings. For example, the following lines of code enable the trust proxy setting and set view engine to jade:

app.enable('trust proxy'),
app.disable('strict routing'),
app.set('view engine', 'jade'),

To get the value of a setting, you use the get(setting), enabled(setting), and disabled(setting) methods. For example:

app.enabled('trust proxy'),  \true
app.disabled('strict routing'), \true
app.get('view engine'), \jade

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

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