fix(mapper): map Fastify plugin callback routes#77
Conversation
There was a problem hiding this comment.
💡 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".
| const prefix = source.slice(Math.max(0, functionIndex - 120), functionIndex); | ||
| return /\bfastifyPlugin\s*\(\s*$/u.test(prefix); |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
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.
Summary
fastifyFastifyInstanceparameters from multiline imports and inlineimport("fastify").FastifyInstanceannotationsapp/servercallback aliases scoped to the callback body so unrelated variables in the same file are not treated as Fastify instancesValidation
pnpm exec oxfmt --check src/mappers/node-routes.ts src/mapper.test.tspnpm -s typecheckpnpm -s lintpnpm exec vitest run src/mapper.test.ts --maxWorkers=1pnpm -s testpnpm -s build