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:
20
lib/static/app/crawler.js
Normal file
20
lib/static/app/crawler.js
Normal 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
|
Reference in New Issue
Block a user