mirror of
https://git.mirrors.martin98.com/https://github.com/mendableai/firecrawl
synced 2025-08-04 18:40:37 +08:00
fix(db): fix caching and rpc error
This commit is contained in:
parent
f8c70fe5dd
commit
2073063fb7
@ -64,7 +64,7 @@ async function getACUC(api_key: string): Promise<AuthCreditUsageChunk | null> {
|
|||||||
const cachedACUC = await getValue(cacheKeyACUC);
|
const cachedACUC = await getValue(cacheKeyACUC);
|
||||||
|
|
||||||
if (cachedACUC !== null) {
|
if (cachedACUC !== null) {
|
||||||
return JSON.parse(cacheKeyACUC);
|
return JSON.parse(cachedACUC);
|
||||||
} else {
|
} else {
|
||||||
const { data, error } =
|
const { data, error } =
|
||||||
await supabase_service.rpc("auth_credit_usage_chunk", { input_key: api_key });
|
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…
x
Reference in New Issue
Block a user