mirror of
https://github.com/bknd-io/bknd/
synced 2026-08-02 08:06:00 +00:00
3f26c45dd9
* refactored adapters to run test suites * fix bun version for tests * added missing adapter tests and refactored examples to use `bknd.config.ts` where applicable
26 lines
725 B
TypeScript
26 lines
725 B
TypeScript
import { type FrameworkBkndConfig, createFrameworkApp, type FrameworkOptions } 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,
|
|
opts: FrameworkOptions = {},
|
|
) {
|
|
return await createFrameworkApp(config, args ?? import.meta.env, opts);
|
|
}
|
|
|
|
export function serve<Env = AstroEnv>(
|
|
config: AstroBkndConfig<Env> = {},
|
|
args: Env = {} as Env,
|
|
opts?: FrameworkOptions,
|
|
) {
|
|
return async (fnArgs: TAstro) => {
|
|
return (await getApp(config, args, opts)).fetch(fnArgs.request);
|
|
};
|
|
}
|