Skip to content

Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥

fix(db): fix caching and rpc error

Gergő Móricz417adf8e967a
diff --git a/apps/api/src/controllers/auth.ts b/apps/api/src/controllers/auth.ts
index a428f9a39..fe7baa62e 100644
--- a/apps/api/src/controllers/auth.ts
+++ b/apps/api/src/controllers/auth.ts
@@ -64,7 +64,7 @@ async function getACUC(api_key: string): Promise<AuthCreditUsageChunk | null> {
const cachedACUC = await getValue(cacheKeyACUC);
if (cachedACUC !== null) {
- return JSON.parse(cacheKeyACUC);
+ return JSON.parse(cachedACUC);
} else {
const { data, error } =
await supabase_service.rpc("auth_credit_usage_chunk", { input_key: api_key });
diff --git a/apps/api/src/lib/checkCredits.ts b/apps/api/src/lib/checkCredits.ts
deleted file mode 100644
index 7e9d988d7..000000000
--- a/apps/api/src/lib/checkCredits.ts
+++ /dev/null
@@ -1,32 +0,0 @@
-import { checkTeamCredits } from "../services/billing/credit_billing";
-import { Logger } from "./logger";
-
-type checkCreditsResponse = {
- status: number;
- error: string | null;
-}
-
-export const checkCredits = async (team_id: string): Promise<checkCreditsResponse> => {
- try {
- const {
- success: creditsCheckSuccess,
- message: creditsCheckMessage
- } = await checkTeamCredits(team_id, 1);
- if (!creditsCheckSuccess) {
- return {
- status: 402,
- error: "Insufficient credits"
- };
- }
- } catch (error) {
- Logger.error(error);
- return {
- status: 500,
- error: "Error checking team credits. Please contact [email protected] for help."
- };
- }
- return {
- status: 200,
- error: null
- }
-};
\ No newline at end of file