Skip to content

Commit

Permalink
Updated fastify event notification JSDoc example
Browse files Browse the repository at this point in the history
  • Loading branch information
domwebber committed Dec 5, 2024
1 parent 837a900 commit da9832f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/rich-planes-do.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@great-detail/whatsapp": patch
---

Update Documentation for Fastify Raw Body Parsing
10 changes: 9 additions & 1 deletion src/Webhook/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,22 @@ export default class Webhook {
* **Fastify**:
*
* ```ts
* // See: https://github.com/fastify/fastify/issues/707#issuecomment-817224931
* fastify.addContentTypeParser("application/json", { parseAs: "buffer" }, (_req, body, done) => {
* done(null, body);
* });
*
* fastify.route({
* method: "GET",
* url: "/path/to/webhook",
* handler: (request, reply) => {
* assert(Buffer.isBuffer(request.body) || typeof request.body === "string");
* const body = request.body.toString();
*
* const reg = await sdk.webhook.register({
* method: request.method,
* query: request.query,
* body: JSON.stringify(request.body),
* body,
* headers: request.headers,
* });
* // DIY: Check the reg.verifyToken value
Expand Down

0 comments on commit da9832f

Please sign in to comment.