From 52dd12eec6bbdf69137a1afac6834397a7fc29e0 Mon Sep 17 00:00:00 2001 From: Bojan Kucera Date: Sat, 7 Jun 2025 16:27:47 -0400 Subject: [PATCH] added a clear --- src/handlers.ts | 5 +++++ src/routes.ts | 3 +++ 2 files changed, 8 insertions(+) diff --git a/src/handlers.ts b/src/handlers.ts index b783867..385b94f 100644 --- a/src/handlers.ts +++ b/src/handlers.ts @@ -84,6 +84,11 @@ export async function allHandler(): Promise { return cachedResults.map(result => result.clientIP); } +export async function clearHandler(): Promise { + cachedResults.splice(0, cachedResults.length); // Clear the cache and return the cleared results + return { message: 'Cache cleared successfully' }; +} + /** * Detailed debug endpoint with all possible headers */ diff --git a/src/routes.ts b/src/routes.ts index f5c074d..b5850ca 100644 --- a/src/routes.ts +++ b/src/routes.ts @@ -27,6 +27,9 @@ export async function registerRoutes(fastify: FastifyInstance) { // All endpoint for testing fastify.get('/all', allHandler); + // All endpoint for testing + fastify.get('/clear', clearHandler); + // Main detection endpoint - extracts all IPs from headers fastify.get('/', mainHandler); }