Replies: 2 comments 4 replies
-
Do you mean https://www.npmjs.com/package/http-server or Node.js's
Yes, I don't think there is an (easy) way to port these to the new Request/Response standard. If you want to use these middlewares, then you'll have to use HatTip's
IIRC @cyco130 was (considering) working on this. |
Beta Was this translation helpful? Give feedback.
-
Hi @bholmesdev, Thanks for the feedback. This is how I use Node middlewares ( // entry-node.js
import { createServer } from 'node:http';
import sirv from 'sirv';
import { createMiddleware } from '@hattip/adapter-node';
import hattipHandler from './entry-hattip.js';
const sirvMiddleware = sirv('public');
const hattipMiddleware = createMiddleware(hattipHandler);
createServer((req, res) =>
sirvMiddleware(req, res, () => hattipMiddleware(req, res))
).listen(3000, () => {
console.log(`Server listening on http://localhost:3000`);
}); Here's a live example. The idea is that your HatTip app (which lives in On static file serving middleware, it's on the map but I didn't prioritize it because all target platforms have their on semi-automatic way to handle static files anyway. Node doesn't, but I used to use HatTip almost exclusively in combination with vavite which handles it for me. Now HatTip has its own CLI and Vite plugin which makes it even easier. In addition to the issue @brillout has opened, we've had some discussion on how to proceed: #45. Now that we have a form data parser, cross-platform filesystem handling (where it makes sense) is the next logical step. Even on platforms that don't have a filesystem, having something backed by other storage media like memory, S3, KV stores, Redis etc might make sense. A static file server would be then more or less trivial to implement. |
Beta Was this translation helpful? Give feedback.
-
By @bholmesdev:
Beta Was this translation helpful? Give feedback.
All reactions