app.enabled(name)
Returns true if the setting name is enabled
Example
maintenanceSupported =
app.enabled('maintenanceSupported')
index.js
var express = require('express') var app = express() app.set('version', '1.2.31') app.set('maintenanceSupported', true) app.get('/', (req, res) => { res.send("Hello World") }) app.get('/appInfo', (req, res) => { version = app.get('version') maintenanceSupported = app.enabled('maintenanceSupported') res.send(`maintenanceSupported : ${maintenanceSupported}, <br />version : ${version}`) }) app.get('/disableMaintenance', (req, res) => { app.disable('maintenanceSupported') version = app.get('version') maintenanceSupported = app.enabled('maintenanceSupported') res.send(`maintenanceSupported : ${maintenanceSupported}, <br />version : ${version}`) }) app.listen(3000, () => {console.log("Application started in port 3000")});
Run index.js.
Open the url ‘http://localhost:3000/appInfo’.
Open the url ‘http://localhost:3000/disableMaintenance’
to disable maintenance.
No comments:
Post a Comment