7.4 billion tokens per month. 34 free LLM providers. 635 free model endpoints. All behind one /v1 endpoint, plus any custom OpenAI-compatible endpoint. Smart routing, automatic failover, encrypted keys. Personal experimentation only.
TypeScript
test: adapt contributed analytics/redaction tests to dashboard-auth gating
Tashfeenc5b09143f29a
diff --git a/server/src/__tests__/routes/analytics.test.ts b/server/src/__tests__/routes/analytics.test.tsindex baa168f1..07eeba5d 100644--- a/server/src/__tests__/routes/analytics.test.ts+++ b/server/src/__tests__/routes/analytics.test.ts@@ -2,13 +2,18 @@ import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'viteimport type { Express } from 'express';import { createApp } from '../../app.js';import { getDb, initDb } from '../../db/index.js';+import { mintDashboardToken, isGatedApiPath } from '../helpers/auth.js';++let dashToken = '';async function request(app: Express, path: string) {const server = app.listen(0);const addr = server.address() as any;const url = `http://127.0.0.1:${addr.port}${path}`;- const res = await fetch(url);+ const res = await fetch(url, {+ headers: isGatedApiPath(path) ? { Authorization: `Bearer ${dashToken}` } : {},+ });const data = await res.json().catch(() => null);server.close();@@ -30,6 +35,7 @@ describe('Analytics API', () => {process.env.ENCRYPTION_KEY = '0'.repeat(64);initDb(':memory:');app = createApp();+ dashToken = mintDashboardToken();});beforeEach(() => {diff --git a/server/src/__tests__/routes/proxy-error-redaction.test.ts b/server/src/__tests__/routes/proxy-error-redaction.test.tsindex a14c3f18..1751b99e 100644--- a/server/src/__tests__/routes/proxy-error-redaction.test.ts+++ b/server/src/__tests__/routes/proxy-error-redaction.test.ts@@ -2,6 +2,9 @@ import { describe, it, expect, beforeAll, beforeEach, afterEach, vi } from 'viteimport type { Express } from 'express';import { createApp } from '../../app.js';import { initDb, getDb, getUnifiedApiKey } from '../../db/index.js';+import { mintDashboardToken, isGatedApiPath } from '../helpers/auth.js';++let dashToken = '';async function request(app: Express, method: string, path: string, body?: any, headers: Record<string, string> = {}) {const server = app.listen(0);@@ -10,7 +13,11 @@ async function request(app: Express, method: string, path: string, body?: any, hconst res = await fetch(url, {method,- headers: { ...(body ? { 'Content-Type': 'application/json' } : {}), ...headers },+ headers: {+ ...(body ? { 'Content-Type': 'application/json' } : {}),+ ...(isGatedApiPath(path) && !('Authorization' in headers) ? { Authorization: `Bearer ${dashToken}` } : {}),+ ...headers,+ },body: body ? JSON.stringify(body) : undefined,});@@ -34,6 +41,7 @@ describe('Provider error redaction', () => {process.env.ENCRYPTION_KEY = '0'.repeat(64);initDb(':memory:');app = createApp();+ dashToken = mintDashboardToken();});beforeEach(async () => {