added update account functionality

This commit is contained in:
Daniel
2023-05-20 22:55:00 +03:30
parent e3862188de
commit 0ce97f0b64
13 changed files with 345 additions and 61 deletions
+7
View File
@@ -10,6 +10,7 @@ import archive from "../../archive";
import { Link, UsersAndCollections } from "@prisma/client";
import AES from "crypto-js/aes";
import getPermission from "@/lib/api/getPermission";
import { existsSync, mkdirSync } from "fs";
export default async function (link: ExtendedLink, userId: number) {
link.collection.name = link.collection.name.trim();
@@ -100,6 +101,12 @@ export default async function (link: ExtendedLink, userId: number) {
include: { tags: true, collection: true },
});
const collectionPath = `data/archives/${updatedLink.collection.id}`;
if (!existsSync(collectionPath))
mkdirSync(collectionPath, { recursive: true });
console.log(updatedLink);
archive(updatedLink.url, updatedLink.collectionId, updatedLink.id);
return { response: updatedLink, status: 200 };