testing generic deploy

This commit is contained in:
Devin Zuczek
2026-06-29 21:52:50 -04:00
parent 3affabd280
commit 69b89e2dc4
79 changed files with 399 additions and 307 deletions
+11 -13
View File
@@ -10,9 +10,9 @@ import type { Context } from 'hono'
import type { App, Env } from './context'
/**
* Ported from the C# `CDNController`. The class `[Route("cdn")]` prefix maps to
* this worker's subdomain, so method routes are served bare. File-backed routes
* (`sigs`, `upload`) have no storage binding yet and are stubbed.
* CDN routes. The `cdn` prefix maps to this worker's subdomain, so method routes
* are served bare. File-backed routes (`sigs`, `upload`) have no storage binding
* yet and are stubbed.
*/
/**
@@ -46,9 +46,8 @@ function parseRange(header: string | undefined): R2Range | undefined {
}
/**
* Stream a binary asset from the CDN R2 bucket as application/octet-stream
* (matching the C#'s `Results.File(..., "application/octet-stream")`, which also
* honors Range requests). The C# 404s when the file is missing; so do we.
* Stream a binary asset from the CDN R2 bucket as application/octet-stream,
* honoring Range requests. 404s when the file is missing.
* Supports conditional GET and byte-range requests (206) — large-file
* downloaders fetch in ranges, and a 200 where a 206 is expected corrupts the
* reassembled file (e.g. EAC "Signatures don't match").
@@ -110,19 +109,18 @@ const app = new Hono<App>()
.get('/', (c) => c.json({ service: 'cdn', status: 'ok' }))
// Loading-screen tips. The C# serves JSON/loadingscreentipdata.json; bundled
// here as static JSON.
// Loading-screen tips, bundled here as static JSON.
.get('/config/LoadingScreenTipData', (c) => c.json(loadingScreenTipData))
// Signature blobs by name (C#: Sigs/ directory). Streamed from R2 under the
// `sigs/` key prefix; 404 when missing.
// Signature blobs by name. Streamed from R2 under the `sigs/` key prefix;
// 404 when missing.
.get('/sigs/:sigName', (c) => serveAsset(c, `sigs/${c.req.param('sigName')}`))
// Room build data by name (C#: Data/DataBlobs/). The client fetches this for
// a SubRoom's DataBlob to load the room. Streamed from R2 under `room/`.
// Room build data by name. The client fetches this for a SubRoom's DataBlob to
// load the room. Streamed from R2 under `room/`.
.get('/room/:dataBlob', (c) => serveAsset(c, `room/${c.req.param('dataBlob')}`))
// Image upload. [Authorize] in the C#; returns the saved filename. No storage
// Image upload. Auth-gated; returns the saved filename. No storage
// binding yet, so we accept the file and return a synthesized filename without
// persisting it. TODO: write to an R2 bucket like the `img` worker.
.post('/upload', async (c) => {
+1 -2
View File
@@ -3,8 +3,7 @@ import type { SharedHonoEnv, SharedHonoVariables } from '@repo/hono-helpers/src/
export type Env = SharedHonoEnv & {
// R2 bucket holding CDN binaries: signature blobs under `sigs/<name>` and
// room build data under `room/<name>` (mirrors the C#'s Sigs/ and
// Data/DataBlobs/ directories).
// room build data under `room/<name>`.
CDN_ASSETS: R2Bucket
}
+1 -1
View File
@@ -1,5 +1,5 @@
/**
* Minimal HS256 JWT validation, mirroring the C# `JwtTokenService.ValidateAndGetAccountId`.
* Minimal HS256 JWT validation.
*
* Uses the same placeholder dev secret as the `auth` worker (`apps/auth/src/jwt.ts`).
* Swap both for a shared secret binding before this is used for anything real.
+1 -1
View File
@@ -10,7 +10,7 @@ declare module 'cloudflare:test' {
interface ProvidedEnv extends Env {}
}
const ORIGIN = 'https://cdn.rec.djdevin.net'
const ORIGIN = 'https://example.com'
// Mint a token the way the `auth` worker does, using the same dev secret.
const DEV_SECRET = 'dev-insecure-signing-key-change-me'
+1 -1
View File
@@ -8,7 +8,7 @@
],
"routes": [
{
"pattern": "cdn.rec.djdevin.net",
"pattern": "cdn.rec.example.com",
"custom_domain": true
}
],