mirror of
https://github.com/mendableai/firecrawl.git
synced 2024-11-16 03:32:22 +08:00
fix(db): fix caching and rpc error
This commit is contained in:
parent
331e826bca
commit
417adf8e96
|
@ -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 });
|
||||
|
|
|
@ -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
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue
Block a user