-
-
Notifications
You must be signed in to change notification settings - Fork 578
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move Node.js serveStatic to this repo #3483
Comments
I basically agree to move Node.js serveStatic to this repo. As you said, we can change Or, to make creating serveStatic easy, I have an idea. export const serveStatic: ServeStatic = defineServeStatic({
async open(path: string): ReadableStream<Uint8Array> {
// ...
}
}) In this idea, we can bundle common processes in on one place. And modifying API interface is easy. And, in my opinion, I don't like to move Node.js adapter to this repo. Runtimes which this repo supports as adapter such as Deno, Cloudflare Workers, and Bun are using Request/Response API. In contrast it's necessary to translate Request/Response for using Node.js. The process can't be called as small. So I think it's good that Node.js adapter is in other repo. |
I think it is more natural to have the entire Node.js adapter here, since
But it's OK for me to move only |
I'd avoid using it from |
I'll propose to move the Node.js Server's Serve Static Middleware in
honojs/node-server
to thishonojs/hono
repo.Create
serveStatic
inhono/nodejs
As mentioned in the comment: honojs/node-server#203, we have a base implementation of Serve Static Middleware, but Node.js Server(
@hono/node-server
developed inhonojs/node-server
) does not use it. That implements the same logic, and there are lots of duplicated stuff.We can use the base Serve Static Middleware in the
honojs/node-server
, but there are problems:honojs/node-server
should follow it.peerDependecies
(hono
package) inpackage.json
ofhonojs/node-server
.This is the pain point. So I considered and and found that it's good to move the Node.js Server's Server Static to this repo like:
This means we create a Node.js Adapter (not an "Adapter Server") like the adapters for Cloudflare Workers, Deno, and Bun.
Should The Node.js Server be in the independent repo?
@exoego said in the comment:
I can understand that opinion, but the Node.js Server should be
honojs/node-server
though the Serve Static for Node.js will be in this main repo.Node.js almost completely has Web Standards APIs like
fetch
,Request
,Respoense
, etc. But Node.js does not have an "entry point" for Web Standards APIs.For Cloudflare Workers, Deno, and Bun, we can run the following app with one command:
Below is Bun case:
However, how to run the app on Node.js?? The answer is we have to convert Node.js's HTTP API
IncomingMessage
andOutgoingMessage
to Web Standards'Request
andReponse
. The Node.js Server is doing that.How about making it an adapter in this repo like
hono/cloudflare-workers
orhono/bun
orhono/deno
? They are for adapting between differences in runtimes. For example, Serve Static and WebSockets. However, the role of converting Node.js's API between Web Standards is improper. It assumes a greater role. So, keep usinghono/node-server
is good.Plus,
@hono/node-server
is used in other packages like@hono/vite-dev-server
as an independent library againsthono
package.Next Actions
Shall we move the Server Static in
hono/node-server
to this repo?hono/node-server
. Close feat(serve-static): support absolute path forroot
node-server#202hono/node-server
as deprecated.serveStatic
inhono/nodejs
, which uses Serve Static base implementation in this repo.peerDependcies
of@hono/node-server
.The text was updated successfully, but these errors were encountered: