itube-specs 0.0.488 → 0.0.490

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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "itube-specs",
3
3
  "type": "module",
4
- "version": "0.0.488",
4
+ "version": "0.0.490",
5
5
  "main": "./nuxt.config.ts",
6
6
  "types": "./types/index.d.ts",
7
7
  "scripts": {
package/runtime/index.ts CHANGED
@@ -42,7 +42,7 @@ export * from './utils/converters/group-objects-by-first-letter';
42
42
  export * from './utils/converters/convert-snake-keys-to-camel';
43
43
  export * from './utils/converters/convert-query-categories';
44
44
  export * from './utils/converters/convert-string-array-to-chips';
45
- export * from '../utils/api-helper';
45
+ export * from './utils/server/api-helper';
46
46
  export * from './utils/server/parse-api-error';
47
47
  export * from './utils/server/get-url-with-proxied-params';
48
48
  export * from './utils/server/server-api-helper';
@@ -0,0 +1,26 @@
1
+ import type { NitroFetchOptions } from "nitropack/types";
2
+
3
+ /** Хелпер для работы с API */
4
+ export class ApiHelper {
5
+ /** Метод для получения данных */
6
+ static async fetch<T>(
7
+ path: string,
8
+ fetchOptions: NitroFetchOptions<string>,
9
+ runtimeConfig: { public: { xDomain: string } },
10
+ ): Promise<T> {
11
+ const headers: Record<string, string> = {
12
+ ...(fetchOptions.headers as Record<string, string> || {}),
13
+ 'x-domain': runtimeConfig.public.xDomain,
14
+ };
15
+
16
+ const res = await $fetch(`/bff${path}`, {
17
+ retry: 0,
18
+ method: fetchOptions.method,
19
+ body: fetchOptions.body,
20
+ query: fetchOptions.query,
21
+ headers,
22
+ } as any);
23
+
24
+ return res as T;
25
+ }
26
+ }