From b3321b2f906f77b446df58f6ee69f9fd415a03d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Syn=C3=A1=C4=8Dek?= Date: Fri, 17 Jul 2020 20:54:11 +0200 Subject: [PATCH] use crawling logic as a service for ICS retrieval --- lib/index.js | 2 ++ lib/services/ics-retriever.js | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/index.js b/lib/index.js index 3a60877..bd61ce4 100644 --- a/lib/index.js +++ b/lib/index.js @@ -5,6 +5,7 @@ const favicon = require('serve-favicon') const rateLimit = require('express-rate-limit') const retrieveICS = require('./services/ics-retriever') +const crawl = require('./services/crawler') const { genericErrorHandler, checkURLParameter, @@ -83,6 +84,7 @@ app.post('/download', async (req, res, next) => { const ics = await retrieveICS(url, { logger: appLogger, + crawl, }) res diff --git a/lib/services/ics-retriever.js b/lib/services/ics-retriever.js index 7885130..d601825 100644 --- a/lib/services/ics-retriever.js +++ b/lib/services/ics-retriever.js @@ -1,10 +1,9 @@ -const crawl = require('./crawler') const parseUsingLDJSONData = require('./ldjson-parser') const parseUsingDOM = require('./dom-parser') const generateICS = require('./ics-generator') const { createParserError, getNormalizedUrl } = require('../utils') -const retrieveICS = async (URLparameter, { logger }) => { +const retrieveICS = async (URLparameter, { logger, crawl }) => { const url = getNormalizedUrl(URLparameter) const html = await crawl(url, { logger }) const LDJSONEventData = parseUsingLDJSONData(html, { logger })