Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
app.enabled() Method in Express.js
The app.enabled() method checks whether a setting name property is enabled or not. It basically checks the value of a setting name and returns True if the property value is also True.
Syntax
app.enabled( name )
Example 1
Create a file with the name "appEnabled.js" and copy the following code snippet. After creating the file, use the command "node appEnabled.js" to run this code as shown in the example below −
// app.enabled() Method Demo Example
// Importing the express module
const express = require('express');
// Initializing the express and port number
var app = express();
// Initializing the router from express
var router = express.Router();
var PORT = 3000;
// Checking the foo property
console.log("Trust proxy settings are set to: ",
app.enabled('trust proxy'));
Output
C:\home\node>> node appEnabled.js Trust proxy settings are set to: false
Example 2
Let's take a look at one more example.
// app.enabled() Method Demo Example
// Importing the express module
const express = require('express');
// Initializing the express and port number
var app = express();
// Initializing the router from express
var router = express.Router();
var PORT = 3000;
// Enabling 'trust proxy' settings
app.enable('trust proxy');
// Checking the foo property
console.log("Trust proxy settings are set to: ",
app.enabled('trust proxy'));
Output
C:\home\node >> node appEnabled.js Trust proxy settings are set to: true
Advertisements
