-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Simplify upload-url implementation #2451
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThe changes consolidate multiple upload URL endpoints into a single, parameterized API route for generating signed upload URLs within a workspace. The UI components are updated to use the new unified endpoint and provide a folder name in the request body. Legacy endpoints and their handlers are removed. Additionally, a new resume upload URL endpoint with CORS and rate limiting is introduced. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant UI_Component
participant API_Endpoint
participant Storage_Service
User->>UI_Component: Selects file to upload
UI_Component->>API_Endpoint: POST /api/workspaces/{workspaceId}/upload-url { folder }
API_Endpoint->>Storage_Service: Request signed URL for {folder}/{nanoid}
Storage_Service-->>API_Endpoint: Returns signed URL and key
API_Endpoint-->>UI_Component: Responds with signed URL and key
UI_Component->>Storage_Service: Uploads file to signed URL
Storage_Service-->>UI_Component: Confirms upload
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (3)
💤 Files with no reviewable changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (1)
🔇 Additional comments (2)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
apps/web/app/api/workspaces/[idOrSlug]/upload-url/route.ts (1)
12-20: Well-designed unified endpoint with room for error handling improvement.The implementation successfully consolidates upload URL generation into a single, flexible endpoint. The key generation pattern and response format are appropriate.
Consider adding explicit error handling for the storage operation:
export const POST = withWorkspace(async ({ req }) => { const { folder } = schema.parse(await req.json()); const key = `${folder}/${nanoid(16)}`; - const signedUrl = await storage.getSignedUrl(key); + try { + const signedUrl = await storage.getSignedUrl(key); + return NextResponse.json({ key, signedUrl }); + } catch (error) { + return NextResponse.json({ error: "Failed to generate upload URL" }, { status: 500 }); + } - - return NextResponse.json({ key, signedUrl }); });
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
apps/web/app/api/oauth/apps/upload-url/route.ts(0 hunks)apps/web/app/api/workspaces/[idOrSlug]/import/csv/upload-url/route.ts(0 hunks)apps/web/app/api/workspaces/[idOrSlug]/upload-url/route.ts(1 hunks)apps/web/ui/oauth-apps/add-edit-app-form.tsx(1 hunks)apps/web/ui/oauth-apps/add-edit-integration-form.tsx(1 hunks)
💤 Files with no reviewable changes (2)
- apps/web/app/api/workspaces/[idOrSlug]/import/csv/upload-url/route.ts
- apps/web/app/api/oauth/apps/upload-url/route.ts
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: build
🔇 Additional comments (2)
apps/web/ui/oauth-apps/add-edit-integration-form.tsx (1)
65-70: LGTM! Clean migration to the new unified upload endpoint.The refactoring correctly updates the API call to use the new parameterized endpoint with explicit folder specification. The change from query parameters to JSON body makes the API more RESTful and clearer about the upload destination.
apps/web/ui/oauth-apps/add-edit-app-form.tsx (1)
150-155: Consistent migration pattern - looks good!The changes mirror those in the integration form, maintaining consistency across the codebase. Both files correctly use the same folder name "integration-screenshots" for OAuth app screenshots.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
apps/web/app/api/resumes/upload-url/route.ts(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
apps/web/app/api/resumes/upload-url/route.ts (2)
apps/web/lib/storage.ts (1)
storage(151-151)packages/utils/src/constants/main.ts (1)
R2_URL(77-77)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: build
🔇 Additional comments (2)
apps/web/app/api/resumes/upload-url/route.ts (2)
1-4: LGTM - Clean imports.All imports are necessary and properly used throughout the file.
18-18: LGTM - Appropriate key generation.Using
nanoid(16)with the "resumes/" prefix provides good uniqueness and organization.
Summary by CodeRabbit
New Features
Refactor
Chores