feat: переработать кастомизацию HttpClient

- добавлен плоский ApiConfig с lifecycle hooks
- добавлены ApiError, retry context, timeout и кастомные parser/serializer
- обновлены примеры, документация и тесты под новый API
This commit is contained in:
2026-06-30 23:52:06 +03:00
parent fe5d3ae091
commit 6662224a9a
9 changed files with 719 additions and 217 deletions

View File

@@ -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: {