Skip to content

Commit 8cca0f5

Browse files
committed
added sample code and renamed files
1 parent da77429 commit 8cca0f5

6 files changed

Lines changed: 77 additions & 4 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
export const customEvent = `import { customEvent, Trigger } from "@trigger.dev/sdk";
2+
3+
new Trigger({
4+
id: "user-created-notify-slack",
5+
name: "User Created - Notify Slack",
6+
on: customEvent({
7+
name: "user.created",
8+
schema: z.object({ id: z.string(), admin: z.boolean() }),
9+
filter: {
10+
admin: [false],
11+
},
12+
}),
13+
run: async (event, ctx) => {},
14+
}).listen();`;

apps/webapp/app/components/samples/customEvent.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
export const githubStars = `
2+
// When a GitHub issue is created or modified, post to Slack
3+
4+
import { Trigger } from "@trigger.dev/sdk";
5+
import * as github from "@trigger.dev/github";
6+
import * as slack from "@trigger.dev/slack";
7+
8+
new Trigger({
9+
id: "my-workflow-1",
10+
name: "Posts to Slack when GitHub Issue created or modified",
11+
apiKey: "<my_api_key>",
12+
on: github.events.issueEvent({
13+
repo: "my-github-org/my-github-repo",
14+
}),
15+
16+
run: async (event, ctx) => {
17+
const response = await slack.postMessage("send-to-slack", {
18+
channelName: "my-slack-channel-name",
19+
text: \`A new issue has been created or modified. \${event.action}\`,
20+
});
21+
22+
return response.message;
23+
},
24+
}).listen();`;

apps/webapp/app/components/samples/githubStars.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,20 @@
1-
export const scheduled = `paste code block here`;
1+
export const scheduled = `import { scheduleEvent, Trigger } from "@trigger.dev/sdk";
2+
3+
new Trigger({
4+
id: "usage",
5+
name: "usage",
6+
on: scheduleEvent({ rateof: { minutes: 10 } }),
7+
run: async (event, ctx) => {
8+
const { lastRunAt, scheduledTime } = event;
9+
10+
const query = \`SELECT * FROM users WHERE created_at < \${scheduledTime}\`;
11+
12+
if (lastRunAt) {
13+
query += \` AND created_at > \${lastRunAt}\`;
14+
}
15+
16+
const latestUsers = await db.query(query);
17+
18+
// ...
19+
},
20+
}).listen();`;
Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,19 @@
1-
export const webhook = `paste code block here`;
1+
export const webhook = `import { webhookEvent, Trigger } from "@trigger.dev/sdk";
2+
3+
new Trigger({
4+
id: "caldotcom-to-slack",
5+
name: "Cal.com To Slack",
6+
on: webhookEvent({
7+
service: "cal.com",
8+
eventName: "BOOKING_CREATED",
9+
filter: {
10+
triggerEvent: ["BOOKING_CREATED"],
11+
},
12+
schema: z.any(),
13+
verifyPayload: {
14+
enabled: true,
15+
header: "X-Cal-Signature-256",
16+
},
17+
}),
18+
run: async (event, ctx) => {},
19+
}).listen();`;

0 commit comments

Comments
 (0)