feat: переработать кастомизацию HttpClient
- добавлен плоский ApiConfig с lifecycle hooks - добавлены ApiError, retry context, timeout и кастомные parser/serializer - обновлены примеры, документация и тесты под новый API
This commit is contained in:
19
AGENTS.md
19
AGENTS.md
@@ -100,8 +100,23 @@ import { createApiClient, HttpClient } from './generated';
|
||||
import { getProfile } from './generated/operations/get-profile';
|
||||
import { login } from './generated/operations/login';
|
||||
|
||||
const httpClient = new HttpClient();
|
||||
httpClient.setSecurityData({ token: 'jwt-token' });
|
||||
const token = 'jwt-token';
|
||||
|
||||
const httpClient = new HttpClient({
|
||||
onRequest: (params) => {
|
||||
if (!params.secure) {
|
||||
return params;
|
||||
}
|
||||
|
||||
return {
|
||||
...params,
|
||||
headers: {
|
||||
...params.headers,
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
const api = createApiClient(httpClient, {
|
||||
auth: {
|
||||
|
||||
Reference in New Issue
Block a user