diff --git a/src/api-manager.js b/src/api-manager.js index a17125d..b4f849d 100644 --- a/src/api-manager.js +++ b/src/api-manager.js @@ -18,27 +18,7 @@ import { * @returns {Promise} - True if the request was handled by API */ export async function handleAPIRequests(method, path, req, res, currentConfig, apiService, providerPoolManager, promptLogFilename) { - // Health check endpoint - if (method === 'GET' && path === '/health') { - res.writeHead(200, { 'Content-Type': 'application/json' }); - res.end(JSON.stringify({ - status: 'healthy', - timestamp: new Date().toISOString(), - provider: currentConfig.MODEL_PROVIDER - })); - return true; - } - // Ignore count_tokens requests - if (path.includes('/count_tokens')) { - console.log(`[Server] Ignoring count_tokens request: ${path}`); - res.writeHead(200, { 'Content-Type': 'application/json' }); - res.end(JSON.stringify({ - tokens: 0, - message: 'Token counting is not supported' - })); - return true; - } // Route model list requests if (method === 'GET') { diff --git a/src/request-handler.js b/src/request-handler.js index 4afdff5..aea628e 100644 --- a/src/request-handler.js +++ b/src/request-handler.js @@ -80,6 +80,28 @@ export function createRequestHandler(config, providerPoolManager) { } return; } + + // Health check endpoint + if (method === 'GET' && path === '/health') { + res.writeHead(200, { 'Content-Type': 'application/json' }); + res.end(JSON.stringify({ + status: 'healthy', + timestamp: new Date().toISOString(), + provider: currentConfig.MODEL_PROVIDER + })); + return true; + } + + // Ignore count_tokens requests + if (path.includes('/count_tokens')) { + console.log(`[Server] Ignoring count_tokens request: ${path}`); + res.writeHead(200, { 'Content-Type': 'application/json' }); + res.end(JSON.stringify({ + tokens: 0, + message: 'Token counting is not supported' + })); + return true; + } // Check authentication for API requests if (!isAuthorized(req, requestUrl, currentConfig.REQUIRED_API_KEY)) {