@@ -118,13 +118,17 @@ Replace the `database-webhook` placeholder code with the following:
118
118
``` ts database-webhook/index.ts
119
119
import " jsr:@supabase/functions-js/edge-runtime.d.ts" ;
120
120
import {
tasks }
from " npm:@trigger.dev/[email protected] /v3" ;
121
- // Import your task type from your /trigger folder
122
- import type { helloWorldTask } from " ../../../src/trigger/example.ts" ;
121
+ import { helloWorldTask } from " ../../../src/trigger/example.ts" ;
122
+
123
+ console .log (" Hello from 'database-webhook' function!" );
123
124
124
125
Deno .serve (async (req ) => {
125
- // @ts-expect-error: Ignoring Task type mismatch and RunHandle incompatibility
126
- await tasks .trigger <typeof helloWorldTask >(" database-webhook" , " hello" );
127
- return new Response (" OK" );
126
+ const payload = await req .json ();
127
+
128
+ await tasks .trigger <typeof helloWorldTask >(" hello-world" , " hello" );
129
+ console .log (payload ?? " No name provided" );
130
+
131
+ return new Response (" ok" );
128
132
});
129
133
```
130
134
@@ -173,6 +177,29 @@ Call the hook `edge-function-hook`:
173
177
[ How to configure the webhook] ( )
174
178
175
179
</Step >
180
+
181
+ <Step title = " Deploy your 'Hello World' task" >
182
+
183
+ Go back to your project and deploy your ` hello-world ` task to [ Trigger.dev cloud] ( https://cloud.trigger.dev ) .
184
+
185
+ <CodeGroup >
186
+
187
+ ``` bash npm
188
+ npx trigger.dev@beta deploy
189
+ ```
190
+
191
+ ``` bash pnpm
192
+ pnpm dlx trigger.dev@beta deploy
193
+ ```
194
+
195
+ ``` bash yarn
196
+ yarn dlx trigger.dev@beta deploy
197
+ ```
198
+
199
+ </CodeGroup >
200
+
201
+ </Step >
202
+
176
203
<Step title = " Trigger your new database webhook edge function" >
177
204
178
205
Go back to your Supabase dashboard, click on 'Table Editor' in the left-hand menu, and then click on the ` skynet ` table.
@@ -185,6 +212,8 @@ Go back to your edge function dashboard, and you should see a new run of your ed
185
212
186
213
[ How to view the logs] ( )
187
214
215
+ Check your [ cloud.trigger.dev] ( http://cloud.trigger.dev ) dashboard and you should see a succesful ` hello-world ` task.
216
+
188
217
Congratulations, you have successfully triggered a task from a Supabase edge function using a database webhook!
189
218
190
219
</Step >
0 commit comments