Open Blankeos opened 1 week ago
Since Bun.serve doesn't have http.Incoming and http.ServerResponse, I'm wondering how to implement an equivalent of this Node code in Bun.
Bun.serve
http.Incoming
http.ServerResponse
In Node:
import { Hono } from 'hono' import { serve, type HttpBindings } from '@hono/node-server' import type { ViteDevServer } from 'vite' const base = process.env.BASE || '/' const app = new Hono<{ Bindings: HttpBindings }>() let vite: ViteDevServer if (!isProduction) { const { createServer } = await import('vite') vite = await createServer({ server: { middlewareMode: true }, appType: 'custom', base }) app.use(async (c, next) => { const viteDevMiddleware = () => new Promise<void>((resolve) => { vite.middlewares(c.env.incoming, c.env.outgoing, () => resolve()) }); await viteDevMiddleware() await next() }) } serve({ fetch: app.fetch, port });
Maybe an adapter for Bun.serve with http.Incoming and http.ServerResponse if it's possible?
No response
this is not an issue in bun. you cannot use connect middleware directly with Bun.serve. you should use express or polka or fastify with @fastify/middie
express
polka
fastify
@fastify/middie
What is the problem this feature would solve?
Since
Bun.serve
doesn't havehttp.Incoming
andhttp.ServerResponse
, I'm wondering how to implement an equivalent of this Node code in Bun.In Node:
What is the feature you are proposing to solve the problem?
Maybe an adapter for Bun.serve with
http.Incoming
andhttp.ServerResponse
if it's possible?What alternatives have you considered?
No response