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:
2929 persist-credentials: false
3030 - uses: oven-sh/setup-bun@v2
3131 with:
32 bun-version: latest
32 bun-version: 1.3.10
3333 - run: bun install --frozen-lockfile
3434 - run: bun run lint
3535
@@ -45,7 +45,7 @@ jobs:
4545 persist-credentials: false
4646 - uses: oven-sh/setup-bun@v2
4747 with:
48 bun-version: latest
48 bun-version: 1.3.10
4949 - run: bun install --frozen-lockfile
5050 - run: bun run format:check
5151
@@ -61,7 +61,7 @@ jobs:
6161 persist-credentials: false
6262 - uses: oven-sh/setup-bun@v2
6363 with:
64 bun-version: latest
64 bun-version: 1.3.10
6565 - run: bun install --frozen-lockfile
6666 - run: bun run build:data
6767 - run: bun run typecheck
@@ -78,7 +78,7 @@ jobs:
7878 persist-credentials: false
7979 - uses: oven-sh/setup-bun@v2
8080 with:
81 bun-version: latest
81 bun-version: 1.3.10
8282 - run: bun install --frozen-lockfile
8383 - run: bun run build:data
8484 - run: bun run test
@@ -95,7 +95,7 @@ jobs:
9595 persist-credentials: false
9696 - uses: oven-sh/setup-bun@v2
9797 with:
98 bun-version: latest
98 bun-version: 1.3.10
9999 - run: bun install --frozen-lockfile
100100 - run: bun run build
101101 - name: Verify bundle output
@@ -113,14 +113,15 @@ jobs:
113113 persist-credentials: false
114114 - uses: oven-sh/setup-bun@v2
115115 with:
116 bun-version: latest
116 bun-version: 1.3.10
117117 - run: bun install --frozen-lockfile
118118 - run: bun run smoke
119119
120120 docker-smoke:
121121 name: 🐳 Docker Smoke
122122 runs-on: ubuntu-latest
123 continue-on-error: true
123 outputs:
124 result: ${{ steps.run.outcome }}
124125 defaults:
125126 run:
126127 working-directory: api
@@ -129,6 +130,8 @@ jobs:
129130 with:
130131 persist-credentials: false
131132 - name: Build and run container
133 id: run
134 continue-on-error: true
132135 run: bash tests/docker-smoke.sh
133136 timeout-minutes: 10
134137
@@ -212,5 +215,8 @@ jobs:
212215 } >> "$GITHUB_STEP_SUMMARY"
213216 for job in $(echo "$NEEDS" | jq -r 'keys[]'); do
214217 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
215221 echo "| $(label "$job") | $(status "$result" "$job") |" >> "$GITHUB_STEP_SUMMARY"
216222 done
.github/workflows/deploy.yml +2 −2
@@ -29,7 +29,7 @@ jobs:
2929 persist-credentials: false
3030 - uses: oven-sh/setup-bun@v2
3131 with:
32 bun-version: latest
32 bun-version: 1.3.10
3333 - run: bun install --frozen-lockfile
3434 - run: bun run build:data
3535 - run: bun run lint
@@ -48,7 +48,7 @@ jobs:
4848 persist-credentials: false
4949 - uses: oven-sh/setup-bun@v2
5050 with:
51 bun-version: latest
51 bun-version: 1.3.10
5252 - run: bun install --frozen-lockfile
5353 - name: Build data and deploy worker
5454 env:
api/src/app.ts +1 −1
@@ -101,7 +101,7 @@ export const buildApp = () => {
101101<summary>Authenticating</summary>
102102
103103By 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.
105105Then, add the \`Authorization: Bearer <your-token>\` header when accessing the enrichment endpoints.
106106</details>
107107
api/src/lib/env.ts +1
@@ -14,6 +14,7 @@ export const readEnv = (workersEnv?: Partial<AppEnv>): AppEnv => {
1414 APIVOID_API_KEY: workersEnv?.APIVOID_API_KEY ?? env.APIVOID_API_KEY,
1515 EXODUS_TOKEN: workersEnv?.EXODUS_TOKEN ?? env.EXODUS_TOKEN,
1616 GITHUB_TOKEN: workersEnv?.GITHUB_TOKEN ?? env.GITHUB_TOKEN,
17 DOCKERHUB_TOKEN: workersEnv?.DOCKERHUB_TOKEN ?? env.DOCKERHUB_TOKEN,
1718 CACHE: workersEnv?.CACHE,
1819 RATE_LIMIT: workersEnv?.RATE_LIMIT,
1920 API_BASE: workersEnv?.API_BASE ?? env.API_BASE,
api/wrangler.toml +12 −1
@@ -1,8 +1,14 @@
11name = "awesome-privacy-api"
22main = "src/index.workers.ts"
3compatibility_date = "2025-01-01"
3compatibility_date = "2026-05-01"
44compatibility_flags = ["nodejs_compat"]
55
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
612# Custom domain, auto-creates the DNS record on deploy
713[[routes]]
814pattern = "api.awesome-privacy.xyz"
@@ -26,3 +32,8 @@ crons = ["*/15 * * * *"]
2632
2733[vars]
2834API_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';
2929import { fetchDiscordInfo } from '@utils/fetch-discord-info';
3030import { fetchRedditInfo } from '@utils/fetch-reddit-info';
3131import { site } from '@utils/config';
32import { apiBase, serviceSlug } from '@utils/api-config';
3233import Button from '@components/form/Button.astro';
3334
3435interface Props extends Service {
@@ -233,7 +234,7 @@ const catSlug = slugify(categoryName);
233234const secSlug = slugify(parentSection.name);
234235
235236const getApiEndpoint = () => {
236 return `https://api.awesome-privacy.xyz/${catSlug}/${secSlug}/${slugify(name)}`;
237 return `${apiBase}/v1/services/${serviceSlug(name)}`;
237238};
238239
239240const makeSoftwareSchema = () => {
@@ -387,7 +388,7 @@ const makeSoftwareSchema = () => {
387388 <pre><a href={getApiEndpoint()}><code>{getApiEndpoint()}</code></a></pre>
388389 <p>
389390 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
391392 > or read the <a href="/about#api">API Usage Guide</a>.
392393 </p>
393394 </section>
web/src/utils/api-config.ts +9
@@ -5,6 +5,15 @@ export const apiBase =
55 strip(import.meta.env.PUBLIC_API_URL || '').replace(/\/+$/, '') ||
66 'https://api.awesome-privacy.xyz';
77
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
817// Bearer header for enrichment routes; omitted when no token is set.
918export const enrichHeaders = (): Record<string, string> => {
1019 const token = strip(import.meta.env.API_TOKEN || '');