Improve error handling on upload

This commit is contained in:
Elias Schneider
2022-04-28 16:01:50 +02:00
parent 5845659bab
commit 09645c6202
4 changed files with 86 additions and 52 deletions

View File

@@ -0,0 +1,19 @@
import type { NextApiRequest, NextApiResponse } from "next";
import { ShareDocument } from "../../../../types/Appwrite.type";
import awServer from "../../../../utils/appwriteServer.util";
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
const shareId = req.query.shareId as string;
let doesExists;
try {
await awServer.database.getDocument<ShareDocument>("shares", shareId);
doesExists = true;
} catch {
doesExists = false;
}
res.status(200).json({ exists: doesExists });
};
export default handler;