api/src/types.ts
72 lines · 1492 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 DISCORD_BOT_TOKEN?: string
60 APIVOID_API_KEY?: string
61 EXODUS_TOKEN?: string
62 GITHUB_TOKEN?: string
63 DOCKERHUB_TOKEN?: string
64 CACHE?: KVNamespace
65 RATE_LIMIT?: RateLimiter
66 API_BASE?: string
67}
68
69export type HonoEnv = {
70 Bindings: AppEnv
71 Variables: { storage: Storage }
72}