mirror of
https://github.com/documenso/documenso.git
synced 2025-11-14 16:51:38 +10:00
build fix
This commit is contained in:
@ -8,7 +8,7 @@ import { NextApiRequest, NextApiResponse } from "next";
|
|||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
import { buffer } from "stream/consumers";
|
import { buffer } from "stream/consumers";
|
||||||
import { Document as PrismaDocument } from "@documenso/prisma/client";
|
import { Document as PrismaDocument } from "@prisma/client";
|
||||||
|
|
||||||
async function getHandler(req: NextApiRequest, res: NextApiResponse) {
|
async function getHandler(req: NextApiRequest, res: NextApiResponse) {
|
||||||
const user = getUserFromToken(req, res);
|
const user = getUserFromToken(req, res);
|
||||||
@ -21,7 +21,7 @@ async function getHandler(req: NextApiRequest, res: NextApiResponse) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const document: PrismaDocument = await prisma.document.findFirst({
|
const document: PrismaDocument = await prisma.document.findFirstOrThrow({
|
||||||
where: {
|
where: {
|
||||||
id: +documentId,
|
id: +documentId,
|
||||||
},
|
},
|
||||||
@ -30,7 +30,7 @@ async function getHandler(req: NextApiRequest, res: NextApiResponse) {
|
|||||||
if (!document)
|
if (!document)
|
||||||
res.status(404).end(`No document with id ${documentId} found.`);
|
res.status(404).end(`No document with id ${documentId} found.`);
|
||||||
|
|
||||||
console.log("document: " + document.document);
|
console.log("document: " + document?.document);
|
||||||
const buffer: Buffer = Buffer.from(document.document.toString(), "base64");
|
const buffer: Buffer = Buffer.from(document.document.toString(), "base64");
|
||||||
res.setHeader("Content-Type", "application/pdf");
|
res.setHeader("Content-Type", "application/pdf");
|
||||||
res.setHeader("Content-Disposition", "attachment; filename=dummy.pdf");
|
res.setHeader("Content-Disposition", "attachment; filename=dummy.pdf");
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { PrismaClient } from "@prisma/client";
|
import { PrismaClient, Document, User } from "@prisma/client";
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
var client: PrismaClient | undefined;
|
var client: PrismaClient | undefined;
|
||||||
|
|||||||
Reference in New Issue
Block a user