mirror your GitHub repos to tangled.org automatically
1

Configure Feed

Select the types of activity you want to include in your feed.

fix: move cron job to get request

+17 -17
+4 -3
.env.example
··· 75 75 76 76 # --------------------------------------------------------------------------- 77 77 # Cron secret — protects the worker tick endpoint (`/api/jobs/run`) from 78 - # unauthenticated callers. In prod, Vercel Cron sends this automatically; 79 - # locally, `pnpm jobs:tick` reads it from this env var. 78 + # unauthenticated callers. Vercel auto-injects this as the `Authorization: 79 + # Bearer` header on cron invocations, so the name must be exactly CRON_SECRET 80 + # (not NUXT_-prefixed). Locally, `pnpm jobs:tick` reads the same var. 80 81 # Generate with: pnpm gen:cron-secret 81 82 # --------------------------------------------------------------------------- 82 - NUXT_CRON_SECRET=<base64url-encoded 32 bytes> 83 + CRON_SECRET=<base64url-encoded 32 bytes> 83 84 84 85 # Optional: per-invocation worker time budget in milliseconds. 85 86 # Default 25_000. Set lower in dev so `pnpm jobs:tick` returns sooner when
+1
.gitignore
··· 5 5 .nitro 6 6 .cache 7 7 dist 8 + .vercel 8 9 9 10 # Node dependencies 10 11 node_modules
+2 -2
README.md
··· 38 38 ```bash 39 39 pnpm gen:jwk # NUXT_ATPROTO_PRIVATE_JWK 40 40 pnpm gen:encryption-key # NUXT_ENCRYPTION_KEY and NUXT_SESSION_PASSWORD 41 - pnpm gen:cron-secret # NUXT_CRON_SECRET 41 + pnpm gen:cron-secret # CRON_SECRET 42 42 ``` 43 43 44 44 The rest (`NUXT_DATABASE_URL`, the `NUXT_GITHUB_APP_*` values) come from your ··· 72 72 Mark the secrets (`NUXT_DATABASE_URL`, `NUXT_GITHUB_APP_PRIVATE_KEY`, 73 73 `NUXT_GITHUB_APP_CLIENT_SECRET`, `NUXT_ATPROTO_PRIVATE_JWK`, 74 74 `NUXT_ENCRYPTION_KEY`, `NUXT_SESSION_PASSWORD`, 75 - `NUXT_GITHUB_WEBHOOK_SECRET`, `NUXT_CRON_SECRET`) as **Sensitive**. 75 + `NUXT_GITHUB_WEBHOOK_SECRET`, `CRON_SECRET`) as **Sensitive**. 76 76 3. Set `NUXT_PUBLIC_URL` to your real origin, point the GitHub App webhook at 77 77 `https://<your-domain>/api/github/webhook`, and set the App's Setup + 78 78 Callback URLs to `https://<your-domain>/connect` and
-1
nuxt.config.ts
··· 26 26 githubAppClientId: '', 27 27 githubAppClientSecret: '', 28 28 githubWebhookSecret: '', 29 - cronSecret: '', 30 29 workerBudgetMs: '', 31 30 maxPackBytes: '', 32 31 encryptionKey: '',
+8 -8
scripts/jobs-tick.ts
··· 1 1 /** 2 2 * Trigger the worker tick endpoint locally. 3 3 * 4 - * Reads `NUXT_CRON_SECRET` from `.env` (loaded by Node's --env-file when run 5 - * via `pnpm jobs:tick`) and POSTs to /api/jobs/run with the matching 6 - * `Authorization: Bearer …` header. 4 + * Reads `CRON_SECRET` from `.env` (loaded by Node's --env-file when run via 5 + * `pnpm jobs:tick`) and GETs /api/jobs/run with the matching 6 + * `Authorization: Bearer …` header — the same shape Vercel Cron sends. 7 7 * 8 - * In production, Vercel Cron does this automatically every minute; this 9 - * script is the local equivalent. 8 + * In production, Vercel Cron does this automatically; this script is the 9 + * local equivalent. 10 10 */ 11 11 12 12 import process from 'node:process' 13 13 14 14 const url = process.env.JOBS_TICK_URL ?? 'http://127.0.0.1:3000/api/jobs/run' 15 - const secret = process.env.NUXT_CRON_SECRET 15 + const secret = process.env.CRON_SECRET 16 16 17 17 if (!secret) { 18 - console.error('NUXT_CRON_SECRET not set; copy from .env or run `pnpm gen:cron-secret`') 18 + console.error('CRON_SECRET not set; copy from .env or run `pnpm gen:cron-secret`') 19 19 process.exit(1) 20 20 } 21 21 22 22 const response = await fetch(url, { 23 - method: 'POST', 23 + method: 'GET', 24 24 headers: { authorization: `Bearer ${secret}` }, 25 25 }) 26 26
+2 -3
server/api/jobs/run.post.ts server/api/jobs/run.get.ts
··· 6 6 const DEFAULT_BUDGET_MS = 25_000 // leave headroom under Vercel's 10s default; pro tiers can override 7 7 8 8 export default defineEventHandler(async event => { 9 - const config = useRuntimeConfig() 10 - const cronSecret = config.cronSecret 9 + const cronSecret = process.env.CRON_SECRET 11 10 if (!cronSecret) { 12 11 throw createError({ statusCode: 500, statusMessage: 'cron secret not configured' }) 13 12 } ··· 18 17 } 19 18 20 19 const workerId = `${process.env.VERCEL_DEPLOYMENT_ID ?? 'local'}:${crypto.randomUUID()}` 21 - const budgetMs = Number(config.workerBudgetMs) || DEFAULT_BUDGET_MS 20 + const budgetMs = Number(useRuntimeConfig().workerBudgetMs) || DEFAULT_BUDGET_MS 22 21 const deadline = Date.now() + budgetMs 23 22 24 23 let processed = 0