diff --git a/api/core/index.ts b/api/core/index.ts new file mode 100644 index 0000000..a6ba6a4 --- /dev/null +++ b/api/core/index.ts @@ -0,0 +1,11 @@ +export async function downloadPDF() { + // const cloud = require("@sparticuz/chromium"); + // // biome-ignore lint/style/useSingleVarDeclarator: + // const executablePath = await cloud.executablePath() + const { chromium } = require("playwright-core"); + + return { c: chromium }; +} + +export const cloud = require("chrome-aws-lambda"); +export const desc = "Api for pdf generation"; diff --git a/api/index.ts b/api/index.ts new file mode 100644 index 0000000..e5ac941 --- /dev/null +++ b/api/index.ts @@ -0,0 +1,13 @@ +// // Netlify On-demand Builder (runs on first request only) +// // exports.handler = builder(handler); + +import type { Handler } from "@netlify/functions"; + +export const handler: Handler = async (event, context) => { + const core = await import("../api/core"); + const data = await core.downloadPDF(); + return { + statusCode: 200, + body: JSON.stringify({ data }), + }; +}; diff --git a/biome.jsonc b/biome.jsonc index 2eb0751..208387f 100644 --- a/biome.jsonc +++ b/biome.jsonc @@ -1,9 +1,9 @@ { "$schema": "https://biomejs.dev/schemas/1.9.4/schema.json", "vcs": { - "enabled": false, + "enabled": true, "clientKind": "git", - "useIgnoreFile": false + "useIgnoreFile": true }, "files": { "ignoreUnknown": false, diff --git a/bun.lockb b/bun.lockb index 48a0ba3..0935435 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/core/index.ts b/core/index.ts deleted file mode 100644 index 67fdfe3..0000000 --- a/core/index.ts +++ /dev/null @@ -1 +0,0 @@ -export const cloud = require("chrome-aws-lambda"); diff --git a/functions/index.ts b/functions/index.ts deleted file mode 100644 index 5812be7..0000000 --- a/functions/index.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { type Handler, builder } from "@netlify/functions"; -import { cloud } from "../core"; -export async function handler() { - return { - statusCode: 200, - body: JSON.stringify({ message: cloud.executablePath }), - }; -} -// Netlify On-demand Builder (runs on first request only) -exports.handler = builder(handler); diff --git a/netlify.toml b/netlify.toml index 7b86eb4..f772377 100644 --- a/netlify.toml +++ b/netlify.toml @@ -1,6 +1,6 @@ [build] - functions = "./functions" - core = "./functions" + functions = "api" + command = "bun run build" [functions] node_bundler = "esbuild" @@ -10,6 +10,6 @@ # totally optional, but makes up for # a much better UX [[redirects]] - from = "/" - to = "/.netlify/functions/index" - status = 200 \ No newline at end of file +from = "/" +to = "/.netlify/functions/index" +status = 200 \ No newline at end of file diff --git a/package.json b/package.json index fbbddf1..03cf1c0 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ }, "dependencies": { "@netlify/functions": "^2.8.2", + "@sparticuz/chromium": "^131.0.1", "chrome-aws-lambda": "^10.1.0", "playwright-core": "^1.49.0" }