added adapter exports, generalized env-depending config construction

This commit is contained in:
dswbx
2025-01-25 11:54:19 +01:00
parent acc504cdc9
commit 9ddacb7ae5
11 changed files with 53 additions and 35 deletions

View File

@@ -1,13 +1,19 @@
import { type FrameworkBkndConfig, createFrameworkApp } from "adapter";
import type { App } from "bknd";
export type RemixBkndConfig = FrameworkBkndConfig;
export type RemixBkndConfig<Args = RemixContext> = FrameworkBkndConfig<Args>;
type RemixContext = {
request: Request;
};
let app: App;
export function serve(config: RemixBkndConfig = {}) {
return async (args: { request: Request }) => {
export function serve<Args extends RemixContext = RemixContext>(
config: RemixBkndConfig<Args> = {}
) {
return async (args: Args) => {
if (!app) {
app = await createFrameworkApp(config);
app = await createFrameworkApp(config, args);
}
return app.fetch(args.request);
};