UNPKG

kobp

Version:
32 lines (31 loc) 1.25 kB
import type { KobpServiceContext, Middleware } from '../context'; import { Loggy } from '..'; export declare type AuditMessagePipelineEventType = 'start' | 'success' | 'error'; /** * AuditMessage pipeline callback. * * @param message - a original message that previous pipeline has produced. * @param event - the event denote what has in particular event. * @param context - the request's context. * @param error - error computed by errorPipeline. */ export declare type AuditMessagePipeline = (message: string, event: AuditMessagePipelineEventType, context: KobpServiceContext, error?: Error) => string; export declare const withJson: () => Middleware; export declare const withJsonConfig: { /** * Ideal place to wrap the error before it emit via reponse.json() */ errorPipeline: ((err: any, loggy?: Loggy) => Error)[]; /** * Run 2 times per API call. * * - First when API has been first called: event = 'start' * - Second when API has deem service will returns which can be either: event = 'success' or 'error' */ auditMessagePipeline: AuditMessagePipeline[]; /** * path that this middleware should ignored. * Default to `/healthcheck` */ suppressPath: string; };