From 9d151a4bc2e5af837c32399a751b6325f85cbbd8 Mon Sep 17 00:00:00 2001 From: Ashley Smith Date: Fri, 1 Nov 2024 12:49:47 -0600 Subject: [PATCH 1/5] middleware try catch fix --- src/middleware/metrics.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/middleware/metrics.ts b/src/middleware/metrics.ts index cd832b1..e9b6015 100644 --- a/src/middleware/metrics.ts +++ b/src/middleware/metrics.ts @@ -80,11 +80,16 @@ const makeMetricsApiMiddleware = (options: Options = {}) => { return false; } - if (route.path.match(path)) { - return true; + try { + if (route.path.match(path)) { + return true; + } } - - return false; + catch(e: unknown){ + logger.error(`Unable to perform regex match on path: ${e}`); + return false; + } + return false; })[0]?.pattern; if (discardUnmatched && !pattern) { From c3cd6a9f1a4b5b9e21ab29ac78774bce13a2d5cf Mon Sep 17 00:00:00 2001 From: Ashley Smith Date: Fri, 1 Nov 2024 12:52:19 -0600 Subject: [PATCH 2/5] linting fix --- src/middleware/metrics.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/middleware/metrics.ts b/src/middleware/metrics.ts index e9b6015..5648feb 100644 --- a/src/middleware/metrics.ts +++ b/src/middleware/metrics.ts @@ -84,12 +84,11 @@ const makeMetricsApiMiddleware = (options: Options = {}) => { if (route.path.match(path)) { return true; } - } - catch(e: unknown){ + } catch (e: unknown) { logger.error(`Unable to perform regex match on path: ${e}`); return false; } - return false; + return false; })[0]?.pattern; if (discardUnmatched && !pattern) { From 34392f55dc876b9fe65e4e42d26d720d4e30dc15 Mon Sep 17 00:00:00 2001 From: Ashley Smith Date: Fri, 1 Nov 2024 14:50:45 -0600 Subject: [PATCH 3/5] non specific error message --- src/middleware/metrics.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/middleware/metrics.ts b/src/middleware/metrics.ts index 5648feb..a245c01 100644 --- a/src/middleware/metrics.ts +++ b/src/middleware/metrics.ts @@ -85,7 +85,7 @@ const makeMetricsApiMiddleware = (options: Options = {}) => { return true; } } catch (e: unknown) { - logger.error(`Unable to perform regex match on path: ${e}`); + logger.error(`Error: something went wrong.`); return false; } return false; From 68fd2b83e285cd792a8da0161da91080276cf435 Mon Sep 17 00:00:00 2001 From: Ashley Smith Date: Fri, 1 Nov 2024 14:52:20 -0600 Subject: [PATCH 4/5] lint fix --- src/middleware/metrics.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/middleware/metrics.ts b/src/middleware/metrics.ts index a245c01..00f8cc5 100644 --- a/src/middleware/metrics.ts +++ b/src/middleware/metrics.ts @@ -85,7 +85,7 @@ const makeMetricsApiMiddleware = (options: Options = {}) => { return true; } } catch (e: unknown) { - logger.error(`Error: something went wrong.`); + logger.error("Error: something went wrong."); return false; } return false; From 3d705b412de59588968b90fda19958bfc1db38e9 Mon Sep 17 00:00:00 2001 From: Ashley Smith Date: Fri, 1 Nov 2024 14:53:37 -0600 Subject: [PATCH 5/5] linting fix --- src/middleware/metrics.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/middleware/metrics.ts b/src/middleware/metrics.ts index 00f8cc5..70a0945 100644 --- a/src/middleware/metrics.ts +++ b/src/middleware/metrics.ts @@ -85,7 +85,7 @@ const makeMetricsApiMiddleware = (options: Options = {}) => { return true; } } catch (e: unknown) { - logger.error("Error: something went wrong."); + logger.error('Error: something went wrong.'); return false; } return false;