From a1284ec3e5b507568fd6a9420e5ba8e9a3dc68a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Asbj=C3=B8rn=20Dyhrberg=20Thegler?= Date: Fri, 17 Jun 2022 21:01:03 +0200 Subject: [PATCH] Add test for typings --- types/test.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/types/test.ts b/types/test.ts index 42061b5..176cd54 100644 --- a/types/test.ts +++ b/types/test.ts @@ -1,10 +1,11 @@ -import { Request, RequestHandler, Response } from 'express'; +import * as express from 'express'; + import * as promClient from 'prom-client'; import * as promBundle from 'express-prom-bundle'; // $ExpectType Middleware -const middleware: RequestHandler = promBundle({ includeMethod: true }); +const middleware: express.RequestHandler = promBundle({ includeMethod: true }); // $ExpectType: string middleware.name; @@ -57,7 +58,8 @@ promBundle({ normalizePath: [ ['^/foo', '/example'] // replace /foo with /example ], - formatStatusCode: (res: Response) => res.statusCode + 100 + formatStatusCode: (res: express.Response) => res.statusCode + 100, + metricsApp: express() }); promClient.register.clear(); @@ -79,14 +81,14 @@ promBundle({ type Writable = { -readonly [K in keyof T]: T[K] }; const wPromBundle: Writable = promBundle; -wPromBundle.normalizePath = (req: Request, opts: promBundle.Opts) => { +wPromBundle.normalizePath = (req: express.Request, opts: promBundle.Opts) => { const path = promBundle.normalizePath(req, opts); // count all docs as one path, but /docs/login as a separate one return path.match(/^\/docs/) && !path.match(/^\/login/) ? '/docs/*' : path; }; -wPromBundle.normalizeStatusCode = (res: Response) => res.statusCode.toString(); +wPromBundle.normalizeStatusCode = (res: express.Response) => res.statusCode.toString(); // $ExpectType RequestHandler promBundle.clusterMetrics();