第一次提交
This commit is contained in:
21
src/crawler/crawler.controller.ts
Normal file
21
src/crawler/crawler.controller.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { Controller, Post } from '@nestjs/common';
|
||||
import { BidCrawlerService } from './services/bid-crawler.service';
|
||||
|
||||
@Controller('api/crawler')
|
||||
export class CrawlerController {
|
||||
constructor(private readonly crawlerService: BidCrawlerService) {}
|
||||
|
||||
@Post('run')
|
||||
async runCrawl() {
|
||||
// We don't await this because we want it to run in the background
|
||||
// and return immediately, or we can await if we want the user to wait.
|
||||
// Given the requirement "Immediate Crawl", usually implies triggering it.
|
||||
// However, for a better UI experience, we might want to wait or just trigger.
|
||||
// Let's await it so the user knows when it's done (or failed),
|
||||
// assuming it doesn't take too long for the mock.
|
||||
// Real crawling might take long, so background is better.
|
||||
// For this prototype, I'll await it to show completion.
|
||||
await this.crawlerService.crawlAll();
|
||||
return { message: 'Crawl completed successfully' };
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user