Skip to content

Instantly share code, notes, and snippets.

@czfadmin
Last active April 8, 2024 14:39
Show Gist options
  • Select an option

  • Save czfadmin/f5bffc10dd089aad6fd2052da5c456be to your computer and use it in GitHub Desktop.

Select an option

Save czfadmin/f5bffc10dd089aad6fd2052da5c456be to your computer and use it in GitHub Desktop.
honojs+socket.io
import { serve } from '@hono/node-server';
import { Hono } from 'hono';
import { Server } from 'socket.io';
import { Server as HttpServer } from 'http';
const app = new Hono();
app.get('/', (c) => {
return c.text('Hello Hono!');
});
const server = serve(
{
fetch: app.fetch,
port: 3000,
},
(info) => {
console.log(`Server is running: http://${info.address}:${info.port}`);
}
);
const ioServer = new Server(server as HttpServer, {
path: '/ws',
serveClient: false,
});
ioServer.on("error", (err) => {
console.log(err)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment