You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Publish a thin @hono/perry-server (or @perryts/hono-server, name TBD) npm package that exposes Hono's standard adapter contract — serve({ fetch: app.fetch, port, hostname? }) — on Perry-native, wrapping Perry's bundled Fastify (perry-ext-fastify). The package is ~100 lines of TypeScript and absorbs the Perry-specific quirks in one well-tested place rather than every downstream app vendoring its own shim (which is the status quo across perry/playground/server/router.ts, perry/compile/server/router.ts, perry/shop/src/platform/serve.ts).
Why
#487 closed "as a side effect" of #577 — the idea being that node:http would work end-to-end and @hono/node-server would suffice. In practice today: #1652 (node:http link gap) and #1651 (node:http2 missing exports) both still block @hono/node-server. A dedicated Perry adapter:
Decouples Hono-on-Perry from the upstream @hono/node-server package (which we don't control and which keeps pulling more Node-stdlib symbols).
Gives a single, versioned, Perry-org-owned place to absorb perry-ext-fastify quirks (reply.code vs reply.status flakiness, method-binding restrictions, etc. — all currently spread across multiple downstream repos).
Matches the per-runtime adapter pattern Hono uses elsewhere (@hono/node-server, @hono/bun, @hono/deno, Workers built-in) — Hono users find this familiar.
New repo: PerryTS/hono-perry-server (or in-tree under packages/), published as @hono/perry-server (preferred — namespace consistency with @hono/node-server, @hono/bun) or @perryts/hono-server (fallback if @hono namespace requires Hono-org coordination).
Source ships with perry: ./src/index.ts export + src/ in files (canonical Perry-package shape, like @perryts/mysql).
Acceptance test: a 5-line Hono app — app.get('/', c => c.json({ ok: true })) + serve({ fetch: app.fetch, port: 3000 }) — compiles via perry compile, listens on 3000, returns {"ok":true} to curl localhost:3000/, identical bytes to the same app under node --import tsx with @hono/node-server.
Documented in docs/src/stdlib/http.md (alongside the existing "Hono" section).
Related
Hono acceptance: @hono/perry-server adapter (4th acceptance bullet of #421) #487 (closed) — original plan: "either inside perry-stdlib (or perry-ext-fastify-style external crate)" — option 1. This issue ships option 2 (npm package), which we now think is the cleaner shape since it lets per-runtime adapter selection match how Hono itself works on every other platform.
Scope
Publish a thin
@hono/perry-server(or@perryts/hono-server, name TBD) npm package that exposes Hono's standard adapter contract —serve({ fetch: app.fetch, port, hostname? })— on Perry-native, wrapping Perry's bundled Fastify (perry-ext-fastify). The package is ~100 lines of TypeScript and absorbs the Perry-specific quirks in one well-tested place rather than every downstream app vendoring its own shim (which is the status quo acrossperry/playground/server/router.ts,perry/compile/server/router.ts,perry/shop/src/platform/serve.ts).Why
#487 closed "as a side effect" of #577 — the idea being that node:http would work end-to-end and
@hono/node-serverwould suffice. In practice today: #1652 (node:http link gap) and #1651 (node:http2 missing exports) both still block@hono/node-server. A dedicated Perry adapter:@hono/node-serverpackage (which we don't control and which keeps pulling more Node-stdlib symbols).perry-ext-fastifyquirks (reply.codevsreply.statusflakiness, method-binding restrictions, etc. — all currently spread across multiple downstream repos).@hono/node-server,@hono/bun,@hono/deno, Workers built-in) — Hono users find this familiar.Hard blockers (must land first)
Request.headersis a numeric handle. The adapter's hot path isawait app.fetch(new Request(url, { method, headers, body })); inside Hono,c.req.headers.get(...)immediately throws on the current numeric handle. The adapter is structurally impossible until this lands.Soft blockers (nice-to-have)
Response.bodytyping. Without it, the adapter mustawait res.text()(buffer-then-send); with it, we can stream straight through.Proposed surface
```typescript
// @hono/perry-server/src/index.ts
import fastify from 'fastify'
import type { Hono } from 'hono'
export interface ServeOptions {
fetch: Hono['fetch']
port: number
hostname?: string
}
export interface ServeInfo {
port: number
address: string
family: 'IPv4' | 'IPv6'
}
export function serve(opts: ServeOptions, listener?: (info: ServeInfo) => void): void {
const app = fastify({ logger: false })
app.all('/*', async (req, reply) => {
const url = `http://${req.headers.host}${req.url}`
const headers = new Headers()
for (const [k, v] of Object.entries(req.headers)) {
if (Array.isArray(v)) v.forEach((vv) => headers.append(k, String(vv)))
else if (v !== undefined) headers.set(k, String(v))
}
const method = req.method ?? 'GET'
const hasBody = method !== 'GET' && method !== 'HEAD'
})
app.listen({ port: opts.port, host: opts.hostname ?? '0.0.0.0' }, (err, address) => {
if (err) throw err
listener?.({ port: opts.port, address, family: address.includes(':') ? 'IPv6' : 'IPv4' })
})
}
```
Acceptance
PerryTS/hono-perry-server(or in-tree underpackages/), published as@hono/perry-server(preferred — namespace consistency with@hono/node-server,@hono/bun) or@perryts/hono-server(fallback if@hononamespace requires Hono-org coordination).perry: ./src/index.tsexport +src/infiles(canonical Perry-package shape, like@perryts/mysql).app.get('/', c => c.json({ ok: true }))+serve({ fetch: app.fetch, port: 3000 })— compiles viaperry compile, listens on 3000, returns{"ok":true}tocurl localhost:3000/, identical bytes to the same app undernode --import tsxwith@hono/node-server.c.html(<Component/>)(needs hono/jsx: <Component/> evaluates to undefined under Perry native compile #1653) round-trips through the adapter and emits real HTML.docs/src/stdlib/http.md(alongside the existing "Hono" section).Related
@hono/node-serveronce node:http/http2 land).