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); }