(route: Node, root: Node | null)
| 600 | |
| 601 | /** What runs before a route's handler: the middleware arguments at the registration, or the guard decorators on it. */ |
| 602 | const chainFor = async (route: Node, root: Node | null): Promise<string[]> => { |
| 603 | const after: string[] = []; |
| 604 | if (JS_FAMILY.has(route.language)) { |
| 605 | const site = await calls.callSite(route, { line: route.startLine, column: 0 }); |
| 606 | if (site && /\.(?:get|post|put|patch|delete|all|use|head|options|route)$/i.test(site.callee)) { |
| 607 | const args = site.argList.slice(1); |
| 608 | if (args.length > 0 && !/^\{/.test(args[args.length - 1]!)) args.pop(); |
| 609 | for (const a of args) if (a && !/^\{ ?…? ?\}$/.test(a)) after.push(a); |
| 610 | } |
| 611 | } |
| 612 | if (root && root.id !== route.id) { |
| 613 | const decs = await calls.decorators(root); |
| 614 | if (decs) { |
| 615 | for (const d of [...decs.class, ...decs.own]) { |
| 616 | if (!JS_FAMILY.has(root.language) && !/^(?:python)$/.test(root.language)) { |
| 617 | if (isGuardDecorator(d)) after.push(d); |
| 618 | continue; |
| 619 | } |
| 620 | for (const dep of dependenciesIn(d)) after.push(dep); |
| 621 | if (isGuardDecorator(d)) after.push(d); |
| 622 | } |
| 623 | } |
| 624 | } |
| 625 | return [...new Set(after)]; |
| 626 | }; |
| 627 | |
| 628 | /** The request a route's handler serves, as its trigger; a Next page's own work fires from its load. */ |
| 629 | const requestTrigger = async (route: Node, root: Node | null): Promise<WireStepTrigger | null> => { |
no test coverage detected