Added Typescript definitions

This commit is contained in:
Ciaran Liedeman
2019-04-04 11:25:32 +02:00
parent cb128c7520
commit 6b49ffab08
2 changed files with 49 additions and 0 deletions

45
index.d.ts vendored Normal file
View File

@@ -0,0 +1,45 @@
import * as express from "express";
import { DefaultMetricsCollectorConfiguration } from "prom-client";
type NormalizePathRegexs = [string, string];
interface Labels {
[key: string]: string | number;
}
interface Opts {
autoregister?: boolean;
buckets?: [number];
includeStatusCode?: boolean;
includeMethod?: boolean;
includePath?: boolean;
includeUp?: boolean;
metricType?: "summary" | "histogram";
metricsPath?: string;
promClient?: DefaultMetricsCollectorConfiguration;
normalizePath?: NormalizePathRegexs;
formatStatusCode?: (res: express.Response) => number | string;
transformLabels: (
labels: Labels,
req: express.Request,
res: express.Response
) => Labels;
// https://github.com/disjunction/url-value-parser#options
urlValueParser?: {
minHexLength?: number;
minBase64Length?: number;
replaceMasks?: string[];
extraMasks?: string[];
};
}
export function normalizePath(
req: express.Request,
opts?: { normalizePath?: NormalizePathRegexs }
);
export default function(opts: Opts): express.RequestHandler;

View File

@@ -10,6 +10,10 @@
"path",
"method"
],
"files": [
"src",
"index.d.ts"
],
"scripts": {
"test": "node_modules/jasme/run.js",
"coverage": "make coverage"