Spaces:
Sleeping
Sleeping
Download apps/api/src/controllers/v2/credit-usage.ts from s-eto-hub/firecrawl-api: direct link, hf CLI and curl.
- Browser
- Download file 936 Bytes
-
https://huggingface.co/spaces/s-eto-hub/firecrawl-api/resolve/main/apps/api/src/controllers/v2/credit-usage.ts
- Command line
-
hf download hf://spaces/s-eto-hub/firecrawl-api/apps/api/src/controllers/v2/credit-usage.ts
-
curl -L -o credit-usage.ts https://huggingface.co/spaces/s-eto-hub/firecrawl-api/resolve/main/apps/api/src/controllers/v2/credit-usage.ts
936 Bytes
| import { Response } from "express"; | |
| import { ErrorResponse, RequestWithAuth } from "./types"; | |
| import { getTeamBalance } from "../../services/autumn/usage"; | |
| interface CreditUsageResponse { | |
| success: true; | |
| data: { | |
| remainingCredits: number; | |
| planCredits: number; | |
| billingPeriodStart: string | null; | |
| billingPeriodEnd: string | null; | |
| }; | |
| } | |
| export async function creditUsageController( | |
| req: RequestWithAuth, | |
| res: Response<CreditUsageResponse | ErrorResponse>, | |
| ): Promise<void> { | |
| const balance = await getTeamBalance(req.auth.team_id); | |
| if (!balance) { | |
| res.status(404).json({ | |
| success: false, | |
| error: "Could not find credit usage information", | |
| }); | |
| return; | |
| } | |
| res.json({ | |
| success: true, | |
| data: { | |
| remainingCredits: balance.remaining, | |
| planCredits: balance.planCredits, | |
| billingPeriodStart: balance.periodStart, | |
| billingPeriodEnd: balance.periodEnd, | |
| }, | |
| }); | |
| } | |