feat: base pages and news fetching with cron job

This commit is contained in:
Riccardo
2023-11-25 09:20:38 +01:00
parent aa34263bdf
commit 74ec709155
31 changed files with 10641 additions and 123 deletions

25
app/utils/types.ts Normal file
View File

@@ -0,0 +1,25 @@
import { z } from 'zod';
export const ResponseSchema = z.object({
message: z.string(),
});
export const SubscribeFormSchema = z.object({
email: z.string().email(),
targetingAllowed: z.boolean(),
});
export const UnsubscribeFormSchema = z.object({
email: z.string().email(),
});
export const NewsSchema = z.object({
id: z.number(),
title: z.string(),
text: z.string().optional(),
type: z.string(),
by: z.string(),
time: z.number(),
url: z.string().optional(),
score: z.number(),
});

3
app/utils/urls.ts Normal file
View File

@@ -0,0 +1,3 @@
export const topNews = 'https://hacker-news.firebaseio.com/v0/topstories.json';
export const singleNews = (id: number) =>
`https://hacker-news.firebaseio.com/v0/item/${id}.json`;