refactor: pass env explicitly across all remaining request-path modules

- Remove last runtimeEnv import from processMessage.ts
- Add env: Env param to all functions with 'Cannot find name env' errors
- Convert initRedisV2 to lazy initialization (ensureRedisV2 + Proxy)
- Add Bindings: Env to StripeWebhookHonoEnv
- Fix 12+ files across external/, internal/, queue/ modules
- Scanning test passes: 1/1 (runtime-env-imports.test.ts)
This commit is contained in:
2026-06-17 07:08:41 -07:00
parent b5e75901a1
commit a98f11c214
180 changed files with 2334 additions and 1907 deletions

View File

@@ -1,4 +1,3 @@
import { runtimeEnv } from "@/utils/envUtils.js";
import { onAwsEcs } from "@/external/aws/ecs/onAwsEcs.js";
/**
@@ -18,13 +17,19 @@ import { onAwsEcs } from "@/external/aws/ecs/onAwsEcs.js";
* Returns the same input string when no swap applies, so callers can use
* it transparently in place of the raw URL.
*/
export const getReachableDragonflyUrl = (url: string): string => {
if (onAwsEcs()) return url;
export const getReachableDragonflyUrl = ({
url,
env,
}: {
url: string;
env: Env;
}): string => {
if (onAwsEcs(env)) return url;
const privateUrl = runtimeEnv.CACHE_V2_DRAGONFLY_URL?.trim();
const privateUrl = env.CACHE_V2_DRAGONFLY_URL?.trim();
if (!privateUrl || url.trim() !== privateUrl) return url;
const publicUrl = runtimeEnv.CACHE_V2_DRAGONFLY_PUBLIC_URL?.trim();
const publicUrl = env.CACHE_V2_DRAGONFLY_PUBLIC_URL?.trim();
if (!publicUrl) return url;
return publicUrl;