mirrorer

:)
git clone https://git.sr.ht/~ashymad/mirrorer
Log | Files | Refs | LICENSE

commit 999d1dbb83ee94dc616fde8da13c14723dc8b0bd
parent b73a8b2b8e64945276b894c89cdb179903e8350b
Author: Szymon Mikulicz <szymon.mikulicz@posteo.net>
Date:   Sat, 13 Jun 2026 23:18:25 +0200

Test out srht api

Diffstat:
Mworker/.gitignore | 1+
Mworker/src/index.ts | 35++++++++++++++++-------------------
2 files changed, 17 insertions(+), 19 deletions(-)

diff --git a/worker/.gitignore b/worker/.gitignore @@ -165,3 +165,4 @@ dist .env* !.env.example .wrangler/ +token diff --git a/worker/src/index.ts b/worker/src/index.ts @@ -16,25 +16,22 @@ */ export default { - async fetch(req) { - const url = new URL(req.url); - url.pathname = '/__scheduled'; - url.searchParams.append('cron', '0 0 * * *'); - return new Response(`To test the scheduled handler, ensure you have used the "--test-scheduled" then try running "curl ${url.href}".`); - }, + async fetch(req) { + return new Response(`I am just a humble cloudflare worker :)`); + }, - // The scheduled handler is invoked at the interval set in our wrangler.jsonc's - // [[triggers]] configuration. - async scheduled(event, env, ctx): Promise<void> { - // A Cron Trigger can make requests to other endpoints on the Internet, - // publish to a Queue, query a D1 Database, and much more. - // - // We'll keep it simple and make an API call to a Cloudflare API: - let resp = await fetch('https://api.cloudflare.com/client/v4/ips'); - let wasSuccessful = resp.ok ? 'success' : 'fail'; + async scheduled(event, env, ctx): Promise<void> { + let resp = await fetch('https://builds.sr.ht/query', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'Authorization': `Bearer ${env.SRHTTOKEN}` + }, + body: JSON.stringify({ + 'query': '{ version { major, minor, patch } }' + }) + }); - // You could store this result in KV, write to a D1 Database, or publish to a Queue. - // In this template, we'll just log the result: - console.log(`trigger fired at ${event.cron}: ${wasSuccessful}`); - }, + console.log(`trigger fired at ${event.cron}: ${resp.text()}`); + }, } satisfies ExportedHandler<Env>;