Skip to content

Commit 04fd340

Browse files
committed
feat: add lightpandaTask
1 parent 477e169 commit 04fd340

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { logger, task } from "@trigger.dev/sdk/v3";
2+
import { execSync } from "node:child_process";
3+
4+
export const lightpandaFetch = task({
5+
id: "lightpanda-fetch",
6+
machine: {
7+
preset: "micro",
8+
},
9+
run: async (payload: { url: string }, { ctx }) => {
10+
logger.log("Lets get a page's content with Lightpanda!", { payload, ctx });
11+
12+
if (!payload.url) {
13+
logger.warn("Please define the payload url");
14+
throw new Error("payload.url is undefined");
15+
}
16+
17+
const e = execSync(
18+
`${process.env.LIGHTPANDA_BROWSER_PATH} fetch --dump ${payload.url}`,
19+
);
20+
21+
return {
22+
message: e.toString(),
23+
};
24+
},
25+
});

0 commit comments

Comments
 (0)