import type express from 'express'; import type prometheus from 'prom-client'; import type { AggregatorStrategy } from './enums'; export interface LabelSet { [name: string]: string; } export interface CustomParams { percentiles?: number[]; buckets?: number[]; labelNames?: string[]; aggregator?: AggregatorStrategy; } // weird class to allow polymorphism over constructors yielding type Metric export class MetricConstructor< T extends string = string, U extends any[] = any[], > { constructor(public construct: new (...args: U) => prometheus.Metric) {} public create(...args: U): prometheus.Metric { return new this.construct(...args); } } export interface MetricsMap { gauge: { [name: string]: prometheus.Gauge }; counter: { [name: string]: prometheus.Counter }; histogram: { [name: string]: prometheus.Histogram }; summary: { [name: string]: prometheus.Summary }; } export type Kind = keyof MetricsMap; export interface MetricsMeta { kind: Kind; help: string; customParams: CustomParams; } export interface MetricsMetaMap { [name: string]: MetricsMeta; } export type AuthTestFunc = (req: express.Request) => boolean;