Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

nullish stats to guard against broken API

Steven Tey55941e12ae54
diff --git a/apps/web/lib/api/scrape-creators/schema.ts b/apps/web/lib/api/scrape-creators/schema.ts
index 58a5b58c95..e5bad28bfa 100644
--- a/apps/web/lib/api/scrape-creators/schema.ts
+++ b/apps/web/lib/api/scrape-creators/schema.ts
@@ -50,9 +50,9 @@ export const profileResponseSchema = z.preprocess(
platform: z.literal("youtube"),
description: z.string(),
channelId: z.string(),
- videoCount: z.number(),
- subscriberCount: z.number(),
- viewCount: z.number(),
+ videoCount: z.number().nullish().default(0),
+ subscriberCount: z.number().nullish().default(0),
+ viewCount: z.number().nullish().default(0),
}),
z.object({
@@ -60,8 +60,12 @@ export const profileResponseSchema = z.preprocess(
data: z.object({
user: z.object({
biography: z.string(),
- edge_followed_by: z.object({ count: z.number() }),
- edge_owner_to_timeline_media: z.object({ count: z.number() }),
+ edge_followed_by: z.object({
+ count: z.number().nullish().default(0),
+ }),
+ edge_owner_to_timeline_media: z.object({
+ count: z.number().nullish().default(0),
+ }),
}),
}),
}),
@@ -74,9 +78,9 @@ export const profileResponseSchema = z.preprocess(
uniqueId: z.string(),
}),
stats: z.object({
- followerCount: z.number(),
- videoCount: z.number(),
- heartCount: z.number(),
+ followerCount: z.number().nullish().default(0),
+ videoCount: z.number().nullish().default(0),
+ heartCount: z.number().nullish().default(0),
}),
}),
@@ -85,8 +89,8 @@ export const profileResponseSchema = z.preprocess(
rest_id: z.string(),
legacy: z.object({
description: z.string(),
- followers_count: z.number(),
- statuses_count: z.number(),
+ followers_count: z.number().nullish().default(0),
+ statuses_count: z.number().nullish().default(0),
}),
}),
]),