small commit

This commit is contained in:
Kfir Dayan 2023-04-17 19:08:09 +03:00
parent 02136ba3fe
commit a130f9065f
2 changed files with 7 additions and 7 deletions

View file

@ -1,4 +1,4 @@
import { Controller, Post } from '@nestjs/common';
import { Body, Controller, Post } from '@nestjs/common';
import { CrawlerService } from '../crawler/crawler.service';
@Controller('/')
@ -6,10 +6,10 @@ export class ApiController {
constructor(private crawlerService: CrawlerService) {}
// Have an HTTP endpoint, "/crawl" with a JSON body "{ url: string }" that activates the crawling on the specified website.
@Post("/crawl")
crawl(){
// invoke crawler service
return this.crawlerService.crawl();
// this route should accept a POST request
@Post('crawl')
async crawl(@Body() body: { url: string }) {
return this.crawlerService.crawl(body.url);
}

View file

@ -3,7 +3,7 @@ import { Injectable } from '@nestjs/common';
@Injectable()
export class CrawlerService {
crawl(){
return "Crawling...";
async crawl(url: string){
return `Crawling... ${url}`;
}
}