From a130f9065f28bc1bc90bba5067c163a56f741828 Mon Sep 17 00:00:00 2001 From: Kfir Dayan Date: Mon, 17 Apr 2023 19:08:09 +0300 Subject: [PATCH] small commit --- src/api/api.controller.ts | 10 +++++----- src/crawler/crawler.service.ts | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) 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}`; } }