Commit c6b6da5b1e

c6b6da5b1ebdac76683e7c37bec522edcbb2a2d2

parent: e42299c072

Unsigned

Alicia Sykes <alicia@omg.lol> · 2026-06-10 07:22 UTC

Configuation for api on docker and wrangler

Layout: unified · split

.github/workflows/ci-api.yml +13 −7
@@ -29,7 +29,7 @@ jobs:
29 persist-credentials: false 29 persist-credentials: false
30 - uses: oven-sh/setup-bun@v2 30 - uses: oven-sh/setup-bun@v2
31 with: 31 with:
32 bun-version: latest 32 bun-version: 1.3.10
33 - run: bun install --frozen-lockfile 33 - run: bun install --frozen-lockfile
34 - run: bun run lint 34 - run: bun run lint
35 35
@@ -45,7 +45,7 @@ jobs:
45 persist-credentials: false 45 persist-credentials: false
46 - uses: oven-sh/setup-bun@v2 46 - uses: oven-sh/setup-bun@v2
47 with: 47 with:
48 bun-version: latest 48 bun-version: 1.3.10
49 - run: bun install --frozen-lockfile 49 - run: bun install --frozen-lockfile
50 - run: bun run format:check 50 - run: bun run format:check
51 51
@@ -61,7 +61,7 @@ jobs:
61 persist-credentials: false 61 persist-credentials: false
62 - uses: oven-sh/setup-bun@v2 62 - uses: oven-sh/setup-bun@v2
63 with: 63 with:
64 bun-version: latest 64 bun-version: 1.3.10
65 - run: bun install --frozen-lockfile 65 - run: bun install --frozen-lockfile
66 - run: bun run build:data 66 - run: bun run build:data
67 - run: bun run typecheck 67 - run: bun run typecheck
@@ -78,7 +78,7 @@ jobs:
78 persist-credentials: false 78 persist-credentials: false
79 - uses: oven-sh/setup-bun@v2 79 - uses: oven-sh/setup-bun@v2
80 with: 80 with:
81 bun-version: latest 81 bun-version: 1.3.10
82 - run: bun install --frozen-lockfile 82 - run: bun install --frozen-lockfile
83 - run: bun run build:data 83 - run: bun run build:data
84 - run: bun run test 84 - run: bun run test
@@ -95,7 +95,7 @@ jobs:
95 persist-credentials: false 95 persist-credentials: false
96 - uses: oven-sh/setup-bun@v2 96 - uses: oven-sh/setup-bun@v2
97 with: 97 with:
98 bun-version: latest 98 bun-version: 1.3.10
99 - run: bun install --frozen-lockfile 99 - run: bun install --frozen-lockfile
100 - run: bun run build 100 - run: bun run build
101 - name: Verify bundle output 101 - name: Verify bundle output
@@ -113,14 +113,15 @@ jobs:
113 persist-credentials: false 113 persist-credentials: false
114 - uses: oven-sh/setup-bun@v2 114 - uses: oven-sh/setup-bun@v2
115 with: 115 with:
116 bun-version: latest 116 bun-version: 1.3.10
117 - run: bun install --frozen-lockfile 117 - run: bun install --frozen-lockfile
118 - run: bun run smoke 118 - run: bun run smoke
119 119
120 docker-smoke: 120 docker-smoke:
121 name: 🐳 Docker Smoke 121 name: 🐳 Docker Smoke
122 runs-on: ubuntu-latest 122 runs-on: ubuntu-latest
123 continue-on-error: true 123 outputs:
124 result: ${{ steps.run.outcome }}
124 defaults: 125 defaults:
125 run: 126 run:
126 working-directory: api 127 working-directory: api
@@ -129,6 +130,8 @@ jobs:
129 with: 130 with:
130 persist-credentials: false 131 persist-credentials: false
131 - name: Build and run container 132 - name: Build and run container
133 id: run
134 continue-on-error: true
132 run: bash tests/docker-smoke.sh 135 run: bash tests/docker-smoke.sh
133 timeout-minutes: 10 136 timeout-minutes: 10
134 137
@@ -212,5 +215,8 @@ jobs:
212 } >> "$GITHUB_STEP_SUMMARY" 215 } >> "$GITHUB_STEP_SUMMARY"
213 for job in $(echo "$NEEDS" | jq -r 'keys[]'); do 216 for job in $(echo "$NEEDS" | jq -r 'keys[]'); do
214 result=$(echo "$NEEDS" | jq -r --arg j "$job" '.[$j].result') 217 result=$(echo "$NEEDS" | jq -r --arg j "$job" '.[$j].result')
218 if [ "$job" = docker-smoke ]; then
219 result=$(echo "$NEEDS" | jq -r '."docker-smoke".outputs.result // "skipped"')
220 fi
215 echo "| $(label "$job") | $(status "$result" "$job") |" >> "$GITHUB_STEP_SUMMARY" 221 echo "| $(label "$job") | $(status "$result" "$job") |" >> "$GITHUB_STEP_SUMMARY"
216 done 222 done
.github/workflows/deploy.yml +2 −2
@@ -29,7 +29,7 @@ jobs:
29 persist-credentials: false 29 persist-credentials: false
30 - uses: oven-sh/setup-bun@v2 30 - uses: oven-sh/setup-bun@v2
31 with: 31 with:
32 bun-version: latest 32 bun-version: 1.3.10
33 - run: bun install --frozen-lockfile 33 - run: bun install --frozen-lockfile
34 - run: bun run build:data 34 - run: bun run build:data
35 - run: bun run lint 35 - run: bun run lint
@@ -48,7 +48,7 @@ jobs:
48 persist-credentials: false 48 persist-credentials: false
49 - uses: oven-sh/setup-bun@v2 49 - uses: oven-sh/setup-bun@v2
50 with: 50 with:
51 bun-version: latest 51 bun-version: 1.3.10
52 - run: bun install --frozen-lockfile 52 - run: bun install --frozen-lockfile
53 - name: Build data and deploy worker 53 - name: Build data and deploy worker
54 env: 54 env:
api/src/app.ts +1 −1
@@ -101,7 +101,7 @@ export const buildApp = () => {
101<summary>Authenticating</summary> 101<summary>Authenticating</summary>
102 102
103By default, no auth is needed. 103By default, no auth is needed.
104If you're self-hosting, you can enable auth by setting the \`API_KEY\` env var. 104If you're self-hosting, you can enable auth by setting the \`API_TOKEN\` env var.
105Then, add the \`Authorization: Bearer <your-token>\` header when accessing the enrichment endpoints. 105Then, add the \`Authorization: Bearer <your-token>\` header when accessing the enrichment endpoints.
106</details> 106</details>
107 107
api/src/lib/env.ts +1
@@ -14,6 +14,7 @@ export const readEnv = (workersEnv?: Partial<AppEnv>): AppEnv => {
14 APIVOID_API_KEY: workersEnv?.APIVOID_API_KEY ?? env.APIVOID_API_KEY, 14 APIVOID_API_KEY: workersEnv?.APIVOID_API_KEY ?? env.APIVOID_API_KEY,
15 EXODUS_TOKEN: workersEnv?.EXODUS_TOKEN ?? env.EXODUS_TOKEN, 15 EXODUS_TOKEN: workersEnv?.EXODUS_TOKEN ?? env.EXODUS_TOKEN,
16 GITHUB_TOKEN: workersEnv?.GITHUB_TOKEN ?? env.GITHUB_TOKEN, 16 GITHUB_TOKEN: workersEnv?.GITHUB_TOKEN ?? env.GITHUB_TOKEN,
17 DOCKERHUB_TOKEN: workersEnv?.DOCKERHUB_TOKEN ?? env.DOCKERHUB_TOKEN,
17 CACHE: workersEnv?.CACHE, 18 CACHE: workersEnv?.CACHE,
18 RATE_LIMIT: workersEnv?.RATE_LIMIT, 19 RATE_LIMIT: workersEnv?.RATE_LIMIT,
19 API_BASE: workersEnv?.API_BASE ?? env.API_BASE, 20 API_BASE: workersEnv?.API_BASE ?? env.API_BASE,
api/wrangler.toml +12 −1
@@ -1,8 +1,14 @@
1name = "awesome-privacy-api" 1name = "awesome-privacy-api"
2main = "src/index.workers.ts" 2main = "src/index.workers.ts"
3compatibility_date = "2025-01-01" 3compatibility_date = "2026-05-01"
4compatibility_flags = ["nodejs_compat"] 4compatibility_flags = ["nodejs_compat"]
5 5
6# Only reachable via the custom domain, not a *.workers.dev subdomain
7workers_dev = false
8
9# Readable stack traces in observability logs
10upload_source_maps = true
11
6# Custom domain, auto-creates the DNS record on deploy 12# Custom domain, auto-creates the DNS record on deploy
7[[routes]] 13[[routes]]
8pattern = "api.awesome-privacy.xyz" 14pattern = "api.awesome-privacy.xyz"
@@ -26,3 +32,8 @@ crons = ["*/15 * * * *"]
26 32
27[vars] 33[vars]
28API_BASE = "https://api.awesome-privacy.xyz" 34API_BASE = "https://api.awesome-privacy.xyz"
35
36# Allow observability
37[observability.logs]
38enabled = true
39invocation_logs = true
web/src/pages/[...listing].astro +3 −2
@@ -29,6 +29,7 @@ import { fetchPlexusInfo } from '@utils/fetch-plexus-info';
29import { fetchDiscordInfo } from '@utils/fetch-discord-info'; 29import { fetchDiscordInfo } from '@utils/fetch-discord-info';
30import { fetchRedditInfo } from '@utils/fetch-reddit-info'; 30import { fetchRedditInfo } from '@utils/fetch-reddit-info';
31import { site } from '@utils/config'; 31import { site } from '@utils/config';
32import { apiBase, serviceSlug } from '@utils/api-config';
32import Button from '@components/form/Button.astro'; 33import Button from '@components/form/Button.astro';
33 34
34interface Props extends Service { 35interface Props extends Service {
@@ -233,7 +234,7 @@ const catSlug = slugify(categoryName);
233const secSlug = slugify(parentSection.name); 234const secSlug = slugify(parentSection.name);
234 235
235const getApiEndpoint = () => { 236const getApiEndpoint = () => {
236 return `https://api.awesome-privacy.xyz/${catSlug}/${secSlug}/${slugify(name)}`; 237 return `${apiBase}/v1/services/${serviceSlug(name)}`;
237}; 238};
238 239
239const makeSoftwareSchema = () => { 240const makeSoftwareSchema = () => {
@@ -387,7 +388,7 @@ const makeSoftwareSchema = () => {
387 <pre><a href={getApiEndpoint()}><code>{getApiEndpoint()}</code></a></pre> 388 <pre><a href={getApiEndpoint()}><code>{getApiEndpoint()}</code></a></pre>
388 <p> 389 <p>
389 The REST API is free, no-auth and CORS-enabled. To learn more, view the <a 390 The REST API is free, no-auth and CORS-enabled. To learn more, view the <a
390 href="/api">Swagger Docs</a 391 href={`${apiBase}/docs`}>API Docs</a
391 > or read the <a href="/about#api">API Usage Guide</a>. 392 > or read the <a href="/about#api">API Usage Guide</a>.
392 </p> 393 </p>
393 </section> 394 </section>
web/src/utils/api-config.ts +9
@@ -5,6 +5,15 @@ export const apiBase =
5 strip(import.meta.env.PUBLIC_API_URL || '').replace(/\/+$/, '') || 5 strip(import.meta.env.PUBLIC_API_URL || '').replace(/\/+$/, '') ||
6 'https://api.awesome-privacy.xyz'; 6 'https://api.awesome-privacy.xyz';
7 7
8// Slug a listing name the way the API does, so /v1/services/{slug} resolves.
9// Note: differs from the web's slugify, which keeps dots (e.g. "Rocket.Chat").
10export const serviceSlug = (name: string): string =>
11 name
12 .toLowerCase()
13 .trim()
14 .replace(/[^a-z0-9]+/g, '-')
15 .replace(/^-|-$/g, '');
16
8// Bearer header for enrichment routes; omitted when no token is set. 17// Bearer header for enrichment routes; omitted when no token is set.
9export const enrichHeaders = (): Record<string, string> => { 18export const enrichHeaders = (): Record<string, string> => {
10 const token = strip(import.meta.env.API_TOKEN || ''); 19 const token = strip(import.meta.env.API_TOKEN || '');