Audits router files statically to verify that imports and Express router registrations are correctly mapped.
The Routes Auditor Story (V3) acts as a validator for Express routes files. It maps imported router modules against their registrations (via `router.use()`) to flag unused router imports or routes registered without a corresponding import declaration.
Execution maps the file text in two tracks:
router.use("/path", routerVar) invocations.It cross-references variable names between these lists to populate validation fields: importMissInUse (imported but unused) and useMissInImport (registered but not imported).
Below is the analysis setup and the resulting comparison object:
import patternCollector from 'pattern-collector-anyjs';
const story = patternCollector({
fileContent,
parseRegex: /import\s*\{[^}]*router\s+as\s+(\w+)[^}]*\}\s*from\s*['"]\.\/([^/]+)\/.*['"]/,
searchRegex: /^[ \t]*import\b.*from\s+['"]\.[^'"]*['"];/gm
});
{
"importLines": [...],
"useLines": [...],
"importMissInUse": [
{ "variable": "routerFromv2", "isFound": false }
],
"useMissInImport": [...]
}
Input your routing code, target search expression, and variable extraction pattern to test route analysis mapping directly inside your browser.
The diagram below displays the execution flow through the custom micro-libraries to generate the validation story: