mirror of
https://github.com/bknd-io/bknd/
synced 2026-08-02 08:06:00 +00:00
30 lines
912 B
TypeScript
30 lines
912 B
TypeScript
import { createRuntimeApp, type RuntimeOptions } from "bknd/adapter";
|
|
import type { CloudflareBkndConfig, Context, CloudflareEnv } from "../index";
|
|
import { makeConfig, registerAsyncsExecutionContext, type CfMakeConfigArgs } from "../config";
|
|
|
|
export async function makeApp<Env extends CloudflareEnv = CloudflareEnv>(
|
|
config: CloudflareBkndConfig<Env>,
|
|
args?: CfMakeConfigArgs<Env>,
|
|
opts?: RuntimeOptions,
|
|
) {
|
|
return await createRuntimeApp<Env>(makeConfig(config, args), args?.env, opts);
|
|
}
|
|
|
|
export async function getFresh<Env extends CloudflareEnv = CloudflareEnv>(
|
|
config: CloudflareBkndConfig<Env>,
|
|
ctx: Context<Env>,
|
|
opts: RuntimeOptions = {},
|
|
) {
|
|
return await makeApp(
|
|
{
|
|
...config,
|
|
onBuilt: async (app) => {
|
|
registerAsyncsExecutionContext(app, ctx.ctx);
|
|
await config.onBuilt?.(app);
|
|
},
|
|
},
|
|
ctx,
|
|
opts,
|
|
);
|
|
}
|