mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-17 21:06:04 +00:00
unified runtime and framework adapters
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
import { App, type CreateAppConfig } from "bknd";
|
||||
import { type FrameworkBkndConfig, createFrameworkApp } from "adapter";
|
||||
import type { App } from "bknd";
|
||||
|
||||
export type RemixBkndConfig = FrameworkBkndConfig;
|
||||
|
||||
let app: App;
|
||||
export function serve(config: CreateAppConfig & { beforeBuild?: (app: App) => Promise<void> }) {
|
||||
export function serve(config: RemixBkndConfig = {}) {
|
||||
return async (args: { request: Request }) => {
|
||||
if (!app) {
|
||||
app = App.create(config);
|
||||
await config.beforeBuild?.(app);
|
||||
await app.build();
|
||||
app = await createFrameworkApp(config);
|
||||
}
|
||||
return app.fetch(args.request);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user