devnotes.

app.disabled() Function

app.disabled() checks whether a boolean application setting is currently turned off — the opposite of app.enabled().

Syntax

app.disabled(name)

Example

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

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

Use cases

  • Checking whether a setting was left at its default disabled state.
  • Verifying that app.disable() was applied correctly.
  • Guarding logic that should only run when a feature is off.
app.disabled() Function | DevNotes