Merge pull request #56 from Collaborne/pr/middleware-result

Declare that the metricsMiddleware is accessible on the bundle as well
This commit is contained in:
Konstantin Pogorelov
2020-10-06 12:48:39 +02:00
committed by GitHub
2 changed files with 8 additions and 4 deletions

6
types/index.d.ts vendored
View File

@@ -46,6 +46,10 @@ declare namespace express_prom_bundle {
};
}
interface Middleware extends RequestHandler {
metricsMiddleware: RequestHandler;
}
const normalizePath: NormalizePathFn;
const normalizeStatusCode: NormalizeStatusCodeFn;
@@ -57,4 +61,4 @@ interface express_prom_bundle {
normalizeStatusCode: express_prom_bundle.NormalizeStatusCodeFn;
}
declare function express_prom_bundle(opts: express_prom_bundle.Opts): RequestHandler;
declare function express_prom_bundle(opts: express_prom_bundle.Opts): express_prom_bundle.Middleware;

View File

@@ -3,7 +3,7 @@ import * as promClient from 'prom-client';
import * as promBundle from 'express-prom-bundle';
// $ExpectType RequestHandler
// $ExpectType Middleware
const middleware: RequestHandler = promBundle({ includeMethod: true });
// $ExpectType: string
@@ -11,7 +11,7 @@ middleware.name;
promClient.register.clear();
// $ExpectType RequestHandler
// $ExpectType Middleware
promBundle({
normalizePath: [
// collect paths like "/customer/johnbobson" as just one "/custom/#name"
@@ -30,7 +30,7 @@ promBundle({
promClient.register.clear();
// $ExpectType RequestHandler
// $ExpectType Middleware
promBundle({
buckets: [0.1, 0.4, 0.7],
includeMethod: true,