login page
This commit is contained in:
34
server.ts
Normal file
34
server.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { Hono } from "hono";
|
||||
import { upgradeWebSocket, websocket } from "hono/bun";
|
||||
|
||||
const app = new Hono();
|
||||
|
||||
app.get("/", async (c) => {
|
||||
return c.json({
|
||||
message: "ok",
|
||||
});
|
||||
});
|
||||
|
||||
app.get(
|
||||
"/ws",
|
||||
upgradeWebSocket((c) => {
|
||||
return {
|
||||
onOpen(event, ws) {
|
||||
console.log("Server: Connection opened");
|
||||
ws.send("Hello!");
|
||||
},
|
||||
onClose: () => {
|
||||
console.log("Server: Connection closed");
|
||||
},
|
||||
onMessage: (ev) => {
|
||||
console.log(ev.data);
|
||||
},
|
||||
};
|
||||
}),
|
||||
);
|
||||
|
||||
export default {
|
||||
port: Bun.env.SERVER_PORT,
|
||||
fetch: app.fetch,
|
||||
websocket,
|
||||
};
|
||||
Reference in New Issue
Block a user