[glm-grade=A-] fix: drift test walker recognizes buildRouter() object exports (routes/version.js)
The direct-mounts walker silently skipped route modules exporting
{ buildRouter } objects instead of function factories, causing a false
stale-entry failure for /api/v1/version. Normalize object exports with
a buildRouter method to the factory before the typeof-function check.
Only version.js uses this shape (verified across routes/). Full suite
1837/1837. Adversarial review: A-, no blocking issues; follow-up: warn
on unrecognized export shapes.
This commit is contained in:
@@ -131,6 +131,7 @@ function readMountedRoutes() {
|
||||
'routes/license.js', // apiRouter.use('/license', licenseRoutes({...}))
|
||||
'routes/share.js', // apiRouter.use(shareRoutes({...})) // bare mount (DC-053)
|
||||
'routes/services.js', // apiRouter.use(serviceRoutes({...})) // bare mount — needed for /api/v1/services + /api/v1/services/status PUBLIC_ROUTES
|
||||
'routes/version.js', // apiRouter.use(versionRoute.buildRouter()) // bare mount — needed for /api/v1/version PUBLIC_ROUTES
|
||||
];
|
||||
// Prefix map: explicit prefix from src/app.js's apiRouter.use() call
|
||||
const prefixMap = {
|
||||
@@ -151,6 +152,12 @@ function readMountedRoutes() {
|
||||
try {
|
||||
factory = require(fullPath);
|
||||
} catch (e) { continue; }
|
||||
// Support object exports that expose buildRouter() (e.g. routes/version.js
|
||||
// exports { buildRouter, getVersion, getName }) — normalize to the factory
|
||||
// so the walker sees the routes it actually mounts in production.
|
||||
if (factory && typeof factory.buildRouter === 'function') {
|
||||
factory = factory.buildRouter;
|
||||
}
|
||||
if (typeof factory !== 'function') continue;
|
||||
let router;
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user