api/src/types.ts
75 lines · 1625 bytes
1// Core runtime types shared across the app
2import type { Storage } from '@/lib/cache'
3
4export interface ShortService {
5 name: string
6 url: string
7 description?: string
8 icon?: string
9}
10
11export interface Service extends ShortService {
12 github?: string
13 followWith?: string
14 securityAudited?: boolean
15 openSource?: boolean
16 acceptsCrypto?: boolean
17 tosdrId?: number | string
18 androidApp?: string
19 iosApp?: string
20 subreddit?: string
21 discordInvite?: string
22}
23
24export interface Section {
25 name: string
26 services: Service[]
27 intro?: string
28 notableMentions?: ShortService[] | string
29 furtherInfo?: string
30 wordOfWarning?: string
31 alternativeTo?: string[]
32}
33
34export interface Category {
35 name: string
36 sections: Section[]
37}
38
39export interface AwesomePrivacy {
40 categories: Category[]
41}
42
43// Flattened service for listing and search, with slug context
44export interface FlatService extends Service {
45 slug: string
46 category: string
47 categorySlug: string
48 section: string
49 sectionSlug: string
50}
51
52export interface RateLimiter {
53 limit(opts: { key: string }): Promise<{ success: boolean }>
54}
55
56// Unified environment seen by both Workers + Node
57export interface AppEnv {
58 API_TOKEN?: string
59 // When truthy, /enrich/* requires a valid bearer token (off by default)
60 REQUIRE_AUTH?: string
61 DISCORD_BOT_TOKEN?: string
62 APIVOID_API_KEY?: string
63 EXODUS_TOKEN?: string
64 GITHUB_TOKEN?: string
65 DOCKERHUB_TOKEN?: string
66 CACHE?: KVNamespace
67 RATE_LIMIT?: RateLimiter
68 ENRICH_RATE_LIMIT?: RateLimiter
69 API_BASE?: string
70}
71
72export type HonoEnv = {
73 Bindings: AppEnv
74 Variables: { storage: Storage }
75}