UNPKG

@fedify/fedify

Version:

An ActivityPub server framework

45 lines 1.75 kB
/** * Fedify with Hono * ================ * * This module provides a [Hono] middleware to integrate with the Fedify. * * [Hono]: https://hono.dev/ * * @module * @since 0.6.0 */ import type { Federation } from "../federation/federation.js"; interface HonoRequest { raw: Request; } interface HonoContext { req: HonoRequest; res: Response; } type HonoMiddleware<THonoContext extends HonoContext> = (ctx: THonoContext, next: () => Promise<void>) => Promise<Response | void>; /** * A factory function to create a context data for the {@link Federation} * object. * * @typeParam TContextData A type of the context data for the {@link Federation} * object. * @typeParam THonoContext A type of the Hono context. * @param context A Hono context object. * @returns A context data for the {@link Federation} object. */ export type ContextDataFactory<TContextData, THonoContext> = (context: THonoContext) => TContextData | Promise<TContextData>; /** * Create a Hono middleware to integrate with the {@link Federation} object. * * @typeParam TContextData A type of the context data for the {@link Federation} * object. * @typeParam THonoContext A type of the Hono context. * @param federation A {@link Federation} object to integrate with Hono. * @param contextDataFactory A function to create a context data for the * {@link Federation} object. * @returns A Hono middleware. */ export declare function federation<TContextData, THonoContext extends HonoContext>(federation: Federation<TContextData>, contextDataFactory: ContextDataFactory<TContextData, THonoContext>): HonoMiddleware<THonoContext>; export {}; //# sourceMappingURL=hono.d.ts.map