From 667e095aacc2ef16b2af37699610d99d1c51d3c3 Mon Sep 17 00:00:00 2001 From: Yasser Lahbibi Date: Fri, 6 Jan 2023 09:16:22 +0100 Subject: [PATCH 1/3] fix: filter unique route/method handlers --- src/scan.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/scan.ts b/src/scan.ts index 7d08777ae9..b9f9af3e89 100644 --- a/src/scan.ts +++ b/src/scan.ts @@ -17,7 +17,9 @@ export async function scanHandlers(nitro: Nitro) { scanRoutes(nitro, "routes", "/"), ]).then((r) => r.flat()); - nitro.scannedHandlers = handlers.flatMap((h) => h.handlers); + nitro.scannedHandlers = handlers.flatMap((h) => h.handlers).filter(({ route, method }, index, array) => { + return array.findIndex((h) => h.route === route && h.method === method) === index; + }); return handlers; } From 1a347ecc29e3287816de26860dbceda2068faeb5 Mon Sep 17 00:00:00 2001 From: Yasser Lahbibi Date: Fri, 6 Jan 2023 09:19:12 +0100 Subject: [PATCH 2/3] lint --- src/scan.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/scan.ts b/src/scan.ts index b9f9af3e89..492939ee20 100644 --- a/src/scan.ts +++ b/src/scan.ts @@ -17,9 +17,14 @@ export async function scanHandlers(nitro: Nitro) { scanRoutes(nitro, "routes", "/"), ]).then((r) => r.flat()); - nitro.scannedHandlers = handlers.flatMap((h) => h.handlers).filter(({ route, method }, index, array) => { - return array.findIndex((h) => h.route === route && h.method === method) === index; - }); + nitro.scannedHandlers = handlers + .flatMap((h) => h.handlers) + .filter(({ route, method }, index, array) => { + return ( + array.findIndex((h) => h.route === route && h.method === method) === + index + ); + }); return handlers; } From b2b6508c0e97c1a9f72e3d1066d216ea81086183 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Mon, 16 Jan 2023 14:04:53 +0100 Subject: [PATCH 3/3] update code style --- src/scan.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/scan.ts b/src/scan.ts index 492939ee20..f0d255c97e 100644 --- a/src/scan.ts +++ b/src/scan.ts @@ -19,10 +19,11 @@ export async function scanHandlers(nitro: Nitro) { nitro.scannedHandlers = handlers .flatMap((h) => h.handlers) - .filter(({ route, method }, index, array) => { + .filter((h, index, array) => { return ( - array.findIndex((h) => h.route === route && h.method === method) === - index + array.findIndex( + (h2) => h.route === h2.route && h.method === h2.method + ) === index ); });