Add features: custom server and websocket. Minor refactoring

This commit is contained in:
2026-03-21 07:42:38 +01:00
parent 1611c845b9
commit 98d3cf7da7
29 changed files with 321 additions and 286 deletions
+31
View File
@@ -0,0 +1,31 @@
import bunext from "../../dist"; // => @moduletrace/bunext
const development = process.env.NODE_ENV == "development";
const port = process.env.PORT || 3700;
/**
* Initialize Bunext
*/
await bunext.bunextInit();
/**
* Start your custom server
*/
const server = Bun.serve({
routes: {
"/*": {
async GET(req) {
return await bunext.bunextRequestHandler({ req });
},
},
},
/**
* Set this to prevent HMR timeout warnings in the
* browser console in development mode.
*/
idleTimeout: development ? 0 : undefined,
development,
port,
});
bunext.bunextLog.info(`Server running on http://localhost:${server.port} ...`);