Added fully archive support!

This commit is contained in:
Daniel
2022-06-02 23:00:51 +04:30
parent b18ef2b905
commit 1d23855eac
10 changed files with 135 additions and 80 deletions
+2 -2
View File
@@ -4,8 +4,8 @@ const fetch = require('cross-fetch');
const config = require('../../src/config.js');
const fs = require('fs');
const screenshotDirectory = config.API.STORAGE_LOCATION + '/Webmarker/screenshot\'s/';
const pdfDirectory = config.API.STORAGE_LOCATION + '/Webmarker/pdf\'s/';
const screenshotDirectory = config.API.STORAGE_LOCATION + '/LinkWarden/screenshot\'s/';
const pdfDirectory = config.API.STORAGE_LOCATION + '/LinkWarden/pdf\'s/';
if (!fs.existsSync(screenshotDirectory)){
fs.mkdirSync(screenshotDirectory, { recursive: true });
+2 -1
View File
@@ -4623,7 +4623,8 @@
"ws": {
"version": "8.6.0",
"resolved": "https://registry.npmjs.org/ws/-/ws-8.6.0.tgz",
"integrity": "sha512-AzmM3aH3gk0aX7/rZLYvjdvZooofDu3fFOzGqcSnQ1tOcTWwhM/o+q++E8mAyVVIyUdajrkzWUGftaVSDLn1bw=="
"integrity": "sha512-AzmM3aH3gk0aX7/rZLYvjdvZooofDu3fFOzGqcSnQ1tOcTWwhM/o+q++E8mAyVVIyUdajrkzWUGftaVSDLn1bw==",
"requires": {}
},
"xdg-basedir": {
"version": "4.0.0",
+23 -1
View File
@@ -3,7 +3,8 @@ const app = express();
const { MongoClient } = require('mongodb');
const cors = require('cors');
const config = require('../src/config.js');
const getData = require('./modules/getData.js')
const getData = require('./modules/getData.js');
const fs = require('fs');
const port = config.API.PORT;
@@ -22,6 +23,14 @@ app.get('/api', async (req, res) => {
res.send(data);
});
app.get('/screenshots/:id', async (req, res) => {
res.sendFile(config.API.STORAGE_LOCATION + '/LinkWarden/screenshot\'s/' + req.params.id);
});
app.get('/pdfs/:id', async (req, res) => {
res.sendFile(config.API.STORAGE_LOCATION + '/LinkWarden/pdf\'s/' + req.params.id);
});
app.post('/api', async (req, res) => {
const pageToVisit = req.body.link;
@@ -77,6 +86,19 @@ async function deleteDoc(doc) {
const list = db.collection(collection);
const result = await list.deleteOne({"_id": doc});
fs.unlink(config.API.STORAGE_LOCATION + '/LinkWarden/screenshot\'s/' + doc + '.png', (err) => {
if (err) {
console.log(err);
}
});
fs.unlink(config.API.STORAGE_LOCATION + '/LinkWarden/pdf\'s/' + doc + '.pdf', (err) => {
if (err) {
console.log(err);
}
});
return result;
}