Skip to content

⚡️⚡️⚡️ Self-hosted collaborative bookmark manager to collect, read, annotate, and fully preserve what matters, all in one place.

small fix

Daniel8aa196efc200
diff --git a/lib/api/archive.ts b/lib/api/archive.ts
index c55aa4cc..27da3154 100644
--- a/lib/api/archive.ts
+++ b/lib/api/archive.ts
@@ -3,6 +3,7 @@ import { prisma } from "@/lib/api/db";
import puppeteer from "puppeteer-extra";
import AdblockerPlugin from "puppeteer-extra-plugin-adblocker";
import StealthPlugin from "puppeteer-extra-plugin-stealth";
+import fs from "fs";
export default async function archive(
url: string,
@@ -24,23 +25,29 @@ export default async function archive(
await autoScroll(page);
- const linkExists = await prisma.link.findFirst({
+ const linkExists = await prisma.link.findUnique({
where: {
id: linkId,
},
});
if (linkExists) {
- await Promise.all([
- page.pdf({
- path: archivePath + ".pdf",
- width: "1366px",
- height: "1931px",
- printBackground: true,
- margin: { top: "15px", bottom: "15px" },
- }),
- page.screenshot({ fullPage: true, path: archivePath + ".png" }),
- ]);
+ const pdf = await page.pdf({
+ width: "1366px",
+ height: "1931px",
+ printBackground: true,
+ margin: { top: "15px", bottom: "15px" },
+ });
+ const screenshot = await page.screenshot({
+ fullPage: true,
+ });
+
+ fs.writeFile(archivePath + ".pdf", pdf, function (err) {
+ console.log(err);
+ });
+ fs.writeFile(archivePath + ".png", screenshot, function (err) {
+ console.log(err);
+ });
}
await browser.close();
diff --git a/package.json b/package.json
index b6bbf422..7873b8dc 100644
--- a/package.json
+++ b/package.json
@@ -22,6 +22,7 @@
"@prisma/client": "^4.9.0",
"@types/crypto-js": "^4.1.1",
"@types/node": "18.11.18",
+ "@types/nodemailer": "^6.4.8",
"@types/react": "18.0.27",
"@types/react-dom": "18.0.10",
"bcrypt": "^5.1.0",
@@ -32,6 +33,7 @@
"multer": "^1.4.5-lts.1",
"next": "13.1.6",
"next-auth": "^4.22.1",
+ "nodemailer": "^6.9.3",
"puppeteer": "^19.8.0",
"puppeteer-extra": "^3.3.6",
"puppeteer-extra-plugin-adblocker": "^2.13.6",
diff --git a/yarn.lock b/yarn.lock
index 72c10cdb..7c6e627f 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -641,6 +641,13 @@
resolved "https://registry.yarnpkg.com/@types/node/-/node-18.11.18.tgz#8dfb97f0da23c2293e554c5a50d61ef134d7697f"
integrity sha512-DHQpWGjyQKSHj3ebjFI/wRKcqQcdR+MoFBygntYOZytCqNfkd2ZC4ARDJ2DQqhjH5p85Nnd3jhUJIXrszFX/JA==
+"@types/nodemailer@^6.4.8":
+ version "6.4.8"
+ resolved "https://registry.yarnpkg.com/@types/nodemailer/-/nodemailer-6.4.8.tgz#f06c661e9b201fc2acc3a00a0fded42ba7eaca9d"
+ integrity sha512-oVsJSCkqViCn8/pEu2hfjwVO+Gb3e+eTWjg3PcjeFKRItfKpKwHphQqbYmPQrlMk+op7pNNWPbsJIEthpFN/OQ==
+ dependencies:
+ "@types/node" "*"
+
"@types/parse-json@^4.0.0":
version "4.0.0"
resolved "https://registry.yarnpkg.com/@types/parse-json/-/parse-json-4.0.0.tgz#2f8bb441434d163b35fb8ffdccd7138927ffb8c0"
@@ -2990,6 +2997,11 @@ node-releases@^2.0.12:
resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.12.tgz#35627cc224a23bfb06fb3380f2b3afaaa7eb1039"
integrity sha512-QzsYKWhXTWx8h1kIvqfnC++o0pEmpRQA/aenALsL2F4pqNVr7YzcdMlDij5WBnwftRbJCNJL/O7zdKaxKPHqgQ==
+nodemailer@^6.9.3:
+ version "6.9.3"
+ resolved "https://registry.yarnpkg.com/nodemailer/-/nodemailer-6.9.3.tgz#e4425b85f05d83c43c5cd81bf84ab968f8ef5cbe"
+ integrity sha512-fy9v3NgTzBngrMFkDsKEj0r02U7jm6XfC3b52eoNV+GCrGj+s8pt5OqhiJdWKuw51zCTdiNR/IUD1z33LIIGpg==
+
nopt@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/nopt/-/nopt-5.0.0.tgz#530942bb58a512fccafe53fe210f13a25355dc88"