Skip to content

Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors

1.3 KB
Raw Blame
/**
 * usageDb.js — Facade (T-15 decomposition)
 *
 * This file is now a thin re-export layer. All logic has been
 * extracted into focused modules under `./usage/`:
 *
 *   migrations.js     — Legacy file + JSON→SQLite migration
 *   usageHistory.js   — Usage tracking, request log, pending requests
 *   costCalculator.js — Cost calculation (pure function)
 *   usageStats.js     — Aggregated stats for dashboard
 *   callLogs.js       — Structured call log management
 *
 * Existing imports like `import { getUsageStats } from "@/lib/usageDb"`
 * continue to work unchanged.
 */

// Trigger migrations on module load (side-effect)
import "./usage/migrations";

// Re-export everything for backward compatibility
export {
  trackPendingRequest,
  updatePendingRequest,
  updatePendingRequestStreamChunks,
  finalizePendingRequest,
  getUsageDb,
  saveRequestUsage,
  getUsageHistory,
  getModelLatencyStats,
  appendRequestLog,
  getRecentLogs,
} from "./usage/usageHistory";
export { getConnectionSpeedStats } from "./usage/connectionSpeedStats";

export { calculateCost } from "./usage/costCalculator";

export { getUsageStats, buildActiveRequests } from "./usage/usageStats";

export { saveCallLog, rotateCallLogs, getCallLogs, getCallLogById } from "./usage/callLogs";
export { getCallLogFilterOptions } from "./usage/callLogFilterOptions";