diff --git a/src/api/api.controller.ts b/src/api/api.controller.ts index 61e3f6e..2325bb9 100644 --- a/src/api/api.controller.ts +++ b/src/api/api.controller.ts @@ -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); } diff --git a/src/crawler/crawler.service.ts b/src/crawler/crawler.service.ts index eb90207..093fe81 100644 --- a/src/crawler/crawler.service.ts +++ b/src/crawler/crawler.service.ts @@ -3,7 +3,7 @@ import { Injectable } from '@nestjs/common'; @Injectable() export class CrawlerService { - crawl(){ - return "Crawling..."; + async crawl(url: string){ + return `Crawling... ${url}`; } }