MCPcopy Create free account
hub / github.com/boringstack-xyz/boringstack / parseResendBody

Function parseResendBody

apps/api/src/api/webhooks/resend.utils.ts:129–149  ·  view source on GitHub ↗
(rawBody: string)

Source from the content-addressed store, hash-verified

127};
128
129const parseResendBody = (rawBody: string): IResendEventBase => {
130 let parsed: unknown;
131
132 try {
133 parsed = JSON.parse(rawBody);
134 } catch (error: unknown) {
135 throw ApiErrors.validation(
136 `Resend webhook body is not a valid JSON event: ${
137 error instanceof Error ? error.message : "unknown"
138 }`
139 );
140 }
141
142 if (!isResendEventShape(parsed)) {
143 throw ApiErrors.validation(
144 "Resend webhook body is missing a string `type` field"
145 );
146 }
147
148 return parsed;
149};
150
151const isResendEventShape = (value: unknown): value is IResendEventBase => {
152 if (value === null || typeof value !== "object") {

Callers 1

verifyResendWebhookFunction · 0.85

Calls 1

isResendEventShapeFunction · 0.85

Tested by

no test coverage detected