More code comments in the examples
This commit is contained in:
@@ -12,6 +12,7 @@ new Trigger({
|
||||
name: "user.created",
|
||||
//todo define the schema for the events you want to receive
|
||||
//this example accepts JSON like this: { id: "123", admin: false }
|
||||
//you can use z.any() to accept any data, but you won't get payload validation or type inference in run()
|
||||
schema: z.object({ id: z.string(), admin: z.boolean() }),
|
||||
//todo define or remove the filter
|
||||
//filters are optional, but can be used to filter out events
|
||||
|
||||
@@ -7,8 +7,13 @@ new Trigger({
|
||||
// For security, we recommend moving this api key to your .env / secrets file.
|
||||
// Our env variable is called TRIGGER_API_KEY
|
||||
apiKey: "${apiKey}",
|
||||
//todo set your CRON expression here
|
||||
//this example runs every Monday at 2:30pm UTC
|
||||
//this site is useful when writing CRON: https://crontab.guru
|
||||
//you don't have to wait to test, use our "Test" button on your workflow page
|
||||
on: scheduleEvent({ cron: "30 14 * * 1" }),
|
||||
run: async (event, ctx) => {
|
||||
//this function is run every Monday at 2:30pm UTC
|
||||
await ctx.logger.info("Received the cron scheduled event", {
|
||||
event,
|
||||
wallTime: new Date(),
|
||||
|
||||
@@ -7,8 +7,12 @@ new Trigger({
|
||||
// For security, we recommend moving this api key to your .env / secrets file.
|
||||
// Our env variable is called TRIGGER_API_KEY
|
||||
apiKey: "${apiKey}",
|
||||
//todo set how often you want your event to fire here
|
||||
//this example runs every 5 minutes, the first run will be 5 minutes after the workflow is first connected
|
||||
//you don't have to wait to test, use our "Test" button on your workflow page
|
||||
on: scheduleEvent({ rateOf: { minutes: 5 } }),
|
||||
run: async (event, ctx) => {
|
||||
//this function is run every 5 minutes
|
||||
await ctx.logger.info("Received the scheduled event", {
|
||||
event,
|
||||
wallTime: new Date(),
|
||||
|
||||
@@ -9,6 +9,9 @@ new Trigger({
|
||||
// For security, we recommend moving this api key to your .env / secrets file.
|
||||
// Our env variable is called TRIGGER_API_KEY
|
||||
apiKey: "${apiKey}",
|
||||
//todo define the schema for the events you want to receive
|
||||
//this example accepts an empty JSON object: {}
|
||||
//you can use z.any() to accept any JSON, but you won't get nice types in the run function
|
||||
on: customEvent({
|
||||
name: "shopify.products",
|
||||
schema: z.object({}),
|
||||
|
||||
Reference in New Issue
Block a user