import type { Schema } from 'hono'; import type { HonoBase } from 'hono/hono-base'; import type { BindingsDefs } from '@fastly/compute-js-context'; import { type BindingsWithClientInfo, type HandleOptions } from './handler.js'; /** * Registers a Hono app to handle fetch events in Fastly Compute. * * This sets up `addEventListener('fetch', handle(app, envBindingsDefs, options))` * using the bindings you passed to `buildFire()`. * * @param app - The Hono application instance to serve * @param options - Options for handling requests (fetch defaults to undefined) * * @example * const fire = buildFire({ foo: "KVStore" }); * * type Env = { * Variables: Variables; * Bindings: typeof fire.Bindings; * }; * * const app = new Hono(); * fire(app); */ type FireFn = { (app: HonoBase<(keyof D extends never ? {} : never) & V, S, BasePath>, options?: HandleOptions): void; (app: HonoBase<{ Bindings: BindingsWithClientInfo; } & V, S, BasePath>, options?: HandleOptions): void; /** * The inferred bindings type, derived from the defs passed to `buildFire()`. * Use this in your Env definition: `{ Bindings: typeof fire.Bindings }`. */ Bindings: BindingsWithClientInfo; /** For debugging: the raw defs object you passed to buildFire */ _defs: D; }; /** * Creates a `fire` function bound to a specific set of environment bindings. * * Call `buildFire()` with the shape of your bindings. The returned `fire` function * registers your Hono app to handle fetch events in Fastly Compute, and also exposes * a `.Bindings` type you can use when defining your `Env`. * * ### Example: With bindings * ```ts * const fire = buildFire({ grip: "ConfigStore", foo: "KVStore" }); * * type Env = { * Variables: Variables, * Bindings: typeof fire.Bindings, // infer binding types automatically * }; * * const app = new Hono(); * fire(app); * ``` * * ### Example: No bindings * ```ts * const fire = buildFire({}); * * const app = new Hono(); * fire(app); * ``` * * @param bindingsDefs - A mapping of binding names to binding types * (e.g. `{ foo: "KVStore", bar: "ConfigStore" }`). * @returns A `fire` function that: * - Registers your Hono app to handle fetch events * - Applies `bindingsDefs` to `c.env` * - Exposes a `.Bindings` type inferred from the given defs */ export declare function buildFire(bindingsDefs: D): FireFn; /** * Registers your Hono app to handle fetch events. No user-defined bindings are * applied to `c.env`. * `fire.Bindings` is a type you can use when defining your `Env`, * providing access to platform-defined bindings such as `clientInfo` and * `serverInfo`. */ export declare const fire: FireFn<{}>; /** * Default bindings which can be used when no user-defined bindings are present. * Alias of `fire.Bindings`. */ export type Bindings = typeof fire.Bindings; export {}; //# sourceMappingURL=fire.d.ts.map