Skip to content

fix(mapper): recognize aliased Express routers#52

Merged
steipete merged 6 commits into
openclaw:mainfrom
rohitjavvadi:fix/express-router-alias-imports
May 18, 2026
Merged

fix(mapper): recognize aliased Express routers#52
steipete merged 6 commits into
openclaw:mainfrom
rohitjavvadi:fix/express-router-alias-imports

Conversation

@rohitjavvadi
Copy link
Copy Markdown
Contributor

Summary

  • recognize local Express Router factory aliases from ES imports, CommonJS destructuring, and direct Router assignments
  • map routes created through aliased Router factories such as ExpressRouter()
  • keep type-only imports and non-Router Express properties excluded

Tests

  • ./node_modules/.bin/oxfmt src/mappers/node-routes.ts src/mapper.test.ts
  • ./node_modules/.bin/vitest run src/mapper.test.ts
  • ./node_modules/.bin/tsc -p tsconfig.json --noEmit
  • ./node_modules/.bin/oxlint . --config oxlint.json

Follow-up to review feedback on #47.

@steipete steipete merged commit 9930100 into openclaw:main May 18, 2026
6 checks passed
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 91ed022196

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

function expressRouterImportBindingNames(source: string): Set<string> {
const names = new Set<string>();
const pattern =
/(?:^|[;\n])\s*import\s+(?!type\b)((?:(?!\n\s*import\b)[\s\S]){0,400}?)\bfrom\s*["']express["']/gu;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Detect Express imports after inline block comments

The new expressRouterImportBindingNames regex only matches import when it is preceded by start-of-file, ;, or \n, so valid module code like /* banner */ import { Router as R } from 'express' no longer registers R as a Router factory. In that case, const router = R(); router.get(...) routes are silently skipped, which regresses route mapping accuracy for files that keep a header comment on the same line as the first import.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants