@fedify/fedify
Version:
An ActivityPub server framework
48 lines (47 loc) • 1.97 kB
TypeScript
import { Temporal } from "@js-temporal/polyfill";
import { URLPattern } from "urlpattern-polyfill";
import "../kv-DRaeSXco.js";
import "../docloader-Q42SMRIB.js";
import "../client-DvtwXO7t.js";
import "../vocab-CzEfWQk2.js";
import "../actor-CPpvuBKU.js";
import "../http-DMTrO3Ye.js";
import "../owner-D0cOz8R5.js";
import "../mod-CDzlVCUF.js";
import "../lookup-Bf-K85bV.js";
import { Federation } from "../context-OBWjptjU.js";
import "../mq-DYKDDJmp.js";
//#region x/hono.d.ts
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.
*/
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.
*/
declare function federation<TContextData, THonoContext extends HonoContext>(federation: Federation<TContextData>, contextDataFactory: ContextDataFactory<TContextData, THonoContext>): HonoMiddleware<THonoContext>;
//#endregion
export { ContextDataFactory, federation };