Skip to content

feat: Hono framework support for all providers#15

Merged
Blankll merged 8 commits into
masterfrom
feat/hono-support
Jun 26, 2026
Merged

feat: Hono framework support for all providers#15
Blankll merged 8 commits into
masterfrom
feat/hono-support

Conversation

@Blankll

@Blankll Blankll commented Jun 26, 2026

Copy link
Copy Markdown
Member

Summary

Add Hono framework support to serverless-adapter. Hono uses Web API Request/Response (not Node.js http streams), so a new honoHandler bridges ServerlessRequest → Web API Request → app.fetch() → Web API Response → ServerlessResponse.

Changes

Core Implementation

  • src/framework.ts: Added honoHandler() function and .fetch duck-type detection before existing Koa/Express checks
  • src/index.ts: Widened app type to accept HonoApp; HandlerResult includes multiValueHeaders
  • src/types/index.ts: Added HonoApp type; ServerlessResponse and ServerlessAdapter include multiValueHeaders

Provider Response Pipeline (multiValueHeaders)

  • src/types/aliyun.ts, src/types/tencent.ts, src/types/volcengine.ts: Added multiValueHeaders to response types
  • src/providers/aliyun.ts, src/providers/tencent.ts, src/providers/volcengine.ts: formatResponse() now passes through multiValueHeaders
  • src/transport.ts: sanitizeHeaders keeps multi-value set-cookie in multiValueHeaders only (RFC 6265 compliance)

Testing

  • Unit tests: Hono detection + handler round-trip + type acceptance (3 tests)
  • Aliyun integration: 21 scenarios (happy, status codes, query/path params, JSON/text/raw/binary/base64 bodies, headers, set-cookie, 404, 500, methods, isBase64Encoded flag)
  • Tencent integration: 7 scenarios (happy, JSON body, query params, custom headers, 404, 500, response format)
  • Volcengine integration: 7 scenarios (same coverage)

Documentation

  • Hono 4.x added to Supported Frameworks table
  • Hono quickstart example
  • API Reference updated with Hono type
  • Node >= 18 requirement documented

Key Design Decisions

  1. No Hono dependency in production code — duck-typing via typeof app.fetch === "function"
  2. Detection order: Hono (fetch) → Koa (callback) → Express (function) — prevents false positives
  3. Node 18/20+ compatibility: getSetCookie() used on Node 20+; Headers.forEach fallback on Node 18
  4. Set-Cookie handling: Single cookies → headers as string; multiple → multiValueHeaders as array (RFC-compliant)

Fixes #14

Blankll and others added 7 commits June 26, 2026 16:56
Ultraworked with Sisyphus

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with Sisyphus

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with Sisyphus

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with Sisyphus

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with Sisyphus

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with Sisyphus

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with Sisyphus

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
@codecov

codecov Bot commented Jun 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.88889% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.68%. Comparing base (30e98f4) to head (799a324).

Files with missing lines Patch % Lines
src/framework.ts 88.88% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #15      +/-   ##
==========================================
- Coverage   93.17%   92.68%   -0.50%     
==========================================
  Files          13       13              
  Lines         293      328      +35     
  Branches       59       72      +13     
==========================================
+ Hits          273      304      +31     
- Misses         15       17       +2     
- Partials        5        7       +2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

…noHandler

Covers Array.isArray(value) branch (line 24) and hasBody=true path.

Ultraworked with Sisyphus

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
@Blankll Blankll merged commit b9c2a65 into master Jun 26, 2026
2 of 4 checks passed
@Blankll Blankll deleted the feat/hono-support branch June 26, 2026 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Hono framework support for all providers

1 participant