From 6d3ed58526a3476543b3d6024ca19ab3c600f7a8 Mon Sep 17 00:00:00 2001 From: Kfir Dayan Date: Tue, 18 Apr 2023 12:36:56 +0300 Subject: [PATCH] module + service is DB has added --- src/crawler/crawler.module.ts | 2 ++ src/crawler/crawler.service.ts | 7 +++---- src/db/db.module.ts | 7 +++++++ src/db/db.service.ts | 8 ++++++++ 4 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 src/db/db.module.ts create mode 100644 src/db/db.service.ts diff --git a/src/crawler/crawler.module.ts b/src/crawler/crawler.module.ts index 159670e..5304f95 100644 --- a/src/crawler/crawler.module.ts +++ b/src/crawler/crawler.module.ts @@ -1,7 +1,9 @@ import { Module } from '@nestjs/common'; import { CrawlerService } from './crawler.service'; +import { DbModule } from '../db/db.module'; @Module({ + imports: [DbModule], providers: [CrawlerService] }) export class CrawlerModule {} diff --git a/src/crawler/crawler.service.ts b/src/crawler/crawler.service.ts index ba9c2e2..0877df2 100644 --- a/src/crawler/crawler.service.ts +++ b/src/crawler/crawler.service.ts @@ -21,14 +21,14 @@ export class CrawlerService { const stylesheetsUrls = await page.$$eval('link[rel="stylesheet"]', links => links.map(link => link.href)); let cssDir = `${directory}/css/` const cssSheetsLocation = await this.downloadFiles(stylesheetsUrls, cssDir); - // console.log(`cssSheetsLocation: `, cssSheetsLocation); + console.log(`cssSheetsLocation: `, cssSheetsLocation); // STYLESHEETS // // SCRIPTS // const scriptsUrls = await page.$$eval('script', scripts => scripts.map(script => script.src)); let scriptsDir = `${directory}/scripts/` const scriptsSheetsLocation = await this.downloadFiles(scriptsUrls, scriptsDir); - // console.log(`scriptsSheetsLocation: `, scriptsSheetsLocation) + console.log(`scriptsSheetsLocation: `, scriptsSheetsLocation) // SCRIPTS // // SCREENSHOT // @@ -65,12 +65,11 @@ export class CrawlerService { } console.log("fileLocation: " + fileLocation) finalUrls.push(fileLocation); - // console.log(`Saving file ${path}${url}`); + console.log(`Saving file ${path}${fileLocation}`); fs.writeFileSync(`${path}${fileLocation}`, content); }) ); - console.log(`finalUrls: `, finalUrls); return finalUrls; } diff --git a/src/db/db.module.ts b/src/db/db.module.ts new file mode 100644 index 0000000..1844827 --- /dev/null +++ b/src/db/db.module.ts @@ -0,0 +1,7 @@ +import { Module } from '@nestjs/common'; +import { DbService } from './db.service'; + +@Module({ + providers: [DbService] +}) +export class DbModule {} diff --git a/src/db/db.service.ts b/src/db/db.service.ts new file mode 100644 index 0000000..9e9ffdd --- /dev/null +++ b/src/db/db.service.ts @@ -0,0 +1,8 @@ +import { Injectable } from '@nestjs/common'; + +@Injectable() +export class DbService { + constructor() { + console.log(`DbService constructor`); + } +}