bknd
Version:
Lightweight Firebase/Supabase alternative built to run anywhere — incl. Next.js, React Router, Astro, Cloudflare, Bun, Node, AWS Lambda & more.
49 lines (48 loc) • 2.42 kB
TypeScript
import { App, type CreateAppConfig } 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> = CreateAppConfig & {
app?: CreateAppConfig | ((args: Args) => CreateAppConfig);
onBuilt?: (app: App) => Promise<void>;
beforeBuild?: (app: App) => Promise<void>;
buildConfig?: Parameters<App["build"]>[0];
};
export type FrameworkBkndConfig<Args = any> = BkndConfig<Args>;
export type CreateAdapterAppOptions = {
force?: boolean;
id?: string;
};
export type FrameworkOptions = CreateAdapterAppOptions;
export type RuntimeOptions = CreateAdapterAppOptions;
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): CreateAppConfig;
export declare function createAdapterApp<Config extends BkndConfig = BkndConfig, Args = DefaultArgs>(config?: Config, args?: Args, opts?: CreateAdapterAppOptions): Promise<App>;
export declare function createFrameworkApp<Args = DefaultArgs>(config?: FrameworkBkndConfig, args?: Args, opts?: FrameworkOptions): Promise<App>;
export declare function createRuntimeApp<Args = DefaultArgs>({ serveStatic, adminOptions, ...config }?: RuntimeBkndConfig<Args>, args?: Args, opts?: RuntimeOptions): 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;
}): (c: Context, next: Next) => Promise<(Response & import("hono").TypedResponse<null, import("hono/utils/http-status").StatusCode, "body">) | (Response & import("hono").TypedResponse<"File not found", 404, "text">) | undefined>;