fixed monolith for docker users

This commit is contained in:
daniel31x13
2024-06-27 18:19:07 -04:00
parent 9fa9fe5db0
commit 22b2734494
7 changed files with 23 additions and 71 deletions
+2 -1
View File
@@ -2,7 +2,8 @@ import { prisma } from "@/lib/api/db";
import { LinkRequestQuery, Sort } from "@/types/global";
export default async function getLink(userId: number, query: LinkRequestQuery) {
const POSTGRES_IS_ENABLED = process.env.DATABASE_URL.startsWith("postgresql");
const POSTGRES_IS_ENABLED =
process.env.DATABASE_URL?.startsWith("postgresql");
let order: any;
if (query.sort === Sort.DateNewestFirst) order = { id: "desc" };
@@ -4,7 +4,8 @@ import { LinkRequestQuery, Sort } from "@/types/global";
export default async function getLink(
query: Omit<LinkRequestQuery, "tagId" | "pinnedOnly">
) {
const POSTGRES_IS_ENABLED = process.env.DATABASE_URL.startsWith("postgresql");
const POSTGRES_IS_ENABLED =
process.env.DATABASE_URL?.startsWith("postgresql");
let order: any;
if (query.sort === Sort.DateNewestFirst) order = { id: "desc" };
+2 -2
View File
@@ -65,12 +65,12 @@ export default async function postToken(
jti: crypto.randomUUID(),
},
maxAge: expiryDateSecond || 604800,
secret: process.env.NEXTAUTH_SECRET,
secret: process.env.NEXTAUTH_SECRET as string,
});
const tokenBody = await decode({
token,
secret: process.env.NEXTAUTH_SECRET,
secret: process.env.NEXTAUTH_SECRET as string,
});
const createToken = await prisma.accessToken.create({
@@ -1,16 +1,11 @@
import { execSync } from "child_process";
import createFile from "../storage/createFile";
import axios from "axios";
import { Agent } from "http";
import { prisma } from "../db";
import { Link } from "@prisma/client";
import { Page } from "playwright";
const handleMonolith = async (link: Link, content: string) => {
if (!link.url) return;
let command = process.env.SINGLEFILE_ARCHIVE_COMMAND;
let httpApi = process.env.SINGLEFILE_ARCHIVE_HTTP_API;
try {
let html = execSync(
`monolith - -I -b ${link.url} ${
@@ -42,56 +37,6 @@ const handleMonolith = async (link: Link, content: string) => {
} catch (err) {
console.error("Error running SINGLEFILE_ARCHIVE_COMMAND:", err);
}
// if (httpApi) {
// try {
// let html = await axios.post(
// httpApi,
// { url: link.url },
// {
// headers: {
// "Content-Type": "application/x-www-form-urlencoded",
// },
// httpAgent: new Agent({ keepAlive: false }),
// }
// );
// if (!html.data.length) {
// console.error("Error running SINGLEFILE_ARCHIVE_COMMAND: Empty buffer");
// return;
// }
// const collectionId = (
// await prisma.link.findUnique({
// where: { id: link.id },
// select: { collectionId: true },
// })
// )?.collectionId;
// if (!collectionId) {
// console.error(
// "Error running SINGLEFILE_ARCHIVE_COMMAND: Collection ID not found"
// );
// return;
// }
// await createFile({
// data: html.data,
// filePath: `archives/${collectionId}/${link.id}.html`,
// }).then(async () => {
// await prisma.link.update({
// where: { id: link.id },
// data: {
// singlefile: `archives/${collectionId}/${link.id}.html`,
// },
// });
// });
// } catch (err) {
// console.error(
// "Error fetching Singlefile using SINGLEFILE_ARCHIVE_HTTP_API:",
// err
// );
// }
// }
};
export default handleMonolith;