database expansion prior to creating on server - also error cleanup, some logging
Some checks failed
Deploy to Web Server flyer-crawler.projectium.com / deploy (push) Failing after 29s

This commit is contained in:
2025-11-20 10:40:35 -08:00
parent 838d31420e
commit 43b44902ca
16 changed files with 555 additions and 80 deletions

View File

@@ -1,12 +1,5 @@
/**
* This interface defines the shape of the pdf.js page object that we use.
* Since pdf.js is loaded from a CDN, we don't have its types available
* at build time, so we define the parts we need here for type safety.
*/
interface PDFPageProxy {
getViewport: (options: { scale: number }) => { width: number; height: number };
render: (options: { canvasContext: CanvasRenderingContext2D; viewport: { width: number; height: number } }) => { promise: Promise<void> };
}
import * as pdfjsLib from 'pdfjs-dist';
import type { PDFDocumentProxy, PDFPageProxy, PageViewport } from 'pdfjs-dist';
/**
* Renders a single PDF page to a canvas and returns it as a JPEG File object.
@@ -33,7 +26,7 @@ const renderPageToImageFile = async (
throw new Error('Could not get canvas context');
}
await pdfPage.render({ canvasContext: context, viewport: viewport }).promise;
await pdfPage.render({ canvas, canvasContext: context, viewport: viewport as PageViewport }).promise;
// Promisify canvas.toBlob for async/await usage
const blob = await new Promise<Blob | null>((resolve) => {
@@ -54,13 +47,8 @@ const renderPageToImageFile = async (
* @returns A promise that resolves to the pdf.js document object.
*/
const getPdfDocument = async (pdfFile: File) => {
// @ts-expect-error - pdfjsLib is globally available from the script tag in index.html
if (typeof pdfjsLib === 'undefined') {
throw new Error('pdf.js library is not loaded. Please check the script tag in index.html.');
}
const arrayBuffer = await pdfFile.arrayBuffer();
// @ts-expect-error - pdfjsLib is globally available
const pdf = await pdfjsLib.getDocument(arrayBuffer).promise;
const pdf: PDFDocumentProxy = await pdfjsLib.getDocument(arrayBuffer).promise;
return pdf;
};