type
bun.Serve.Options
type Options<WebSocketData, R extends string = string> = Bun.__internal.XOR<HostnamePortServeOptions<WebSocketData>, UnixServeOptions<WebSocketData>> & Bun.__internal.XOR<FetchOrRoutes<WebSocketData, R>, FetchOrRoutesWithWebSocket<WebSocketData, R>>
Options for serve, with support for routes and a safer requirement for fetch
export default {
fetch: req => Response.json(req.url),
websocket: {
message(ws) {
ws.data.name; // string
},
},
} satisfies Bun.Serve.Options<{ name: string }>;