Skip to content

Commit 46dbc3d

Browse files
committed
Update route.ts
1 parent 1c08e7b commit 46dbc3d

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

apps/web/app/api/notifications/route.ts

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -96,34 +96,34 @@ export async function GET() {
9696

9797
return yield* Effect.all(
9898
notificationsWithAuthors.map(({ notification, author }) =>
99-
Effect.fn(function* () {
100-
try {
101-
// all notifications currently require an author
102-
if (!author) return null;
99+
Effect.gen(function* () {
100+
// all notifications currently require an author
101+
if (!author) return null;
103102

104-
const resolvedAvatar = author.avatar
105-
? yield* imageUploads.resolveImageUrl(author.avatar)
106-
: null;
103+
const resolvedAvatar = author.avatar
104+
? yield* imageUploads.resolveImageUrl(author.avatar)
105+
: null;
107106

108-
return APINotification.parse({
109-
id: notification.id,
110-
type: notification.type,
111-
readAt: notification.readAt,
112-
videoId: notification.data.videoId,
113-
createdAt: notification.createdAt,
114-
data: notification.data,
115-
comment: notification.data.comment,
116-
author: {
117-
id: author.id,
118-
name: author.name ?? "Unknown",
119-
avatar: resolvedAvatar,
120-
},
121-
});
122-
} catch (error) {
107+
return APINotification.parse({
108+
id: notification.id,
109+
type: notification.type,
110+
readAt: notification.readAt,
111+
videoId: notification.data.videoId,
112+
createdAt: notification.createdAt,
113+
data: notification.data,
114+
comment: notification.data.comment,
115+
author: {
116+
id: author.id,
117+
name: author.name ?? "Unknown",
118+
avatar: resolvedAvatar,
119+
},
120+
});
121+
}).pipe(
122+
Effect.catchAll((error) => {
123123
console.error("Invalid notification data:", error);
124-
return null;
125-
}
126-
})(),
124+
return Effect.succeed(null);
125+
}),
126+
),
127127
),
128128
);
129129
})

0 commit comments

Comments
 (0)