Spaces:
Sleeping
Sleeping
Download apps/api/src/controllers/v1/crawl-ongoing.ts from s-eto-hub/firecrawl-api: direct link, hf CLI and curl.
- Browser
- Download file 1.06 kB
-
https://huggingface.co/spaces/s-eto-hub/firecrawl-api/resolve/main/apps/api/src/controllers/v1/crawl-ongoing.ts
- Command line
-
hf download hf://spaces/s-eto-hub/firecrawl-api/apps/api/src/controllers/v1/crawl-ongoing.ts
-
curl -L -o crawl-ongoing.ts https://huggingface.co/spaces/s-eto-hub/firecrawl-api/resolve/main/apps/api/src/controllers/v1/crawl-ongoing.ts
1.06 kB
| import { Response } from "express"; | |
| import { | |
| OngoingCrawlsResponse, | |
| RequestWithAuth, | |
| toNewCrawlerOptions, | |
| } from "./types"; | |
| import { getCrawl } from "../../lib/crawl-redis"; | |
| import { configDotenv } from "dotenv"; | |
| import { crawlGroup } from "../../services/worker/nuq"; | |
| configDotenv(); | |
| export async function ongoingCrawlsController( | |
| req: RequestWithAuth<{}, undefined, OngoingCrawlsResponse>, | |
| res: Response<OngoingCrawlsResponse>, | |
| ) { | |
| const ids = (await crawlGroup.getOngoingByOwner(req.auth.team_id)).map( | |
| x => x.id, | |
| ); | |
| const crawls = ( | |
| await Promise.all(ids.map(async id => ({ ...(await getCrawl(id)), id }))) | |
| ).filter(crawl => crawl !== null && !crawl.cancelled && crawl.crawlerOptions); | |
| res.status(200).json({ | |
| success: true, | |
| crawls: crawls.map(x => ({ | |
| id: x.id, | |
| teamId: x.team_id!, | |
| url: x.originUrl!, | |
| created_at: new Date(x.createdAt || Date.now()).toISOString(), | |
| options: { | |
| ...toNewCrawlerOptions(x.crawlerOptions), | |
| scrapeOptions: x.scrapeOptions, | |
| }, | |
| })), | |
| }); | |
| } | |