Skip to content

fix(mapper): map Fastify plugin callback routes#77

Open
rohitjavvadi wants to merge 2 commits into
openclaw:mainfrom
rohitjavvadi:fix/fastify-plugin-param-routes
Open

fix(mapper): map Fastify plugin callback routes#77
rohitjavvadi wants to merge 2 commits into
openclaw:mainfrom
rohitjavvadi:fix/fastify-plugin-param-routes

Conversation

@rohitjavvadi
Copy link
Copy Markdown
Contributor

Summary

  • map Fastify routes declared inside typed plugin callback functions instead of only callbacks named fastify
  • support FastifyInstance parameters from multiline imports and inline import("fastify").FastifyInstance annotations
  • keep app/server callback aliases scoped to the callback body so unrelated variables in the same file are not treated as Fastify instances

Validation

  • pnpm exec oxfmt --check src/mappers/node-routes.ts src/mapper.test.ts
  • pnpm -s typecheck
  • pnpm -s lint
  • pnpm exec vitest run src/mapper.test.ts --maxWorkers=1
  • pnpm -s test
  • pnpm -s build

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: 29e3458328

ℹ️ 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".

Comment thread src/mappers/node-routes.ts Outdated
Comment on lines +750 to +751
const prefix = source.slice(Math.max(0, functionIndex - 120), functionIndex);
return /\bfastifyPlugin\s*\(\s*$/u.test(prefix);
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 aliased/generic fastify-plugin callback invocations

The new plugin-scoped detection only treats callbacks as Fastify plugin callbacks when the immediate prefix matches fastifyPlugin( exactly, so routes are missed when projects use common patterns like import fp from "fastify-plugin"; fp(async (app) => ...) or typed invocations like fastifyPlugin<MyOpts>(async (app) => ...). In those cases app/server parameters are never promoted to Fastify targets, and valid Fastify routes are silently dropped from mapping.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 56b98f2. The mapper now collects local fastify-plugin call bindings from aliased imports, generic wrapper calls, TypeScript import-equals, require("fastify-plugin"), and require("fastify-plugin").default, with regression coverage for each reported route-mapping case.

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.

1 participant