UNPKG

@promster/express

Version:

Express server integrations of promster

28 lines (27 loc) 1.26 kB
import type { TRequestRecorder } from '@promster/metrics'; import { Prometheus } from '@promster/metrics'; import type { TLabelValues, TOptionalPromsterOptions } from '@promster/types'; import type { Application, NextFunction, Request, Response } from 'express'; interface TApp extends Application { locals: Record<string, unknown>; } type TLocaleTarget = { app?: TApp; key: string; value: typeof Prometheus | TRequestRecorder; }; declare const exposeOnLocals: ({ app, key, value }: TLocaleTarget) => void; declare const extractPath: (req: Request) => string; declare const getRequestRecorder: () => TRequestRecorder; declare const signalIsUp: () => void; declare const signalIsNotUp: () => void; type TSkipFunction = <TRequest = Request, TResponse = Response>(_req: TRequest, _res: TResponse, _labels: TLabelValues) => boolean; export type TPromsterOptions = TOptionalPromsterOptions & { skip?: TSkipFunction; }; type TMiddlewareOptions = { app?: TApp; options?: TPromsterOptions; }; declare const createMiddleware: ({ app, options }?: TMiddlewareOptions) => (request: Request, response: Response, next: NextFunction) => void; export { createMiddleware, exposeOnLocals, extractPath, getRequestRecorder, signalIsUp, signalIsNotUp, };