Home / Function/ andRestrictTo() — express Function Reference

andRestrictTo() — express Function Reference

Architecture documentation for the andRestrictTo() function in index.js from the express codebase.

Entity Profile

Dependency Diagram

graph TD
  9449e895_e189_fa52_a930_2f682113ad31["andRestrictTo()"]
  afb8616c_d315_1619_1936_54fa1bc1f161["index.js"]
  9449e895_e189_fa52_a930_2f682113ad31 -->|defined in| afb8616c_d315_1619_1936_54fa1bc1f161
  style 9449e895_e189_fa52_a930_2f682113ad31 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

examples/route-middleware/index.js lines 50–58

function andRestrictTo(role) {
  return function(req, res, next) {
    if (req.authenticatedUser.role === role) {
      next();
    } else {
      next(new Error('Unauthorized'));
    }
  }
}

Domain

Subdomains

Frequently Asked Questions

What does andRestrictTo() do?
andRestrictTo() is a function in the express codebase, defined in examples/route-middleware/index.js.
Where is andRestrictTo() defined?
andRestrictTo() is defined in examples/route-middleware/index.js at line 50.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free