feat: add PDF render timing to convert and demo routes
Some checks failed
Build & Deploy to Staging / Build & Deploy to Staging (push) Failing after 1m42s
Some checks failed
Build & Deploy to Staging / Build & Deploy to Staging (push) Failing after 1m42s
- renderPdf() and renderUrlPdf() now return { pdf, durationMs }
- Timing wraps the actual render with Date.now()
- Log render duration via logger.info
- Add X-Render-Time response header in convert and demo routes
- Update all callers in convert, demo, templates routes
- Add TDD tests in render-timing.test.ts
- Update existing test mocks for new return shape
This commit is contained in:
parent
0283e9dae8
commit
f9caef82e6
13 changed files with 165 additions and 23 deletions
|
|
@ -133,7 +133,7 @@ router.post("/html", async (req: Request & { acquirePdfSlot?: () => Promise<void
|
|||
printBackground: true,
|
||||
margin: { top: "0", right: "0", bottom: "0", left: "0" },
|
||||
};
|
||||
const pdf = await renderPdf(fullHtml, {
|
||||
const { pdf, durationMs } = await renderPdf(fullHtml, {
|
||||
...defaultOpts,
|
||||
...validation.sanitized,
|
||||
});
|
||||
|
|
@ -142,6 +142,7 @@ router.post("/html", async (req: Request & { acquirePdfSlot?: () => Promise<void
|
|||
res.setHeader("Content-Type", "application/pdf");
|
||||
res.setHeader("Content-Disposition", `attachment; filename="${filename}"`);
|
||||
res.setHeader("Content-Length", pdf.length);
|
||||
res.setHeader("X-Render-Time", String(durationMs));
|
||||
res.send(pdf);
|
||||
} catch (err: any) {
|
||||
if (err.message === "QUEUE_FULL") {
|
||||
|
|
@ -237,7 +238,7 @@ router.post("/markdown", async (req: Request & { acquirePdfSlot?: () => Promise<
|
|||
printBackground: true,
|
||||
margin: { top: "0", right: "0", bottom: "0", left: "0" },
|
||||
};
|
||||
const pdf = await renderPdf(fullHtml, {
|
||||
const { pdf, durationMs } = await renderPdf(fullHtml, {
|
||||
...defaultOpts,
|
||||
...validation.sanitized,
|
||||
});
|
||||
|
|
@ -246,6 +247,7 @@ router.post("/markdown", async (req: Request & { acquirePdfSlot?: () => Promise<
|
|||
res.setHeader("Content-Type", "application/pdf");
|
||||
res.setHeader("Content-Disposition", `attachment; filename="${filename}"`);
|
||||
res.setHeader("Content-Length", pdf.length);
|
||||
res.setHeader("X-Render-Time", String(durationMs));
|
||||
res.send(pdf);
|
||||
} catch (err: any) {
|
||||
if (err.message === "QUEUE_FULL") {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue