File tree Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -442,27 +442,26 @@ and obtain a Seam webhook secret.
442
442
> This example is for [ Express] , see the [ Svix docs for more examples in specific frameworks] ( https://docs.svix.com/receiving/verifying-payloads/how ) .
443
443
444
444
``` js
445
+ import { env } from ' node:process'
446
+
445
447
import { SeamWebhook } from ' seam'
446
448
import express from ' express'
447
449
import bodyParser from ' body-parser'
448
450
449
- import { storeEvent } from ' ./store-event.js'
450
-
451
451
const app = express ()
452
452
453
- const webhook = new SeamWebhook (process . env .SEAM_WEBHOOK_SECRET )
453
+ const webhook = new SeamWebhook (env .SEAM_WEBHOOK_SECRET )
454
454
455
455
app .post (
456
456
' /webhook' ,
457
457
bodyParser .raw ({ type: ' application/json' }),
458
458
(req , res ) => {
459
459
let data
460
460
try {
461
- data = webhook .verify (payload, headers)
461
+ data = webhook .verify (req . body , req . headers )
462
462
} catch {
463
463
return res .status (400 ).send ()
464
464
}
465
-
466
465
storeEvent (data, (err ) => {
467
466
if (err != null ) {
468
467
return res .status (500 ).send ()
@@ -471,6 +470,15 @@ app.post(
471
470
})
472
471
},
473
472
)
473
+
474
+ const storeEvent = (data , callback ) => {
475
+ console .log (data)
476
+ callback ()
477
+ }
478
+
479
+ app .listen (8080 , () => {
480
+ console .log (' Ready to receive webhooks at http://localhost:8080/webhook' )
481
+ })
474
482
```
475
483
476
484
[ Express ] : https://expressjs.com/
You can’t perform that action at this time.
0 commit comments