added a clear

This commit is contained in:
Bojan Kucera 2025-06-07 16:27:47 -04:00
parent 60c76f1d55
commit 52dd12eec6
2 changed files with 8 additions and 0 deletions

View file

@ -84,6 +84,11 @@ export async function allHandler(): Promise<string[] | { message: string }> {
return cachedResults.map(result => result.clientIP);
}
export async function clearHandler(): Promise<string[] | { message: string }> {
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
*/

View file

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