fix: pass Koa response to setHeaders#156
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuidePasses Koa's high-level response object into the setHeaders callback instead of the raw Node response, and aligns types, tests, and documentation with this behavior. Sequence diagram for updated setHeaders invocation in sendsequenceDiagram
participant KoaMiddleware
participant send
participant SetHeaders
participant KoaResponse
KoaMiddleware->>send: send(ctx, root, options)
send->>SetHeaders: setHeaders(ctx.response, filePath, stats)
send->>KoaResponse: set(Content-Length, stats.size)
send->>KoaResponse: set(Last-Modified, stats.mtime.toUTCString())
File-Level Changes
Assessment against linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThe 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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 |
Fixes #130.
Summary
ctx.responseobject to thesetHeaderscallback instead of the raw Node response.SetHeaderstype and README wording to describe the Koa response argument.setHeadersregression test to use Koa response methods such asresponse.set()andresponse.get().Root Cause
setHeaderswas receivingctx.res, which requires callers to bypass Koa's response abstraction and use raw Node response methods. Koa documents that bypassing Koa's response handling is unsupported, and callers commonly need Koa response helpers when deciding whether to set cache headers.Validation
npx jest test/index.test.ts --runInBand --testNamePattern='setHeaders'npm testnpm run lint(passes with the existingsendcomplexity warning)npm run buildgit diff --checkSummary by Sourcery
Route Koa send header injection through the Koa response abstraction instead of the raw Node response, and align types, docs, and tests with the updated callback signature.
Bug Fixes:
Enhancements:
Documentation:
Tests:
Summary by CodeRabbit
Bug Fixes
setHeaderscallback to provide Koa’s response object, enabling standard response methods such asset()andget().Content-Lengthoverrides.Documentation
setHeaderscallback signature and response parameter in the documentation.