devnotes.

app.enabled() Function

app.enabled() checks whether a boolean application setting is currently turned on.

Syntax

app.enabled(name)

Example

const express = require("express");
const app = express();

console.log(app.enabled("trust proxy")); // false
app.enable("trust proxy");
console.log(app.enabled("trust proxy")); // true

Use cases

  • Verifying a setting before relying on it in application logic.
  • Confirming a setting toggled with app.enable() actually took effect.
  • Branching logic based on current configuration.
app.enabled() Function | DevNotes