mirror of
https://git.mirrors.martin98.com/https://github.com/mendableai/firecrawl
synced 2025-08-05 15:40:37 +08:00
Nick: fixed .sort coupons and sentry to withAuth
This commit is contained in:
parent
7561fd279f
commit
3072d4a333
@ -1,5 +1,6 @@
|
||||
import { AuthResponse } from "../../src/types";
|
||||
import { Logger } from "./logger";
|
||||
import * as Sentry from "@sentry/node";
|
||||
|
||||
let warningCount = 0;
|
||||
|
||||
@ -18,6 +19,7 @@ export function withAuth<T extends AuthResponse, U extends any[]>(
|
||||
try {
|
||||
return await originalFunction(...args);
|
||||
} catch (error) {
|
||||
Sentry.captureException(error);
|
||||
Logger.error(`Error in withAuth function: ${error}`);
|
||||
return { success: false, error: error.message } as T;
|
||||
}
|
||||
|
@ -40,14 +40,15 @@ export async function supaBillTeam(team_id: string, credits: number) {
|
||||
]);
|
||||
|
||||
let couponCredits = 0;
|
||||
let sortedCoupons = [];
|
||||
|
||||
if (coupons && coupons.length > 0) {
|
||||
couponCredits = coupons.reduce(
|
||||
(total, coupon) => total + coupon.credits,
|
||||
0
|
||||
);
|
||||
sortedCoupons = [...coupons].sort((a, b) => b.credits - a.credits);
|
||||
}
|
||||
|
||||
let sortedCoupons = coupons.sort((a, b) => b.credits - a.credits);
|
||||
// using coupon credits:
|
||||
if (couponCredits > 0) {
|
||||
// if there is no subscription and they have enough coupon credits
|
||||
|
Loading…
x
Reference in New Issue
Block a user