From 7eae5d4b7fa36bd4e3799645f5b0ed7a53a797e9 Mon Sep 17 00:00:00 2001 From: Cellaryllis <95936504+Cellaryllis@users.noreply.github.com> Date: Tue, 12 Jul 2022 10:15:47 +0100 Subject: [PATCH] Add another example for normalizePath --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index 88f6404..2f1af5a 100644 --- a/README.md +++ b/README.md @@ -142,6 +142,17 @@ promBundle.normalizePath = (req, opts) => { }; ``` +#### Example 3 (return express route definition): + +```javascript +app.use(promBundle(/* options? */)); + +promBundle.normalizePath = (req, opts) => { + // Return the path of the express route (i.e. /v1/member/:id or /v1/timer/automated/:userid/:timerid") + return req.route?.path ?? "NULL"; +}; +``` + For more details: * [url-value-parser](https://www.npmjs.com/package/url-value-parser) - magic behind automatic path normalization * [normalizePath.js](https://github.com/jochen-schweizer/express-prom-bundle/blob/master/src/normalizePath.js) - source code for path processing