small commit
This commit is contained in:
parent
02136ba3fe
commit
a130f9065f
2 changed files with 7 additions and 7 deletions
|
@ -1,4 +1,4 @@
|
||||||
import { Controller, Post } from '@nestjs/common';
|
import { Body, Controller, Post } from '@nestjs/common';
|
||||||
import { CrawlerService } from '../crawler/crawler.service';
|
import { CrawlerService } from '../crawler/crawler.service';
|
||||||
|
|
||||||
@Controller('/')
|
@Controller('/')
|
||||||
|
@ -6,10 +6,10 @@ export class ApiController {
|
||||||
|
|
||||||
constructor(private crawlerService: CrawlerService) {}
|
constructor(private crawlerService: CrawlerService) {}
|
||||||
// Have an HTTP endpoint, "/crawl" with a JSON body "{ url: string }" that activates the crawling on the specified website.
|
// Have an HTTP endpoint, "/crawl" with a JSON body "{ url: string }" that activates the crawling on the specified website.
|
||||||
@Post("/crawl")
|
// this route should accept a POST request
|
||||||
crawl(){
|
@Post('crawl')
|
||||||
// invoke crawler service
|
async crawl(@Body() body: { url: string }) {
|
||||||
return this.crawlerService.crawl();
|
return this.crawlerService.crawl(body.url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { Injectable } from '@nestjs/common';
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class CrawlerService {
|
export class CrawlerService {
|
||||||
|
|
||||||
crawl(){
|
async crawl(url: string){
|
||||||
return "Crawling...";
|
return `Crawling... ${url}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue