feat(pathRewrite): add 'res' and 'options' to custom pathRewrite function#1247
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe PR extends pathRewrite to pass (path, req, res, options) to rewrite callbacks, updates TypeScript types to include a TRes generic, re-parameters createPathRewriter, wires the rewriter through the middleware, adds tests verifying res/options are passed, and updates docs/changelog. ChangespathRewrite Signature Enhancement
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
commit: |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/types.ts`:
- Around line 76-82: The type for the async pathRewrite callback currently
forces Promise<string>, preventing valid no-op rewrites; update the callback
return type(s) so async handlers can return Promise<string | undefined> (and
ensure the synchronous variant also allows string | undefined) — change
occurrences of Promise<string> to Promise<string | undefined> for the
pathRewrite function type (and string to string | undefined where applicable) so
typings match runtime behavior that treats non-string/undefined as “no rewrite”.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 626fac3a-b051-4726-9fbe-bffb35dfe498
📒 Files selected for processing (9)
CHANGELOG.mdREADME.mdrecipes/pathRewrite.mdsrc/http-proxy-middleware.tssrc/path-rewriter.tssrc/types.tstest/e2e/path-rewriter.spec.tstest/types.spec.tstest/unit/path-rewriter.spec.ts
closes #854
Summary by CodeRabbit
New Features
Documentation