Skip to content

🎥 Make videos programmatically with React

fix types

Jonny Burger7f62f90dc094
diff --git a/packages/docs/docs/lambda/validatewebhooksignature.md b/packages/docs/docs/lambda/validatewebhooksignature.md
index 6f6a524ae9..64d36cf743 100644
--- a/packages/docs/docs/lambda/validatewebhooksignature.md
+++ b/packages/docs/docs/lambda/validatewebhooksignature.md
@@ -20,7 +20,7 @@ The same webhook secret that was passed to [`renderMediaOnLambda()`](/docs/lambd
### `body`
-The body that was received by the endpoint.
+The body that was received by the endpoint - takes a parsed JSON object, not a `string`.
### `signatureHeader`
@@ -32,7 +32,7 @@ In the following Next.JS webhook endpoint, an error gets thrown if the signature
```tsx twoslash title="pages/api/webhook.ts"
type NextApiRequest = {
- body: string;
+ body: object;
headers: Record<string, string>;
};
type NextApiResponse = {
@@ -55,7 +55,7 @@ export default async function handler(
});
// If code reaches this path, the webhook is authentic.
- const payload = JSON.parse(req.body) as WebhookPayload;
+ const payload = req.body as WebhookPayload;
if (payload.type === "success") {
// ...
} else if (payload.type === "timeout") {
diff --git a/packages/lambda/src/api/validate-webhook-signature.ts b/packages/lambda/src/api/validate-webhook-signature.ts
index 3ca398bd04..f67c2cd9e3 100644
--- a/packages/lambda/src/api/validate-webhook-signature.ts
+++ b/packages/lambda/src/api/validate-webhook-signature.ts
@@ -12,7 +12,7 @@ export const validateWebhookSignature = ({
signatureHeader,
}: {
secret: string;
- body: string;
+ body: unknown;
signatureHeader: string;
}) => {
if (!secret) {