honojs / node-server

Node.js Server for Hono
https://hono.dev
306 stars 42 forks source link

Unix domain socket support #89

Open MrFoxPro opened 8 months ago

TransparentLC commented 1 month ago

It seems that you can fill the socket's path directly in the port:

const app = new Hono;
const uds = '/var/run/foobar.sock';

if (fs.existsSync(uds)) {
    fs.unlinkSync(uds);
}
serve({
    fetch: app.fetch,
    hostname: 'localhost',
    port: uds as any,
});
fs.chmodSync(uds, 666);