Major preformance fix.

This commit is contained in:
Daniel 2022-06-05 21:42:49 +04:30
parent b907bd53ec
commit b3e6e75f90
4 changed files with 18 additions and 7 deletions

View File

@ -5,6 +5,7 @@ const cors = require('cors');
const config = require('../src/config.js'); const config = require('../src/config.js');
const getData = require('./modules/getData.js'); const getData = require('./modules/getData.js');
const fs = require('fs'); const fs = require('fs');
const fetch = require('cross-fetch');
const port = config.API.PORT; const port = config.API.PORT;
@ -35,16 +36,27 @@ app.get('/pdfs/:id', async (req, res) => {
app.post('/api', async (req, res) => { app.post('/api', async (req, res) => {
const pageToVisit = req.body.link; const pageToVisit = req.body.link;
const id = req.body._id;
const getTitle = async(url) => {
let body;
await fetch(url)
.then(res => res.text())
.then(text => body = text)
// regular expression to parse contents of the <title> tag
let match = body.match(/<title>([^<]*)<\/title>/);
return match[1];
}
try { try {
req.body.title = await getTitle(req.body.link);
await insertDoc(req.body);
res.send("DONE!");
const dataResult = await getData(pageToVisit, req.body._id); const dataResult = await getData(pageToVisit, req.body._id);
req.body.title = dataResult;
insertDoc(req.body);
} catch (err) { } catch (err) {
console.log(err); console.log(err);
insertDoc(req.body); insertDoc(req.body);
} finally {
res.send('Posted!');
} }
}); });

View File

@ -37,7 +37,6 @@
} }
.list-entity-content { .list-entity-content {
text-shadow: 0px 1px 3px #1f2c38;
z-index: 0; z-index: 0;
margin-left: 70px; margin-left: 70px;
padding: 20px; padding: 20px;

View File

@ -6,5 +6,5 @@
.seperator { .seperator {
width: 100%; width: 100%;
color: white; color: #1f2c38;
} }

View File

@ -6,9 +6,9 @@ body {
-webkit-font-smoothing: antialiased; -webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale; -moz-osx-font-smoothing: grayscale;
background-color: #1f2c38; background-color: #1f2c38;
text-shadow: 0px 1px 1px #1f2c38;
} }
*::selection { *::selection {
background-color: rgba(255, 255, 0, 0.6); background-color: rgba(255, 255, 0, 0.6);
text-shadow: 0px 1px 3px #1f2c38;
} }