feat(framework): config 生产用 HttpConfigFetcher(全局 fetch)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-28 16:47:15 +08:00
co-authored by Claude Opus 4.8
parent c87d204f28
commit 632cef35e5
@@ -0,0 +1,15 @@
import type { ConfigFetcher, RemoteConfig } from './remote-config.ts';
import { ConfigParseError } from './remote-config.ts';
/** 生产用 ConfigFetcher:全局 fetch 抓取远程配置 txt 并 JSON.parse。 */
export class HttpConfigFetcher implements ConfigFetcher {
async fetch(url: string): Promise<RemoteConfig> {
const resp = await fetch(url, { method: 'GET' });
const text = await resp.text();
try {
return JSON.parse(text) as RemoteConfig;
} catch {
throw new ConfigParseError(`远程配置 JSON 解析失败: ${url}`);
}
}
}