unified runtime and framework adapters

This commit is contained in:
dswbx committed 2024-12-24 09:43:16 +01:00
1 parent c1e92e503b
commit 76da14294c
20 files changed
+276 -253

No files matched your search

+6 -5
View File
@@ -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);
};