From d2f0088f3cc6ca867ba3a0e8b40e25341d51b50f Mon Sep 17 00:00:00 2001 From: Andreas Kohn Date: Thu, 9 Apr 2020 19:20:56 +0200 Subject: [PATCH] Declare that the metricsMiddleware is accessible on the bundle as well Related-to: #49 --- types/index.d.ts | 6 +++++- types/test.ts | 6 +++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/types/index.d.ts b/types/index.d.ts index 1a77877..3f2acb2 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -44,6 +44,10 @@ declare namespace express_prom_bundle { }; } + interface Middleware extends RequestHandler { + metricsMiddleware: RequestHandler; + } + const normalizePath: NormalizePathFn; const normalizeStatusCode: NormalizeStatusCodeFn; @@ -55,4 +59,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; diff --git a/types/test.ts b/types/test.ts index 2a7c21e..1586506 100644 --- a/types/test.ts +++ b/types/test.ts @@ -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,