Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughThe PR removes a standalone AWS Lambda utility module and consolidates its functionality by refactoring Lambda handlers to use extracted functions from srvx/aws-lambda, while updating the Stormkit preset to use a new encoding helper. This involves deleting utilities and simplifying handler implementations. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/presets/stormkit/runtime/stormkit.ts (1)
56-91: PreferResponse.arrayBuffer()over manual stream plumbing.You can simplify
encodeResponseBodyand droptoBuffer, reducing reliance onWritableStream.pipeTowhile keeping behavior identical.♻️ Proposed simplification
async function encodeResponseBody( response: Response ): Promise<{ body: string; isBase64Encoded?: boolean }> { if (!response.body) { return { body: "" }; } - const buffer = await toBuffer(response.body as any); + const buffer = Buffer.from(await response.arrayBuffer()); const contentType = response.headers.get("content-type") || ""; return isTextType(contentType) ? { body: buffer.toString("utf8") } : { body: buffer.toString("base64"), isBase64Encoded: true }; } @@ -function toBuffer(data: ReadableStream): Promise<Buffer> { - return new Promise<Buffer>((resolve, reject) => { - const chunks: Buffer[] = []; - data - .pipeTo( - new WritableStream({ - write(chunk) { - chunks.push(chunk); - }, - close() { - resolve(Buffer.concat(chunks)); - }, - abort(reason) { - reject(reason); - }, - }) - ) - .catch(reject); - }); -}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/presets/stormkit/runtime/stormkit.ts` around lines 56 - 91, Replace the manual stream plumbing in encodeResponseBody by calling Response.arrayBuffer() instead of toBuffer: if response.body is empty return {body:""} as before, otherwise await response.arrayBuffer(), create a Node Buffer via Buffer.from(arrayBuffer) and use isTextType(contentType) to decide between utf8 string or base64 with isBase64Encoded: true; remove the toBuffer helper entirely and keep the existing isTextType function and header lookup logic to preserve behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/presets/stormkit/runtime/stormkit.ts`:
- Around line 56-91: Replace the manual stream plumbing in encodeResponseBody by
calling Response.arrayBuffer() instead of toBuffer: if response.body is empty
return {body:""} as before, otherwise await response.arrayBuffer(), create a
Node Buffer via Buffer.from(arrayBuffer) and use isTextType(contentType) to
decide between utf8 string or base64 with isBase64Encoded: true; remove the
toBuffer helper entirely and keep the existing isTextType function and header
lookup logic to preserve behavior.
ℹ️ Review info
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
src/presets/aws-lambda/runtime/_utils.tssrc/presets/aws-lambda/runtime/aws-lambda-streaming.tssrc/presets/aws-lambda/runtime/aws-lambda.tssrc/presets/stormkit/runtime/stormkit.ts
💤 Files with no reviewable changes (1)
- src/presets/aws-lambda/runtime/_utils.ts
❓ Type of change
📚 Description
Refactors the Nitro preset to use srvx's AWS lambda compatibility adapter handler.
📝 Checklist