Spaces:
Sleeping
Sleeping
Download apps/api/src/controllers/v1/scrape-status.ts from s-eto-hub/firecrawl-api: direct link, hf CLI and curl.
- Browser
- Download file 1.59 kB
-
https://huggingface.co/spaces/s-eto-hub/firecrawl-api/resolve/main/apps/api/src/controllers/v1/scrape-status.ts
- Command line
-
hf download hf://spaces/s-eto-hub/firecrawl-api/apps/api/src/controllers/v1/scrape-status.ts
-
curl -L -o scrape-status.ts https://huggingface.co/spaces/s-eto-hub/firecrawl-api/resolve/main/apps/api/src/controllers/v1/scrape-status.ts
1.59 kB
| import { Response } from "express"; | |
| import { supabaseGetScrapeByIdOnlyData } from "../../lib/supabase-jobs"; | |
| import { getJob } from "./crawl-status"; | |
| import { logger as _logger } from "../../lib/logger"; | |
| import { getScrapeZDR } from "../../lib/zdr-helpers"; | |
| export async function scrapeStatusController(req: any, res: any) { | |
| const logger = _logger.child({ | |
| module: "scrape-status", | |
| method: "scrapeStatusController", | |
| teamId: req.auth.team_id, | |
| jobId: req.params.jobId, | |
| scrapeId: req.params.jobId, | |
| zeroDataRetention: getScrapeZDR(req.acuc?.flags) === "forced", | |
| }); | |
| if (getScrapeZDR(req.acuc?.flags) === "forced") { | |
| return res.status(400).json({ | |
| success: false, | |
| error: | |
| "Your team has zero data retention enabled. This is not supported on scrape status. Please contact support@firecrawl.com to unblock this feature.", | |
| }); | |
| } | |
| const job = await supabaseGetScrapeByIdOnlyData(req.params.jobId, logger); | |
| if (!job) { | |
| return res.status(404).json({ | |
| success: false, | |
| error: "Job not found.", | |
| }); | |
| } | |
| if (job?.team_id !== req.auth.team_id) { | |
| return res.status(403).json({ | |
| success: false, | |
| error: "You are not allowed to access this resource.", | |
| }); | |
| } | |
| const jobData = await getJob(req.params.jobId); | |
| const data = Array.isArray(jobData?.returnvalue) | |
| ? jobData?.returnvalue[0] | |
| : jobData?.returnvalue; | |
| if (!data) { | |
| return res.status(404).json({ | |
| success: false, | |
| error: "Job not found.", | |
| }); | |
| } | |
| return res.status(200).json({ | |
| success: true, | |
| data, | |
| }); | |
| } | |