-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: update README and refactor PDF response functions
- Loading branch information
Showing
2 changed files
with
27 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} |