diff --git a/src/handlers.ts b/src/handlers.ts index 3332b77..b783867 100644 --- a/src/handlers.ts +++ b/src/handlers.ts @@ -77,6 +77,13 @@ export async function randomHandler(): Promise { + if (cachedResults.length === 0) { + return { message: 'No data yet' }; + } + return cachedResults.map(result => result.clientIP); +} + /** * Detailed debug endpoint with all possible headers */ diff --git a/src/routes.ts b/src/routes.ts index 29020d6..f5c074d 100644 --- a/src/routes.ts +++ b/src/routes.ts @@ -6,7 +6,8 @@ import { FastifyInstance } from 'fastify'; import { healthHandler, mainHandler, - randomHandler, + randomHandler, + allHandler, detailedDebugHandler } from './handlers'; @@ -20,9 +21,12 @@ export async function registerRoutes(fastify: FastifyInstance) { // Detailed debug endpoint (bypasses authentication) fastify.get('/ip-debug-detailed', detailedDebugHandler); - // Main detection endpoint - extracts all IPs from headers - fastify.get('/', mainHandler); - // Random endpoint for testing fastify.get('/random', randomHandler); + + // All endpoint for testing + fastify.get('/all', allHandler); + + // Main detection endpoint - extracts all IPs from headers + fastify.get('/', mainHandler); }