@lark-apaas/miaoda-core 0.0.1-alpha.6 → 0.0.1-alpha.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,182 @@
1
+ /**
2
+ * HTTP 请求方法类型
3
+ */
4
+ export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
5
+ /**
6
+ * 请求配置接口
7
+ */
8
+ export interface RequestConfig {
9
+ /** 请求 URL */
10
+ url: string;
11
+ /** 请求方法 */
12
+ method?: HttpMethod;
13
+ /** 请求头 */
14
+ headers?: Record<string, string>;
15
+ /** 请求参数(用于 GET 请求的查询参数) */
16
+ params?: Record<string, any>;
17
+ /** 请求体数据 */
18
+ data?: any;
19
+ /** 超时时间(毫秒) */
20
+ timeout?: number;
21
+ /** 响应类型 */
22
+ responseType?: 'json' | 'text' | 'blob' | 'arrayBuffer' | 'formData';
23
+ /** 是否携带凭证 */
24
+ credentials?: RequestCredentials;
25
+ /** AbortSignal 用于取消请求 */
26
+ signal?: AbortSignal;
27
+ }
28
+ /**
29
+ * 响应数据接口
30
+ */
31
+ export interface ApiResponse<T = any> {
32
+ /** 响应数据 */
33
+ data: T;
34
+ /** HTTP 状态码 */
35
+ status: number;
36
+ /** 状态文本 */
37
+ statusText: string;
38
+ }
39
+ /**
40
+ * API 错误类
41
+ */
42
+ export declare class ApiError extends Error {
43
+ status?: number;
44
+ statusText?: string;
45
+ response?: Response;
46
+ config?: RequestConfig;
47
+ code?: string;
48
+ constructor(message: string, config?: RequestConfig, response?: Response, code?: string);
49
+ }
50
+ /**
51
+ * 请求拦截器类型
52
+ */
53
+ export type RequestInterceptor = (config: RequestConfig) => RequestConfig | Promise<RequestConfig>;
54
+ /**
55
+ * 响应拦截器类型
56
+ */
57
+ export type ResponseInterceptor = <T = any>(response: ApiResponse<T>) => ApiResponse<T> | Promise<ApiResponse<T>>;
58
+ /**
59
+ * 错误拦截器类型
60
+ */
61
+ export type ErrorInterceptor = (error: ApiError) => any;
62
+ /**
63
+ * 通用接口测试 API 代理类
64
+ *
65
+ * 特性:
66
+ * - 支持所有 RESTful 请求方法 (GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS)
67
+ * - 完善的错误处理和边界检查
68
+ * - 请求/响应拦截器
69
+ * - 超时控制和请求取消
70
+ * - 支持多种响应类型
71
+ */
72
+ declare class ApiProxy {
73
+ /** 默认配置 */
74
+ private defaultConfig;
75
+ /** 请求拦截器队列 */
76
+ private requestInterceptors;
77
+ /** 响应拦截器队列 */
78
+ private responseInterceptors;
79
+ /** 错误拦截器队列 */
80
+ private errorInterceptors;
81
+ /** 活跃的请求控制器 Map */
82
+ private activeRequests;
83
+ /**
84
+ * 构造函数
85
+ * @param baseConfig 基础配置
86
+ */
87
+ constructor(baseConfig?: Partial<RequestConfig>);
88
+ /**
89
+ * 添加请求拦截器
90
+ */
91
+ useRequestInterceptor(interceptor: RequestInterceptor): void;
92
+ /**
93
+ * 添加响应拦截器
94
+ */
95
+ useResponseInterceptor(interceptor: ResponseInterceptor): void;
96
+ /**
97
+ * 添加错误拦截器
98
+ */
99
+ useErrorInterceptor(interceptor: ErrorInterceptor): void;
100
+ /**
101
+ * 验证 URL 格式
102
+ */
103
+ private validateUrl;
104
+ /**
105
+ * 构建完整 URL (包含查询参数)
106
+ */
107
+ private buildUrl;
108
+ /**
109
+ * 序列化请求体
110
+ */
111
+ private serializeData;
112
+ /**
113
+ * 解析响应数据
114
+ */
115
+ private parseResponse;
116
+ /**
117
+ * 执行请求拦截器
118
+ */
119
+ private runRequestInterceptors;
120
+ /**
121
+ * 执行响应拦截器
122
+ */
123
+ private runResponseInterceptors;
124
+ /**
125
+ * 执行错误拦截器
126
+ */
127
+ private runErrorInterceptors;
128
+ /**
129
+ * 生成请求唯一键
130
+ */
131
+ private generateRequestKey;
132
+ /**
133
+ * 核心请求方法
134
+ */
135
+ request<T = any>(config: RequestConfig): Promise<ApiResponse<T>>;
136
+ /**
137
+ * 执行实际请求
138
+ */
139
+ private executeRequest;
140
+ /**
141
+ * GET 请求
142
+ */
143
+ get<T = any>(url: string, config?: Omit<RequestConfig, 'url' | 'method' | 'data'>): Promise<ApiResponse<T>>;
144
+ /**
145
+ * POST 请求
146
+ */
147
+ post<T = any>(url: string, data?: any, config?: Omit<RequestConfig, 'url' | 'method' | 'data'>): Promise<ApiResponse<T>>;
148
+ /**
149
+ * PUT 请求
150
+ */
151
+ put<T = any>(url: string, data?: any, config?: Omit<RequestConfig, 'url' | 'method' | 'data'>): Promise<ApiResponse<T>>;
152
+ /**
153
+ * DELETE 请求
154
+ */
155
+ delete<T = any>(url: string, config?: Omit<RequestConfig, 'url' | 'method' | 'data'>): Promise<ApiResponse<T>>;
156
+ /**
157
+ * PATCH 请求
158
+ */
159
+ patch<T = any>(url: string, data?: any, config?: Omit<RequestConfig, 'url' | 'method' | 'data'>): Promise<ApiResponse<T>>;
160
+ /**
161
+ * HEAD 请求
162
+ */
163
+ head<T = any>(url: string, config?: Omit<RequestConfig, 'url' | 'method' | 'data'>): Promise<ApiResponse<T>>;
164
+ /**
165
+ * OPTIONS 请求
166
+ */
167
+ options<T = any>(url: string, config?: Omit<RequestConfig, 'url' | 'method' | 'data'>): Promise<ApiResponse<T>>;
168
+ /**
169
+ * 取消指定的请求
170
+ */
171
+ cancelRequest(requestKey: string): void;
172
+ /**
173
+ * 取消所有活跃请求
174
+ */
175
+ cancelAllRequests(): void;
176
+ /**
177
+ * 获取活跃请求数量
178
+ */
179
+ getActiveRequestCount(): number;
180
+ }
181
+ declare const apiProxy: ApiProxy;
182
+ export default apiProxy;
@@ -0,0 +1,287 @@
1
+ class ApiError extends Error {
2
+ status;
3
+ statusText;
4
+ response;
5
+ config;
6
+ code;
7
+ constructor(message, config, response, code){
8
+ super(message);
9
+ this.name = 'ApiError';
10
+ this.config = config;
11
+ this.response = response;
12
+ this.status = response?.status;
13
+ this.statusText = response?.statusText;
14
+ this.code = code;
15
+ Object.setPrototypeOf(this, ApiError.prototype);
16
+ }
17
+ }
18
+ class ApiProxy {
19
+ defaultConfig = {
20
+ timeout: 30000,
21
+ responseType: 'json',
22
+ credentials: 'same-origin',
23
+ headers: {
24
+ 'Content-Type': 'application/json',
25
+ 'X-Suda-Csrf-Token': window.csrfToken || ''
26
+ }
27
+ };
28
+ requestInterceptors = [];
29
+ responseInterceptors = [];
30
+ errorInterceptors = [];
31
+ activeRequests = new Map();
32
+ constructor(baseConfig){
33
+ if (baseConfig) this.defaultConfig = {
34
+ ...this.defaultConfig,
35
+ ...baseConfig
36
+ };
37
+ }
38
+ useRequestInterceptor(interceptor) {
39
+ if ('function' != typeof interceptor) throw new TypeError('Request interceptor must be a function');
40
+ this.requestInterceptors.push(interceptor);
41
+ }
42
+ useResponseInterceptor(interceptor) {
43
+ if ('function' != typeof interceptor) throw new TypeError('Response interceptor must be a function');
44
+ this.responseInterceptors.push(interceptor);
45
+ }
46
+ useErrorInterceptor(interceptor) {
47
+ if ('function' != typeof interceptor) throw new TypeError('Error interceptor must be a function');
48
+ this.errorInterceptors.push(interceptor);
49
+ }
50
+ validateUrl(url) {
51
+ if (!url || 'string' != typeof url) return false;
52
+ if (url.startsWith('/') || url.startsWith('./') || url.startsWith('../')) return true;
53
+ try {
54
+ new URL(url);
55
+ return true;
56
+ } catch {
57
+ return false;
58
+ }
59
+ }
60
+ buildUrl(url, params) {
61
+ if (!params || 0 === Object.keys(params).length) return url;
62
+ try {
63
+ const urlObj = new URL(url, window.location.origin);
64
+ Object.entries(params).forEach(([key, value])=>{
65
+ if (null != value) urlObj.searchParams.append(key, String(value));
66
+ });
67
+ return urlObj.toString();
68
+ } catch (error) {
69
+ console.error('Failed to build URL:', error);
70
+ return url;
71
+ }
72
+ }
73
+ serializeData(data, contentType) {
74
+ if (null == data) return null;
75
+ if (data instanceof FormData) return data;
76
+ if (data instanceof Blob || data instanceof File) return data;
77
+ if (data instanceof ArrayBuffer || ArrayBuffer.isView(data)) return data;
78
+ if (data instanceof URLSearchParams) return data;
79
+ const type = contentType?.toLowerCase() || '';
80
+ if (type.includes('application/json')) try {
81
+ return JSON.stringify(data);
82
+ } catch (error) {
83
+ throw new ApiError('Failed to serialize JSON data', void 0, void 0, 'SERIALIZATION_ERROR');
84
+ }
85
+ if (type.includes('application/x-www-form-urlencoded')) {
86
+ if ('object' == typeof data) return new URLSearchParams(data).toString();
87
+ return String(data);
88
+ }
89
+ if ('object' == typeof data) try {
90
+ return JSON.stringify(data);
91
+ } catch (error) {
92
+ throw new ApiError('Failed to serialize data', void 0, void 0, 'SERIALIZATION_ERROR');
93
+ }
94
+ return String(data);
95
+ }
96
+ async parseResponse(response, responseType) {
97
+ try {
98
+ switch(responseType){
99
+ case 'json':
100
+ const text = await response.text();
101
+ return text ? JSON.parse(text) : null;
102
+ case 'text':
103
+ return await response.text();
104
+ case 'blob':
105
+ return await response.blob();
106
+ case 'arrayBuffer':
107
+ return await response.arrayBuffer();
108
+ case 'formData':
109
+ return await response.formData();
110
+ default:
111
+ return await response.text();
112
+ }
113
+ } catch (error) {
114
+ throw new ApiError(`Failed to parse response as ${responseType}`, void 0, response, 'PARSE_ERROR');
115
+ }
116
+ }
117
+ async runRequestInterceptors(config) {
118
+ let modifiedConfig = {
119
+ ...config
120
+ };
121
+ for (const interceptor of this.requestInterceptors)try {
122
+ modifiedConfig = await interceptor(modifiedConfig);
123
+ } catch (error) {
124
+ console.error('Request interceptor error:', error);
125
+ throw new ApiError('Request interceptor failed', modifiedConfig, void 0, 'INTERCEPTOR_ERROR');
126
+ }
127
+ return modifiedConfig;
128
+ }
129
+ async runResponseInterceptors(response) {
130
+ let modifiedResponse = response;
131
+ for (const interceptor of this.responseInterceptors)try {
132
+ modifiedResponse = await interceptor(modifiedResponse);
133
+ } catch (error) {
134
+ console.error('Response interceptor error:', error);
135
+ }
136
+ return modifiedResponse;
137
+ }
138
+ async runErrorInterceptors(error) {
139
+ for (const interceptor of this.errorInterceptors)try {
140
+ const result = await interceptor(error);
141
+ if (void 0 !== result) return result;
142
+ } catch (err) {
143
+ console.error('Error interceptor failed:', err);
144
+ }
145
+ throw error;
146
+ }
147
+ generateRequestKey(config) {
148
+ return `${config.method || 'GET'}_${config.url}_${Date.now()}_${Math.random()}`;
149
+ }
150
+ async request(config) {
151
+ if (!config || 'object' != typeof config) throw new ApiError('Request config is required and must be an object', config, void 0, 'INVALID_CONFIG');
152
+ if (!config.url) throw new ApiError('Request URL is required', config, void 0, 'MISSING_URL');
153
+ if (!this.validateUrl(config.url)) throw new ApiError('Invalid URL format', config, void 0, 'INVALID_URL');
154
+ const mergedConfig = {
155
+ ...this.defaultConfig,
156
+ ...config,
157
+ headers: {
158
+ ...this.defaultConfig.headers,
159
+ ...config.headers
160
+ }
161
+ };
162
+ const finalConfig = await this.runRequestInterceptors(mergedConfig);
163
+ const requestKey = this.generateRequestKey(finalConfig);
164
+ try {
165
+ const response = await this.executeRequest(finalConfig, requestKey);
166
+ return response;
167
+ } catch (error) {
168
+ const apiError = error instanceof ApiError ? error : new ApiError(error instanceof Error ? error.message : 'Unknown error', finalConfig, void 0, 'REQUEST_FAILED');
169
+ return await this.runErrorInterceptors(apiError);
170
+ }
171
+ }
172
+ async executeRequest(config, requestKey) {
173
+ let abortController;
174
+ if (config.signal) {
175
+ abortController = new AbortController();
176
+ config.signal.addEventListener('abort', ()=>abortController.abort());
177
+ } else abortController = new AbortController();
178
+ this.activeRequests.set(requestKey, abortController);
179
+ let timeoutId = null;
180
+ if (config.timeout && config.timeout > 0) timeoutId = setTimeout(()=>{
181
+ abortController.abort();
182
+ }, config.timeout);
183
+ try {
184
+ const fullUrl = this.buildUrl(config.url, config.params);
185
+ const fetchOptions = {
186
+ method: config.method || 'GET',
187
+ headers: config.headers,
188
+ credentials: config.credentials,
189
+ signal: abortController.signal
190
+ };
191
+ const methodsWithoutBody = [
192
+ 'GET',
193
+ 'HEAD'
194
+ ];
195
+ if (config.data && !methodsWithoutBody.includes(config.method || 'GET')) fetchOptions.body = this.serializeData(config.data, config.headers?.['Content-Type']);
196
+ const response = await fetch(fullUrl, fetchOptions);
197
+ if (timeoutId) clearTimeout(timeoutId);
198
+ this.activeRequests.delete(requestKey);
199
+ if (!response.ok) throw new ApiError(`HTTP Error: ${response.status} ${response.statusText}`, config, response, 'HTTP_ERROR');
200
+ const data = await this.parseResponse(response, config.responseType || 'json');
201
+ const apiResponse = {
202
+ data,
203
+ status: response.status,
204
+ statusText: response.statusText
205
+ };
206
+ return await this.runResponseInterceptors(apiResponse);
207
+ } catch (error) {
208
+ if (timeoutId) clearTimeout(timeoutId);
209
+ this.activeRequests.delete(requestKey);
210
+ if (error instanceof Error && 'AbortError' === error.name) throw new ApiError(config.timeout ? 'Request timeout' : 'Request cancelled', config, void 0, 'ABORT_ERROR');
211
+ if (error instanceof TypeError) throw new ApiError('Network error or CORS issue', config, void 0, 'NETWORK_ERROR');
212
+ if (error instanceof ApiError) throw error;
213
+ throw new ApiError(error instanceof Error ? error.message : 'Unknown error', config, void 0, 'UNKNOWN_ERROR');
214
+ }
215
+ }
216
+ async get(url, config) {
217
+ return this.request({
218
+ ...config,
219
+ url,
220
+ method: 'GET'
221
+ });
222
+ }
223
+ async post(url, data, config) {
224
+ return this.request({
225
+ ...config,
226
+ url,
227
+ method: 'POST',
228
+ data
229
+ });
230
+ }
231
+ async put(url, data, config) {
232
+ return this.request({
233
+ ...config,
234
+ url,
235
+ method: 'PUT',
236
+ data
237
+ });
238
+ }
239
+ async delete(url, config) {
240
+ return this.request({
241
+ ...config,
242
+ url,
243
+ method: 'DELETE'
244
+ });
245
+ }
246
+ async patch(url, data, config) {
247
+ return this.request({
248
+ ...config,
249
+ url,
250
+ method: 'PATCH',
251
+ data
252
+ });
253
+ }
254
+ async head(url, config) {
255
+ return this.request({
256
+ ...config,
257
+ url,
258
+ method: 'HEAD'
259
+ });
260
+ }
261
+ async options(url, config) {
262
+ return this.request({
263
+ ...config,
264
+ url,
265
+ method: 'OPTIONS'
266
+ });
267
+ }
268
+ cancelRequest(requestKey) {
269
+ const controller = this.activeRequests.get(requestKey);
270
+ if (controller) {
271
+ controller.abort();
272
+ this.activeRequests.delete(requestKey);
273
+ }
274
+ }
275
+ cancelAllRequests() {
276
+ this.activeRequests.forEach((controller)=>{
277
+ controller.abort();
278
+ });
279
+ this.activeRequests.clear();
280
+ }
281
+ getActiveRequestCount() {
282
+ return this.activeRequests.size;
283
+ }
284
+ }
285
+ const apiProxy = new ApiProxy();
286
+ const core = apiProxy;
287
+ export { ApiError, core as default };
@@ -0,0 +1,38 @@
1
+ /**
2
+ * api panel
3
+ * 获取open-api.json
4
+ */
5
+ declare function getOpenApiJson(): Promise<{}>;
6
+ /**
7
+ * 获取日志json
8
+ */
9
+ declare function getLogJson(): Promise<{}>;
10
+ /**
11
+ * GET 请求
12
+ */
13
+ declare function api_get(url: any, config: any): Promise<import("../api-proxy/core").ApiResponse<any>>;
14
+ /**
15
+ * POST 请求
16
+ */
17
+ declare function api_post(url: any, data: any, config: any): Promise<import("../api-proxy/core").ApiResponse<any>>;
18
+ /**
19
+ * PUT 请求
20
+ */
21
+ declare function api_put(url: any, data: any, config: any): Promise<import("../api-proxy/core").ApiResponse<any>>;
22
+ /**
23
+ * DELETE 请求
24
+ */
25
+ declare function api_delete(url: any, config: any): Promise<import("../api-proxy/core").ApiResponse<any>>;
26
+ /**
27
+ * PATCH 请求
28
+ */
29
+ declare function api_patch(url: any, data: any, config: any): Promise<import("../api-proxy/core").ApiResponse<any>>;
30
+ /**
31
+ * HEAD 请求
32
+ */
33
+ declare function api_head(url: any, config: any): Promise<import("../api-proxy/core").ApiResponse<any>>;
34
+ /**
35
+ * OPTIONS 请求
36
+ */
37
+ declare function api_options(url: any, config: any): Promise<import("../api-proxy/core").ApiResponse<any>>;
38
+ export { getOpenApiJson, getLogJson, api_get, api_post, api_put, api_delete, api_patch, api_head, api_options, };
@@ -0,0 +1,60 @@
1
+ import { normalizeBasePath } from "../../../utils/utils.js";
2
+ import core from "../api-proxy/core.js";
3
+ async function getOpenApiJson() {
4
+ let apiJson = {};
5
+ try {
6
+ const basePath = normalizeBasePath(process.env.CLIENT_BASE_PATH);
7
+ const res = await fetch(`${basePath}/openapi.json`);
8
+ apiJson = await res.json();
9
+ } catch (error) {
10
+ console.warn('get openapi.json error', error);
11
+ }
12
+ return apiJson;
13
+ }
14
+ async function getLogJson() {
15
+ let logJson = {};
16
+ try {
17
+ const basePath = normalizeBasePath(process.env.CLIENT_BASE_PATH);
18
+ const res = await fetch(`${basePath}/log.json`);
19
+ logJson = await res.json();
20
+ } catch (error) {
21
+ console.warn('get log.json error', error);
22
+ }
23
+ return logJson;
24
+ }
25
+ async function api_get(url, config) {
26
+ const basePath = normalizeBasePath(process.env.CLIENT_BASE_PATH);
27
+ const res = await core.get(`${basePath}${url}`, config);
28
+ return res;
29
+ }
30
+ async function api_post(url, data, config) {
31
+ const basePath = normalizeBasePath(process.env.CLIENT_BASE_PATH);
32
+ const res = await core.post(`${basePath}${url}`, data, config);
33
+ return res;
34
+ }
35
+ async function api_put(url, data, config) {
36
+ const basePath = normalizeBasePath(process.env.CLIENT_BASE_PATH);
37
+ const res = await core.put(`${basePath}${url}`, data, config);
38
+ return res;
39
+ }
40
+ async function api_delete(url, config) {
41
+ const basePath = normalizeBasePath(process.env.CLIENT_BASE_PATH);
42
+ const res = await core["delete"](`${basePath}${url}`, config);
43
+ return res;
44
+ }
45
+ async function api_patch(url, data, config) {
46
+ const basePath = normalizeBasePath(process.env.CLIENT_BASE_PATH);
47
+ const res = await core.patch(`${basePath}${url}`, data, config);
48
+ return res;
49
+ }
50
+ async function api_head(url, config) {
51
+ const basePath = normalizeBasePath(process.env.CLIENT_BASE_PATH);
52
+ const res = await core.head(`${basePath}${url}`, config);
53
+ return res;
54
+ }
55
+ async function api_options(url, config) {
56
+ const basePath = normalizeBasePath(process.env.CLIENT_BASE_PATH);
57
+ const res = await core.options(`${basePath}${url}`, config);
58
+ return res;
59
+ }
60
+ export { api_delete, api_get, api_head, api_options, api_patch, api_post, api_put, getLogJson, getOpenApiJson };
@@ -1,5 +1,5 @@
1
1
  import { normalizeBasePath } from "../../../utils/utils.js";
