Website and API for rory.cat. A Cloudflare Worker using Hono, Vue and TypeScript, with images in R2 and their ids in D1.
pnpm install
cp .dev.vars.example .dev.vars # set API_KEY
pnpm db:migrate:local
pnpm wrangler d1 execute DB --local --command "INSERT INTO images (url) VALUES ('https://i.rory.cat/Zd46PQ6BV4.jpeg')"
pnpm devBefore pushing: pnpm lint && pnpm typecheck && pnpm test.
pnpm wrangler secret put API_KEY # first time only
pnpm run deploy- Use
pnpm run deploy, notpnpm deploy(that is a built-in pnpm command). wrangler deployneedspnpm buildfirst, otherwise it errors aboutassets.directory.- For dashboard Git builds, set the build command to
pnpm build. - Don't run
pnpm db:migrate:remote. TheroryD1 database already has its table.
All /purr routes allow any origin.
GET /purr: random image,{ "id": 42, "url": "https://i.rory.cat/..." }GET /purr/:id: that image, or 404{ "error": "this rory does not exist" }POST /new: upload from a URL. SendAuthorization: <API_KEY>androry=<image url>as a query param, form field or JSON. Returns{ "success": true, "url": "...", "id": 43 }.
Pages accept ?locale= with en, zh, hi, es, ar, fr, bn, pt, ru, id or ca.