Skip to content

Commit

Permalink
Handle string dates
Browse files Browse the repository at this point in the history
  • Loading branch information
jalvarado91 committed Mar 14, 2024
1 parent fa16089 commit 10f5dd2
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/server/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import { syncAllCollectives } from "@/pages/api/internal/sync-episodes";
export type DBTrack = {
source: "SOUNDCLOUD" | "MIXCLOUD";
duration: number;
created_time: Date;
// TODO: In Prod, mixcloud episodes have string dates
created_time: string | Date;
key: number;
name: string;
url: string;
Expand All @@ -27,8 +28,14 @@ export function episodeProjection(t: WithId<DBTrack>) {
id: t._id.toString(),
source: t.source,
duration: t.duration,
releasedAt: t.created_time.toISOString(),
createadAt: t.created_time.toISOString(),
releasedAt:
typeof t.created_time !== "string"
? t.created_time.toISOString()
: t.created_time,
createadAt:
typeof t.created_time !== "string"
? t.created_time.toISOString()
: t.created_time,
embedPlayerKey: t.key,
name: t.name,
permalinkUrl: t.url,
Expand Down

0 comments on commit 10f5dd2

Please sign in to comment.