import type { Layer } from "../layer/index.js"; import type { AnyService, Service } from "../service/index.js"; export type FromFnClosure = (req: Request, next: Next) => Promise | Response; /** * Creates a layer from a function. * * @example * ```ts * import { fromFn } from "@taxum/core/middleware/from-fn"; * import { m, Router } from "@taxum/core/routing"; * * const router = new Router() * .route("/", m.get(() => "Hello World)) * .layer(fromFn((req, next) => { * // do something with `req` * * const res = await next.invoke(req); * * // do something with `res` * * return res; * })); * ``` */ export declare const fromFn: (f: FromFnClosure) => FromFnLayer; /** * A layer that wraps a service with a function. * * @see {@link fromFn} */ export declare class FromFnLayer implements Layer, Next> { private readonly f; /** * Creates a new {@link FromFnLayer}. */ constructor(f: FromFnClosure); layer(inner: Next): Service; }