UNPKG

bknd

Version:

Lightweight Firebase/Supabase alternative built to run anywhere — incl. Next.js, React Router, Astro, Cloudflare, Bun, Node, AWS Lambda & more.

48 lines (47 loc) 2.49 kB
import { App, type CreateAppConfig, type MaybePromise, registries as $registries, type Merge } from ".."; import type { Context, MiddlewareHandler, Next } from "hono"; import type { AdminControllerOptions } from "../modules/server/AdminController"; import type { Manifest } from "vite"; export type BkndConfig<Args = any, Additional = {}> = Merge<CreateAppConfig & Omit<Additional, "app"> & { app?: Omit<BkndConfig<Args, Additional>, "app"> | ((args: Args) => MaybePromise<Omit<BkndConfig<Args, Additional>, "app">>); onBuilt?: (app: App) => MaybePromise<void>; beforeBuild?: (app?: App, registries?: typeof $registries) => MaybePromise<void>; buildConfig?: Parameters<App["build"]>[0]; }>; export type FrameworkBkndConfig<Args = any> = BkndConfig<Args>; export type RuntimeBkndConfig<Args = any> = BkndConfig<Args> & { distPath?: string; serveStatic?: MiddlewareHandler | [string, MiddlewareHandler]; adminOptions?: AdminControllerOptions | false; }; export type DefaultArgs = { [key: string]: any; }; export declare function makeConfig<Args = DefaultArgs>(config: BkndConfig<Args>, args?: Args): Promise<Omit<BkndConfig<Args>, "app">>; export declare function createAdapterApp<Config extends BkndConfig = BkndConfig, Args = DefaultArgs>(config?: Config, args?: Args): Promise<{ app: App; config: BkndConfig<Args>; }>; export declare function createFrameworkApp<Args = DefaultArgs>(config?: FrameworkBkndConfig, args?: Args): Promise<App>; export declare function createRuntimeApp<Args = DefaultArgs>({ serveStatic, adminOptions, ...config }?: RuntimeBkndConfig<Args>, args?: Args): Promise<App>; /** * Creates a middleware handler to serve static assets via dynamic imports. * This is useful for environments where filesystem access is limited but bundled assets can be imported. * * @param manifest - Vite manifest object containing asset information * @returns Hono middleware handler for serving static assets * * @example * ```typescript * import { serveStaticViaImport } from "bknd/adapter"; * * serve({ * serveStatic: serveStaticViaImport(), * }); * ``` */ export declare function serveStaticViaImport(opts?: { manifest?: Manifest; appendRaw?: boolean; package?: string; }): (c: Context, next: Next) => Promise<(Response & import("hono").TypedResponse<any, import("hono/utils/http-status").ContentfulStatusCode, "body">) | (Response & import("hono").TypedResponse<"File not found", 404, "text">) | undefined>;