Skip to content

Commit 1774122

Browse files
committed
ci: Generate code
1 parent 5e7d415 commit 1774122

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

README.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -442,27 +442,26 @@ and obtain a Seam webhook secret.
442442
> This example is for [Express], see the [Svix docs for more examples in specific frameworks](https://docs.svix.com/receiving/verifying-payloads/how).
443443
444444
```js
445+
import { env } from 'node:process'
446+
445447
import { SeamWebhook } from 'seam'
446448
import express from 'express'
447449
import bodyParser from 'body-parser'
448450

449-
import { storeEvent } from './store-event.js'
450-
451451
const app = express()
452452

453-
const webhook = new SeamWebhook(process.env.SEAM_WEBHOOK_SECRET)
453+
const webhook = new SeamWebhook(env.SEAM_WEBHOOK_SECRET)
454454

455455
app.post(
456456
'/webhook',
457457
bodyParser.raw({ type: 'application/json' }),
458458
(req, res) => {
459459
let data
460460
try {
461-
data = webhook.verify(payload, headers)
461+
data = webhook.verify(req.body, req.headers)
462462
} catch {
463463
return res.status(400).send()
464464
}
465-
466465
storeEvent(data, (err) => {
467466
if (err != null) {
468467
return res.status(500).send()
@@ -471,6 +470,15 @@ app.post(
471470
})
472471
},
473472
)
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+
})
474482
```
475483

476484
[Express]: https://expressjs.com/

0 commit comments

Comments
 (0)