1
0
mirror of https://github.com/comatory/fb2iCal synced 2025-06-05 22:09:25 +02:00

implement same parsing logic on server and frontend

Server now downloads the HTML file via new endpoint but the parsing logic now happens in
the browser. The reason for this is to have a way same code for both
environments.

If the JavaScript is disabled, it's still possible to call the previous
endpoint and download the file from the server.
This commit is contained in:
Ondřej Synáček
2020-07-17 22:20:48 +02:00
parent 410096398d
commit f577fb6385
5 changed files with 97 additions and 30 deletions

20
lib/static/app/crawler.js Normal file
View File

@@ -0,0 +1,20 @@
const crawl = async (url, { logger }) => {
if (logger) {
logger.log({
message: `Crawl started for url: ${url}`,
level: 'info',
service: 'parser',
})
}
return new Promise((resolve, reject) => {
fetch(url, {
method: 'GET',
}).then((response) => {
console.log(response)
resolve()
}).catch(reject)
})
}
export default crawl