Closed juliusmarminge closed 1 month ago
The latest updates on your projects. Learn more about Vercel for Git ↗︎
Name | Status | Preview | Comments | Updated (UTC) |
---|---|---|---|---|
docs-uploadthing | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Oct 16, 2024 7:47am |
Latest commit: 3718df260f9cb19562546e7f21cd6f5d1507b230
Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.
Click here to learn what changesets are, and how to add one.
Click here if you're a maintainer who wants to add a changeset to this PR
The changes involve modifications to the createRouteHandler
function in packages/uploadthing/src/server.ts
, allowing it to accept an event object that may contain a request
property. This enhances the function's ability to handle different input structures. Additionally, a new test case has been added to the test suite in packages/uploadthing/test/adapters.test.ts
to verify that the handler can process requests encapsulated within an object, ensuring compatibility with various middleware functions.
File Path | Change Summary |
---|---|
packages/uploadthing/src/server.ts | Modified createRouteHandler to accept an event object ev , checking for ev.request . |
packages/uploadthing/test/adapters.test.ts | Added a new test case to verify the handler's ability to accept an object containing a request. |
In the meadow where bunnies play,
A handler now works in a new way!
With events that bring requests near,
Our tests now cheer, "Let's give a cheer!"
For every hop and every bound,
Flexibility's joy is truly found! 🐇✨
packages/uploadthing/src/server.ts (2)
`27-32`: **LGTM! This change improves flexibility in handling middleware arguments.** The modification to `createRouteHandler` now allows it to handle both direct `Request` objects and objects containing a `request` property. This change: 1. Addresses the PR objective of fixing args in middleware when using object syntax. 2. Improves flexibility without breaking existing functionality. 3. Ensures compatibility with various middleware functions that might wrap the request in an object. The implementation is correct and uses the `in` operator to safely check for the presence of the `request` property. --- `27-32`: **Verify usage of `createRouteHandler` across the codebase** While the changes to `createRouteHandler` improve its flexibility, it's important to ensure that this modification doesn't introduce any unintended side effects in other parts of the codebase that might be using this function. Let's run a script to check the usage of `createRouteHandler` across the codebase: This script will help us identify any potential areas that might need adjustment due to the changes in `createRouteHandler`.✅ Verification successful
**Usage of `createRouteHandler` verified across the codebase** All instances of `createRouteHandler` have been reviewed, and no unintended side effects were found from the recent changes. The modifications in `packages/uploadthing/src/server.ts` are isolated and maintain compatibility with existing implementations.🏁 Scripts executed
The following scripts were executed for the analysis: Script: ```shell #!/bin/bash # Description: Check usage of createRouteHandler across the codebase # Search for createRouteHandler usage echo "Searching for createRouteHandler usage:" rg --type typescript -A 5 "createRouteHandler" # Search for potential direct Request usage with createRouteHandler echo "\nSearching for potential direct Request usage with createRouteHandler:" rg --type typescript -A 5 "createRouteHandler.*Request" ``` Length of output: 416 --- Script: ```shell #!/bin/bash # Description: Check usage of createRouteHandler across the codebase # Search for createRouteHandler usage in .ts and .tsx files echo "Searching for createRouteHandler usage in .ts and .tsx files:" rg "createRouteHandler" --type-add 'ts=*.ts' --type-add 'tsx=*.tsx' -t ts -t tsx -A 5 # Search for potential direct Request usage with createRouteHandler in .ts and .tsx files echo "\nSearching for potential direct Request usage with createRouteHandler in .ts and .tsx files:" rg "createRouteHandler.*Request" --type-add 'ts=*.ts' --type-add 'tsx=*.tsx' -t ts -t tsx -A 5 ``` Length of output: 632 --- Script: ```shell #!/bin/bash # Description: Check usage of createRouteHandler across the codebase # Search for createRouteHandler usage in .ts and .tsx files echo "Searching for createRouteHandler usage in .ts and .tsx files:" rg "createRouteHandler" -g "*.ts" -g "*.tsx" -A 5 # Search for potential direct Request usage with createRouteHandler in .ts and .tsx files echo "\nSearching for potential direct Request usage with createRouteHandler in .ts and .tsx files:" rg "createRouteHandler.*Request" -g "*.ts" -g "*.tsx" -A 5 ``` Length of output: 36480packages/uploadthing/test/adapters.test.ts (2)
`238-294`: **LGTM! New test case effectively covers object syntax for request handling.** This new test case is a valuable addition as it verifies the correct handling of middleware args when using object syntax. It aligns well with the PR objectives and maintains consistency with existing test structures. The test comprehensively checks: 1. Correct handler creation and execution 2. Proper middleware invocation with expected arguments 3. Accurate response generation 4. Asynchronous metadata registration at UploadThing This test enhances the robustness of the adapter implementation and ensures compatibility with various request handling scenarios. --- Line range hint `1-1180`: **Overall, the changes enhance the test coverage without disrupting existing tests.** The addition of the new test case "accepts object with request in" to the "adapters:server" section is the only significant change in this file. This new test integrates seamlessly with the existing test suite, maintaining consistency in structure and naming conventions. It effectively addresses the PR objective of correcting args in middleware when using object syntax. The test suites for other adapters (h3, next, next-legacy, express, fastify, and effect-platform) remain unchanged, preserving the overall integrity of the test file.
Bundle | Size (gzip) | Visualization |
---|---|---|
Main | 26.11KB | See Treemap 📊 |
PR (0ae31070845c3943cb53e5d48ad3a33e390df9c3) | 26.11KB | See Treemap 📊 |
Diff | No change |
- [@example/minimal-appdir](https://pkg.pr.new/template/a1cb0123-738c-4d57-b585-854255b212a4) - [@example/minimal-astro-react](https://pkg.pr.new/template/7703882e-cb8d-45b4-a9fb-5eca61326ece) - [@example/minimal-expo](https://pkg.pr.new/template/c267f2c4-9447-47ce-9488-fb870f53ecf7) - [@example/minimal-nuxt](https://pkg.pr.new/template/d4120a92-d875-4d6f-9f19-81279b7c9a3d) - [@example/minimal-pagedir](https://pkg.pr.new/template/d502cf7f-af03-4107-805e-1c1abc692ff9) - [@example/minimal-solidstart](https://pkg.pr.new/template/c2980165-fcbd-47cd-a05a-3404f59f8118) - [@example/minimal-sveltekit](https://pkg.pr.new/template/841c6ed4-0f20-49df-8bd2-acb3fa52f232) - [@example/minimal-tanstack-start](https://pkg.pr.new/template/5afff95d-1fef-43e8-9179-c3a244f96995)
pnpm add https://pkg.pr.new/pingdotgg/uploadthing@1017
commit: 3718df2
Fixes: https://discord.com/channels/966627436387266600/1295885646916878366/1295886403095236718
Summary by CodeRabbit
New Features
Bug Fixes
Tests