2
- import { apiTest } from "./api-fetch.js";
2
+ import { api_delete, api_get, api_head, api_options, api_patch, api_post, api_put, getLogJson, getOpenApiJson } from "./api-panel.js";
3
3
  async function getRoutes() {
4
4
  let routes = [
5
5
  {
@@ -17,6 +17,16 @@ async function getRoutes() {
17
17
  }
18
18
  const childApi = {
19
19
  getRoutes,
20
- apiTest: apiTest
20
+ apiProxy: {
21
+ api_get: api_get,
22
+ api_post: api_post,
23
+ api_put: api_put,
24
+ api_delete: api_delete,
25
+ api_patch: api_patch,
26
+ api_head: api_head,
27
+ api_options: api_options,
28
+ getOpenApiJson: getOpenApiJson,
29
+ getLogJson: getLogJson
30
+ }
21
31
  };
22
32
  export { childApi };
@@ -47,5 +47,15 @@ export interface ParentApi {
47
47
  }
48
48
  export interface ChildApi {
49
49
  getRoutes: () => Promise<any[]>;
50
- apiTest: (fullUrl: string, fetchOptions: RequestInit) => Promise<any>;
50
+ apiProxy: {
51
+ api_get: (url: string, config?: any) => Promise<any>;
52
+ api_post: (url: string, data?: any, config?: any) => Promise<any>;
53
+ api_put: (url: string, data?: any, config?: any) => Promise<any>;
54
+ api_delete: (url: string, config?: any) => Promise<any>;
55
+ api_patch: (url: string, data?: any, config?: any) => Promise<any>;
56
+ api_head: (url: string, config?: any) => Promise<any>;
57
+ api_options: (url: string, config?: any) => Promise<any>;
58
+ getOpenApiJson: () => Promise<any>;
59
+ getLogJson: () => Promise<any>;
60
+ };
51
61
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/miaoda-core",
3
- "version": "0.0.1-alpha.6",
3
+ "version": "0.0.1-alpha.7",
4
4
  "types": "./lib/index.d.ts",
5
5
  "main": "./lib/index.js",
6
6
  "files": [
@@ -1 +0,0 @@
1
- export declare function apiTest(fullUrl: string, fetchOptions: RequestInit): Promise<Response>;
@@ -1,10 +0,0 @@
1
- import { normalizeBasePath } from "../../../utils/utils.js";
2
- async function apiTest(fullUrl, fetchOptions) {
3
- const basePath = normalizeBasePath(process.env.CLIENT_BASE_PATH);
4
- fetchOptions.headers = {
5
- ...fetchOptions.headers,
6
- 'X-Suda-Csrf-Token': window.csrfToken || ''
7
- };
8
- return fetch(`${basePath}${fullUrl}`, fetchOptions);
9
- }
10
- export { apiTest };