fix: remove public api endpoint

This commit is contained in:
2026-04-11 22:23:38 +02:00
parent 7c61767afa
commit a3acea4d35
2 changed files with 0 additions and 32 deletions

View File

@@ -182,20 +182,6 @@ describe('worker fetch handler', () => {
astroFetchMock.mockResolvedValue(new Response('<html>OK</html>', { status: 200 }));
});
it('should not cache API endpoints', async () => {
const worker = await getWorker();
const request = new Request('https://example.com/api/status');
const envWithPublic = { ...mockEnv, STATUS_PUBLIC: 'true' };
const response = await worker.fetch(request, envWithPublic, mockCtx);
// API endpoint returns JSON, not HTML
expect(response.headers.get('Content-Type')).toBe('application/json');
expect(response.headers.get('Cache-Control')).toBeNull();
expect(mockCaches.default.match).not.toHaveBeenCalled();
expect(mockCaches.default.put).not.toHaveBeenCalled();
});
it('should normalize cache key by removing query parameters', async () => {
const worker = await getWorker();
const request1 = new Request('https://example.com/?t=1234567890');

View File

@@ -7,7 +7,6 @@ import { parseConfig } from './config/index.js';
import { prepareChecks } from './checker/index.js';
import { processResults } from './processor/index.js';
import { formatWebhookPayload } from './alert/index.js';
import { getStatusApiData } from './api/status.js';
import { getMonitorStates, writeCheckResults, updateMonitorStates, recordAlert } from './db.js';
import { interpolateSecrets } from './utils/interpolate.js';
import type { Env } from './types.js';
@@ -18,24 +17,7 @@ import type { Config } from './config/types.js';
const worker = {
async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
const url = new URL(request.url);
if (url.pathname === '/api/status') {
try {
const configYaml = interpolateSecrets(env.MONITORS_CONFIG, env);
const config = parseConfig(configYaml);
const data = await getStatusApiData(env.DB, config);
return new Response(JSON.stringify(data), {
headers: { 'Content-Type': 'application/json' },
});
} catch (error) {
console.error('Status API error:', error);
return new Response(JSON.stringify({ error: 'Internal Server Error' }), {
status: 500,
headers: { 'Content-Type': 'application/json' },
});
}
}
// Auth check for all non-API routes
const authResponse = await checkAuth(request, env);
if (authResponse) {
return authResponse;