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
+9 -10
View File
@@ -2,24 +2,23 @@ import type { ServeOptions } from "bun";
import grabAppPort from "../../utils/grab-app-port";
import isDevelopment from "../../utils/is-development";
import bunextRequestHandler from "./bunext-req-handler";
import grabConfig from "../grab-config";
import _ from "lodash";
type Params = {
dev?: boolean;
};
export default async function (params?: Params): Promise<ServeOptions> {
export default async function (): Promise<ServeOptions> {
const port = grabAppPort();
const is_dev = isDevelopment();
const development = isDevelopment();
const config = await grabConfig();
return {
async fetch(req, server) {
return await bunextRequestHandler({ req });
},
port,
// idleTimeout: 0,
development: {
hmr: true,
},
idleTimeout: development ? 0 : undefined,
development,
websocket: config?.websocket,
..._.omit(config?.serverOptions || {}, ["fetch"]),
} as ServeOptions;
}