Skip to content

Commit 98810fc

Browse files
committed
fix: 🐛 Add puppeteer config
1 parent be7438d commit 98810fc

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

apps/api/.puppeteerrc.cjs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const {join} = require('path');
2+
3+
/**
4+
* @type {import("puppeteer").Configuration}
5+
*/
6+
module.exports = {
7+
// Changes the cache location for Puppeteer.
8+
cacheDirectory: join(__dirname, '.cache', 'puppeteer'),
9+
};

apps/api/src/invoice.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
11
import { Elysia } from 'elysia'
22
import puppeteer from 'puppeteer';
33

4-
5-
const getBrowser = () => puppeteer.launch({ headless: true });
6-
74
const plugin = new Elysia()
85
.get('/invoice', async ({
96
query
107
}) => {
118
console.log(query)
129
const { id, type, download } = query
1310

14-
let browser = await getBrowser();
11+
let browser = await puppeteer.launch({ headless: true });
1512
const page = await browser.newPage();
1613

1714
await page.goto(`https://app.invoicelink.io/invoice?id=${id}&type=${type}&download=${download}`);
1815
const pdf = await page.pdf({
1916
format: 'A4',
2017
printBackground: true
2118
});
19+
20+
await browser.close();
2221

2322
return new Response(pdf, {
2423
headers: {

0 commit comments

Comments
 (0)