import { IChassisContext, IChassisPlugin, IChassisMiddleware, IOperation } from "../index"; import { Request, Handler } from "express"; import { Operation } from "../openapi/"; /** * plugin to create a pipeline of middleware (including before/after policies) * * @param context * @param options * @returns {exports} */ export declare class PipelinePlugin implements IChassisPlugin { name: string; title: string; context: IChassisContext; policies: any; middleware: PipelineMiddleware; install(context: IChassisContext, _options: any): void; } /** * generate middleware that excecutes pipeline for an operation/feature including before/after policies */ export declare class PipelineMiddleware implements IChassisMiddleware { protected plugin: PipelinePlugin; name: string; title: string; constructor(plugin: PipelinePlugin, _name?: string); fn(oper: IOperation, _ignored: any): Function; pipleine(oper: IOperation): Handler[]; /** * some sugar to make finding middleware sweeter .. * * @param name */ feature(name: string): IChassisMiddleware; prioritize(policies: any): Handler[]; /** * Turn a set of named middleware configs into a pipeline * * @param oper * @param configs */ policy_middleware(oper: IOperation, configs: any): any; /** * Creates 'express' middleware that allows policies to be executed 'after' the response 'res.end()' is generated. * * @param oper * @param after */ afterware(oper: IOperation, after: Function[], pipeline_names?: string[]): Function; /** * basic request tracking accounting * * @param oper * @param request_uuid * @param req */ metrics(oper: IOperation, request_id: string, req: Request): void; /** * generate a UUID for each request * * @param req * @param now */ request_uuid(req: Request, now: number): any; /** * Prometheus metric labels for an request / operation * * @param oper * @param req * @param request_uuid */ metric_labels(oper: IOperation, req: Request, request_id: string): { method: string; path: string; request_id: string; resource: string; operationId: string; actionId: string; }; /** * inject trace into pipeline * * @param stage * @param _pipeline */ tracing(oper: Operation, stage: string, _pipeline: Function[], policyNames: []): void; }