refactor(core): 统一 HTTP 工厂与认证模块,支持 401 自动重试
- factory.ts 只负责创建 HTTP client 和 401 retry 逻辑 - auth 模块(ekb/easo/piper/sealai)只负责 token/header 获取 - ekb.ts 新增 createEkbClient - sealai.ts 新增 createSealaiClient,内部使用 createAuthClient - easo.ts/piper.ts 改用 createAuthClient,token 交换失败抛 AuthenticationError - server.ts 使用 createEkbClient / createSealaiClient / getEasoClient
This commit is contained in:
1 parent
62afd6906e
commit
c9e0fba265
6 files changed
+151
-62
No files matched your search
@@ -1,4 +1,5 @@
|
||||
import { CorpConfig } from "../config/types";
|
||||
import { CorpConfig } from "../config/types.js";
|
||||
import { createClient } from "../http/factory.js";
|
||||
|
||||
export function getEkbHeaders(corp: CorpConfig): Record<string, string> {
|
||||
return {
|
||||
@@ -7,3 +8,10 @@ export function getEkbHeaders(corp: CorpConfig): Record<string, string> {
|
||||
staffid: corp.credentials.staffId,
|
||||
};
|
||||
}
|
||||
|
||||
export function createEkbClient(corp: CorpConfig) {
|
||||
return createClient({
|
||||
prefixUrl: corp.baseUrl || "https://app.ekuaibao.com",
|
||||
headers: getEkbHeaders(corp),
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user