Files
sign/apps/web/pages/api/documents/[id]/sign.ts

40 lines
956 B
TypeScript
Raw Normal View History

2023-01-20 13:58:21 +01:00
import {
defaultHandler,
defaultResponder,
getUserFromToken,
} from "@documenso/lib/server";
import prisma from "@documenso/prisma";
import { NextApiRequest, NextApiResponse } from "next";
async function postHandler(req: NextApiRequest, res: NextApiResponse) {
const existingUser = await getUserFromToken(req, res);
2023-01-20 13:58:21 +01:00
const { id: documentId } = req.query;
const { token: recipientToken } = req.query;
2023-01-20 13:58:21 +01:00
if (!documentId) {
res.status(400).send("Missing parameter documentId.");
return;
}
let document = await prisma.document.findFirst({
where: {
id: +documentId,
},
});
if (!document)
res.status(404).end(`No document with id ${documentId} found.`);
const recipients = prisma.recipient.findMany({
where: { documentId: +documentId },
});
2023-01-20 13:58:21 +01:00
// todo sign stuff
return res.status(200).end();
2023-01-20 13:58:21 +01:00
}
export default defaultHandler({
POST: Promise.resolve({ default: defaultResponder(postHandler) }),
});