Apply suggestions from code review

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
This commit is contained in:
Alan Danielandcoderabbitai[bot] authored and GitHub committed 2026-04-06 19:02:06 -04:00
1 parent 809990e8ea
commit 065ec19daa
2 files changed
+10 -2

No files matched your search

+6 -1
View File
@@ -3,7 +3,12 @@ import { goPageSchema, type GoPage } from '@/types/go'
function isExpired(page: { expiresAt?: string }): boolean {
if (!page.expiresAt) return false
return new Date(page.expiresAt) < new Date()
const [year, month, day] = page.expiresAt.split('-').map(Number)
if (![year, month, day].every(Number.isInteger)) {
throw new Error(`Invalid expiresAt value: "${page.expiresAt}"`)
}
const expiresAtEndOfDayUtc = Date.UTC(year, month - 1, day, 23, 59, 59, 999)
return Date.now() > expiresAtEndOfDayUtc
}
export function getAllGoPages(): GoPage[] {
+4 -1
View File
@@ -333,7 +333,10 @@ const goPageBaseSchema = z.object({
sections: z.array(goSectionSchema).optional(),
publishedAt: z.string().optional(),
/** ISO 8601 date (YYYY-MM-DD) after which the page should return a 404. */
expiresAt: z.string().optional(),
expiresAt: z
.string()
.regex(/^\d{4}-\d{2}-\d{2}$/, 'expiresAt must be YYYY-MM-DD')
.optional(),
})
export const leadGenPageSchema = goPageBaseSchema.extend({