Skip to content

Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.

refactor: change to sequential promise in delete document

Marc Seitz76b645c39452
diff --git a/pages/api/documents/[id]/index.ts b/pages/api/documents/[id]/index.ts
index 167825b4..e9f0747f 100644
--- a/pages/api/documents/[id]/index.ts
+++ b/pages/api/documents/[id]/index.ts
@@ -57,29 +57,26 @@ export default async function handle(
id: id,
},
});
-
+
if (!document) {
return res.status(404).end("Document not found");
}
-
+
// check that the user is owner of the document, otherwise return 401
if (document.ownerId !== (session.user as CustomUser).id) {
return res.status(401).end("Unauthorized to access the document");
}
-
- await Promise.all([
- // delete the document from vercel blob
- await del(document.file),
- // delete the document from database
- await prisma.document.delete({
- where: {
- id: id,
- }
- }),
- ]);
-
- res.status(204).end(); // 204 No Content response for successful deletes
+ // delete the document from vercel blob
+ await del(document.file)
+ // delete the document from database
+ await prisma.document.delete({
+ where: {
+ id: id,
+ },
+ })
+
+ res.status(204).end(); // 204 No Content response for successful deletes
} catch (error) {
return res.status(500).json({
message: "Internal Server Error",