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