mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-16 04:27:21 +00:00
24 lines
700 B
TypeScript
24 lines
700 B
TypeScript
import { type FrameworkBkndConfig, createFrameworkApp } from "bknd/adapter";
|
|
|
|
type ReactRouterEnv = NodeJS.ProcessEnv;
|
|
type ReactRouterFunctionArgs = {
|
|
request: Request;
|
|
};
|
|
export type ReactRouterBkndConfig<Env = ReactRouterEnv> = FrameworkBkndConfig<Env>;
|
|
|
|
export async function getApp<Env = ReactRouterEnv>(
|
|
config: ReactRouterBkndConfig<Env>,
|
|
args: Env = process.env as Env,
|
|
) {
|
|
return await createFrameworkApp(config, args);
|
|
}
|
|
|
|
export function serve<Env = ReactRouterEnv>(
|
|
config: ReactRouterBkndConfig<Env> = {},
|
|
args: Env = process.env as Env,
|
|
) {
|
|
return async (fnArgs: ReactRouterFunctionArgs) => {
|
|
return (await getApp(config, args)).fetch(fnArgs.request);
|
|
};
|
|
}
|