fix(db): fix caching and rpc error

This commit is contained in:
Gergő Móricz 2024-09-25 19:42:45 +02:00
parent 331e826bca
commit 417adf8e96
2 changed files with 1 additions and 33 deletions

View File

@ -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 });

View File

@ -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 hello@firecrawl.com for help."
};
}
return {
status: 200,
error: null
}
};