Skip to content

Commit

Permalink
docs: update README and refactor PDF response functions
Browse files Browse the repository at this point in the history
  • Loading branch information
ax-sh committed Dec 3, 2024
1 parent 68cde51 commit e50d36f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,18 @@ bun install
To run:

```bash
bun run index.ts
bun dev


```
For running unit test
```sh
bun test
```

To run browser test
```sh
bun test:puppet
```

This project was created using `bun init` in bun v1.1.37. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime.
25 changes: 15 additions & 10 deletions api/core/core.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
export async function downloadPDF() {
// const cloud = require("@sparticuz/chromium");
// // biome-ignore lint/style/useSingleVarDeclarator: <explanation>
// const executablePath = await cloud.executablePath()
const { chromium } = require("playwright-core");

return { c: chromium };
}
import * as buffer from "node:buffer";

export const cloud = require("chrome-aws-lambda");

export function pdfResponse(pdf: Buffer, fileName: string) {
export function base64EncodedResponse(base64Encoded: Buffer, fileName) {
const response = {
headers: {
"Content-type": "application/pdf",
"content-disposition": `attachment; filename=${fileName}.pdf`,
},
statusCode: 200,
body: pdf.toString("base64"),
body: buffer.toString("base64"),
isBase64Encoded: true,
};
}
export function pdfResponse(pdf: Buffer, fileName: string) {
return base64EncodedResponse();
}

export async function downloadPDF() {
// const cloud = require("@sparticuz/chromium");
// // biome-ignore lint/style/useSingleVarDeclarator: <explanation>
// const executablePath = await cloud.executablePath()
// const { chromium } = require("playwright-core");

return pdfResponse(null, "portfolio.pdf");
}

0 comments on commit e50d36f

Please sign in to comment.