diff --git a/backend/src/server.test.ts b/backend/src/server.test.ts index e9a5756..5a84dba 100644 --- a/backend/src/server.test.ts +++ b/backend/src/server.test.ts @@ -8,6 +8,8 @@ const initDatastoreMock = vi.fn(() => undefined); const appMock = { register: vi.fn(async () => undefined), + get: vi.fn(), + post: vi.fn(), }; vi.mock('@bytelyst/fastify-core', () => ({ @@ -39,6 +41,8 @@ vi.mock('./lib/config.js', () => ({ }, })); vi.mock('./lib/product-config.js', () => ({ DISPLAY_NAME: 'NoteLett' })); +vi.mock('./lib/feature-flags.js', () => ({ getAllFlags: vi.fn(() => ({})) })); +vi.mock('./lib/telemetry.js', () => ({ getBufferedEvents: vi.fn(() => []), flushEvents: vi.fn(() => []) })); describe('server bootstrap', () => { beforeEach(() => { diff --git a/backend/src/server.ts b/backend/src/server.ts index a58223b..a853ae8 100644 --- a/backend/src/server.ts +++ b/backend/src/server.ts @@ -10,6 +10,8 @@ import { workspaceRoutes } from './modules/workspaces/routes.js'; import { initCosmosIfNeeded } from './lib/cosmos-init.js'; import { initDatastore } from './lib/datastore.js'; import { config } from './lib/config.js'; +import { getAllFlags } from './lib/feature-flags.js'; +import { getBufferedEvents, flushEvents } from './lib/telemetry.js'; import { DISPLAY_NAME } from './lib/product-config.js'; import type { JwtPayload } from './lib/request-context.js'; @@ -53,4 +55,9 @@ await registerApiPlugin(noteTaskRoutes); await registerApiPlugin(savedViewRoutes); await registerApiPlugin(workspaceRoutes); +// ── Diagnostics routes (no auth) ──────────────────────────────── +app.get('/api/diagnostics/flags', async () => getAllFlags()); +app.get('/api/diagnostics/telemetry', async () => ({ events: getBufferedEvents() })); +app.post('/api/diagnostics/telemetry/flush', async () => ({ flushed: flushEvents().length })); + await startService(app, { port: config.PORT, host: config.HOST });