updated to node 22.2.0 to work with pdf.js 4.2.67

This commit is contained in:
Felix Kaspar
2024-05-16 18:52:24 +02:00
parent e72f3d5525
commit efd4bdc493
7 changed files with 88 additions and 58 deletions

View File

@@ -3,8 +3,6 @@ import { PDFPageProxy } from "pdfjs-dist/types/src/display/api";
import * as PDFJS from "pdfjs-dist";
import { createCanvas } from "canvas";
export interface PDFJSImage {
width: number;
height: number;

View File

@@ -1,4 +1,5 @@
import * as PDFJS from "pdfjs-dist";
import type { PDFDocumentProxy as PDFJSDocument } from "pdfjs-dist/types/src/display/api";
import { PDFDocument as PDFLibDocument } from "pdf-lib";

View File

@@ -6,8 +6,9 @@ export const JoiPDFFileSchema = Joi.custom((value: Express.Multer.File[] /* <- a
if(isPdfFileArray(value))
return value;
else { // File(s)
if(value.some(f => f.mimetype != "application/pdf"))
throw new Error("at least one of the files provided doesn't seem to be a PDF.");
const firstWrongFile = value.find(f => f.mimetype != "application/pdf")
if(firstWrongFile)
throw new Error(`at least one of the files provided doesn't seem to be a PDF. Got ${firstWrongFile.mimetype} instead.`);
return PdfFile.fromMulterFiles(value);
}