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( config: CloudflareBkndConfig, args?: CfMakeConfigArgs, opts?: RuntimeOptions, ) { return await createRuntimeApp(makeConfig(config, args), args?.env, opts); } export async function getFresh( config: CloudflareBkndConfig, ctx: Context, opts: RuntimeOptions = {}, ) { return await makeApp( { ...config, onBuilt: async (app) => { registerAsyncsExecutionContext(app, ctx.ctx); await config.onBuilt?.(app); }, }, ctx, opts, ); }