From 661d5e9880eaca3bf72d9eacbff551aee272a4e8 Mon Sep 17 00:00:00 2001 From: Kfir Dayan Date: Tue, 18 Apr 2023 13:23:34 +0300 Subject: [PATCH] db add --- src/app.module.ts | 3 ++- src/crawler/crawler.service.ts | 12 ++++++++++++ src/db/db.service.ts | 4 ++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/app.module.ts b/src/app.module.ts index ca348d4..60bc28f 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -1,8 +1,9 @@ import { Module } from '@nestjs/common'; import { ApiModule } from './api/api.module'; import { CrawlerModule } from './crawler/crawler.module'; +import { DbModule } from './db/db.module'; @Module({ - imports: [ApiModule, CrawlerModule] + imports: [ApiModule, CrawlerModule, DbModule] }) export class AppModule {} diff --git a/src/crawler/crawler.service.ts b/src/crawler/crawler.service.ts index 0877df2..074a97d 100644 --- a/src/crawler/crawler.service.ts +++ b/src/crawler/crawler.service.ts @@ -42,6 +42,18 @@ export class CrawlerService { // URLS // const urls = await page.$$eval('a', links => links.map(link => link.href)); await browser.close(); + + // // save to db + // this.dbService.insert({ + // url, + // domain, + // cssSheetsLocation, + // scriptsSheetsLocation, + // screenshotBuffer, + // urls + // }, 'crawler'); + + } async downloadFiles(urls: string[], path: string) { diff --git a/src/db/db.service.ts b/src/db/db.service.ts index 9e9ffdd..dc92d3f 100644 --- a/src/db/db.service.ts +++ b/src/db/db.service.ts @@ -5,4 +5,8 @@ export class DbService { constructor() { console.log(`DbService constructor`); } + + insert(data, collection) { + console.log(`DbService insert`); + } }