Skip to content

Commit

Permalink
refactor(api): rename core and update function structure
Browse files Browse the repository at this point in the history
  • Loading branch information
ax-sh committed Dec 2, 2024
1 parent 505aaf5 commit cc116f1
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 18 deletions.
11 changes: 11 additions & 0 deletions api/core/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
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 };
}

export const cloud = require("chrome-aws-lambda");
export const desc = "Api for pdf generation";
13 changes: 13 additions & 0 deletions api/index.ts
Original file line number Diff line number Diff line change
@@ -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 }),
};
};
4 changes: 2 additions & 2 deletions biome.jsonc
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
Binary file modified bun.lockb
Binary file not shown.
1 change: 0 additions & 1 deletion core/index.ts

This file was deleted.

10 changes: 0 additions & 10 deletions functions/index.ts

This file was deleted.

10 changes: 5 additions & 5 deletions netlify.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[build]
functions = "./functions"
core = "./functions"
functions = "api"
command = "bun run build"

[functions]
node_bundler = "esbuild"
Expand All @@ -10,6 +10,6 @@
# totally optional, but makes up for
# a much better UX
[[redirects]]
from = "/"
to = "/.netlify/functions/index"
status = 200
from = "/"
to = "/.netlify/functions/index"
status = 200
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down

0 comments on commit cc116f1

Please sign in to comment.