bunext/examples/custom-server/server.ts
2026-03-29 17:08:10 +01:00

27 lines
566 B
TypeScript

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, server) {
return await bunext.bunextRequestHandler({ req, server });
},
},
},
development,
port,
});
bunext.bunextLog.info(`Server running on http://localhost:${server.port} ...`);