devnotes.

res.app Property

res.app holds a reference to the Express application instance tied to the current response — the same instance you'd get from req.app.

Syntax

res.app

Example

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

app.set("storeName", "PixelMart");

app.get("/about", (req, res) => {
    console.log(res.app.get("storeName"));
    res.send("PixelMart - About Page");
});

app.listen(PORT, () => console.log(`Listening on ${PORT}`));

Use cases

  • Reading application-level settings from a response handler.
  • Confirming a response object belongs to a particular app instance.
  • Accessing shared app configuration inside custom response logic.
res.app Property | DevNotes