Using Elysia
Bullet inside an Elysia server
bullet() returns an H3 application with a standard .fetch handler. Elysia's .mount() accepts any WinterTC-compliant fetch handler, so you can embed Bullet at the root and add your own Elysia routes alongside it.
Install Elysia
Create server.ts
Mount Bullet at / so it handles everything Elysia does not match first. Calling .listen() starts the Bun server, which supports WebSocket natively and handles Bullet's HMR and DevTools upgrade requests without extra configuration.
import { bullet } from "@clutchify/bullet-server";
import { Elysia } from "elysia";
import configuration from "./rspack.config.ts";
const port = Number(process.env.REPACK_PORT ?? 8081);
const bulletApp = await bullet({
configuration,
mode: process.env.NODE_ENV === "production" ? "production" : "development",
environments: {
client: "client",
server: "server",
android: "android",
ios: "ios",
},
development: { port },
});
const app = new Elysia()
.get("/health", () => ({ status: "ok" }))
.mount("/", bulletApp.fetch)
.listen(port);Elysia handles routes you register explicitly. Any request that falls through reaches mount("/", ...) and goes to Bullet.
Node.js
Elysia's primary runtime is Bun. For Node.js, install @elysiajs/node and replace .listen() with serve() from crossws/server to keep the WebSocket upgrade path working.
import { bullet } from "@clutchify/bullet-server";
import { node } from "@elysiajs/node";
import { Elysia } from "elysia";
import { serve } from "crossws/server";
import configuration from "./rspack.config.ts";
const port = Number(process.env.REPACK_PORT ?? 8081);
const host = process.env.REPACK_HOST;
const bulletApp = await bullet({
configuration,
mode: process.env.NODE_ENV === "production" ? "production" : "development",
environments: {
client: "client",
server: "server",
android: "android",
ios: "ios",
},
development: { port, host },
});
const app = new Elysia({ adapter: node() })
.get("/health", () => ({ status: "ok" }))
.mount("/", bulletApp.fetch);
serve({ fetch: (request) => app.handle(request), hostname: host, port, websocket: {} });