mirror of
https://github.com/bknd-io/bknd/
synced 2026-08-03 00:26:01 +00:00
21 lines
621 B
TypeScript
21 lines
621 B
TypeScript
import { type FrameworkBkndConfig, createFrameworkApp } from "bknd/adapter";
|
|
|
|
type AstroEnv = NodeJS.ProcessEnv;
|
|
type TAstro = {
|
|
request: Request;
|
|
};
|
|
export type AstroBkndConfig<Env = AstroEnv> = FrameworkBkndConfig<Env>;
|
|
|
|
export async function getApp<Env = AstroEnv>(
|
|
config: AstroBkndConfig<Env> = {},
|
|
args: Env = {} as Env,
|
|
) {
|
|
return await createFrameworkApp(config, args ?? import.meta.env);
|
|
}
|
|
|
|
export function serve<Env = AstroEnv>(config: AstroBkndConfig<Env> = {}, args: Env = {} as Env) {
|
|
return async (fnArgs: TAstro) => {
|
|
return (await getApp(config, args)).fetch(fnArgs.request);
|
|
};
|
|
}
|