Noir::JSHandlerResolver
Resolves a route's named handler (app.get('/x', login),
router.post('/y', users.create), app.use(auth())) to the file and
line that define it: a same-file function login / const login =, or
the target of the import that brought the name in.
Best-effort by design. An inline closure has no name, a package import
(express.static) has no file in the scan, and a re-exported symbol is
followed one hop only. Each of those yields nil rather than a guess.
Constants
Factories that register middleware, never a route's handler. A route whose last argument is one of these has no named handler to report.
The wrapper head: function name<T>(, name = <T extends H>(,
= async (, module.exports = (, export default function (; or a
bare = fn =>.
The request parameter of the function a wrapper returns: (req, res, next) =>, function (req, res), req =>.
utils.asyncHandler(login()), wrap(ctrl.show): the handler is the
argument, the wrapper only catches its rejection. A wrapper defined in
the scan is judged by its definition (unwrap); these names are the
fallback for one that comes from a package (express-async-handler).
validate(schema) is middleware, not a wrapped schema.
Instance methods
Names the module's exports object goes by: exports, module.exports,
and a local bound to it (const Posts = module.exports;, or
module.exports = Posts; at the end), as an alternation.
handler_text is the route argument as written. Returns nil unless it
is a plain reference that resolves to a definition.
await import("./x.handler") in a handler body: name as exported by
the module specifier names, or its default export when nil.
A wrapper call W(x) as {x, its char offset in text, W}, when the
wrapper hands the request on to its argument: its definition takes a
function and returns one that calls it ((fn) => (req, res, next) => Promise.resolve(fn(req, res, next)).catch(next)). A wrapper with no
definition in the scan, or one whose definition cannot be read, is taken
by name (WRAPPER_NAME_RE). A wrapper that can itself refuse the request
((fn) => (req, res, next) => req.user ? fn(req, res, next) : res.sendStatus(401)) is a guard around x: it is only unwrapped when
the caller reports that guard (guards: true).