mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-13 10:43:43 +03:00
Port of decolua/9router#1437 — adds Deno Deploy v2 as a second cloud
edge-relay backend alongside the existing Vercel relay, and folds both
deploy buttons into a single "Deploy Relay" dropdown so adding more
relay backends does not blow up the toolbar.
Backend:
- New shared RELAY_TYPES set in proxyDispatcher (single source of
truth for "this is an edge relay, not a TCP proxy"). proxyFetch and
src/lib/db/proxies both consult it instead of hard-coding
`type === "vercel"` checks at every callsite.
- proxyConfigToUrl returns the relay URL verbatim for both vercel and
deno types; the dispatch decision (TCP vs relay-headers) is now
uniform across both backends.
- New /api/settings/proxy/deno-deploy route mirrors the Vercel route's
contract: validates with a Zod schema (ddo_-prefixed token, DNS-shaped
org domain, slug-shaped project name), generates a server-side
relayAuth secret (token is NEVER stored), pushes a single-file Deno
worker via /v2/apps + /v2/apps/{id}/deploy, polls until succeeded,
and registers a proxy_registry entry with type="deno". The inlined
SSRF guard inside the worker matches the Vercel one byte-for-byte
(blocks RFC1918, loopback, link-local, IPv6 ULA, and embedded creds).
- All five `record.type === "vercel"` callsites in src/lib/db/proxies
now go through isRelayProxyType() so deno entries get the same
notes-redaction + relayAuth extraction.
UI:
- New DenoRelayModal (token + org domain + app name) mirroring
VercelRelayModal shape.
- ProxyPoolTab toolbar now hosts a single "Deploy Relay" dropdown that
groups Vercel + Deno; the dropdown closes on outside click and the
individual buttons remain feature-flagged by
NEXT_PUBLIC_{VERCEL,DENO}_RELAY_ENABLED.
TDD (tests/unit/proxy-pool-deno-deploy-relay.test.ts):
- RELAY_TYPES contains vercel + deno and excludes http/socks5.
- proxyConfigToUrl returns "https://<host>" verbatim for type:"deno".
- proxyFetch routes a deno context through the relay branch with the
same x-relay-{target,path,auth} envelope as vercel and never falls
through to the TCP dispatcher.
- Missing relayAuth on a deno context fails closed with no dispatch.
- The existing #2743 Vercel-relay test stays green (backward compat).
Co-authored-by: TD <tho.din@inno.ai.vn>
Inspired-by: https://github.com/decolua/9router/pull/1437