diff --git a/.github/workflows/auto-refresh.yml b/.github/workflows/auto-refresh.yml index 46be6ab..0bd48e5 100644 --- a/.github/workflows/auto-refresh.yml +++ b/.github/workflows/auto-refresh.yml @@ -17,4 +17,7 @@ jobs: with: node-version: lts/* - - run: npx tsx ./scripts/refresh.ts + - name: Refresh + env: + JWT_TOKEN: ${{ secrets.JWT_TOKEN }} + run: npx tsx ./scripts/refresh.ts diff --git a/scripts/refresh.ts b/scripts/refresh.ts index 617f28c..58b282c 100644 --- a/scripts/refresh.ts +++ b/scripts/refresh.ts @@ -1,11 +1,10 @@ +import process from "node:process" import { sources } from "../shared/sources" -import { delay } from "../shared/utils" -async function main() { - for (const id of Object.keys(sources)) { - await delay(100) - fetch(`https://newsnow.busiyi.world/api/s/${id}`) - } -} - -main().catch(console.error) +Promise.all(Object.keys(sources).map(id => + fetch(`https://newsnow.busiyi.world/api/s/${id}?latest`, { + headers: { + Authorization: `Bearer ${process.env.JWT_TOKEN}`, + }, + }), +)).catch(console.error)