1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
import { z } from "zod";
// Top stories from Hacker News (always) plus any configured subreddits.
// Both are keyless public JSON APIs.
export const HackerNewsConfig = z.object({
limit: z.number().int().min(1).max(30).default(10),
subreddits: z.array(z.string()).default([]),
});
export type HackerNewsConfig = z.infer<typeof HackerNewsConfig>;
export const FeedStory = z.object({
source: z.string(), // "HN" | "r/<sub>"
title: z.string(),
points: z.number().nullable(),
comments: z.number().nullable(),
url: z.string().nullable(),
});
export const HackerNewsPayload = z.object({
stories: z.array(FeedStory).default([]),
});
export type HackerNewsPayload = z.infer<typeof HackerNewsPayload>;
|