@zauru-sdk/services 2.0.82 → 2.0.83

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,36 @@
1
+ import axios from "axios";
2
+ import chalk from "chalk";
3
+ import { config } from "@zauru-sdk/config";
4
+ const axiosInstance = axios.create({
5
+ baseURL: `${config.cmsAPIBaseURL}`,
6
+ });
7
+ axiosInstance.interceptors.request.use(function (request) {
8
+ // Do something before request is sent
9
+ console.log("---------------- EJECUTANDO REQUEST CMS ----------------");
10
+ //console.time(`${request.baseURL}${request.url}`);
11
+ console.log(chalk.green(`${request.baseURL}${request.url}`));
12
+ request.timeout = 200000;
13
+ return request;
14
+ }, function (error) {
15
+ console.log(chalk.red("---------------- ERROR CON REQUEST CMS ----------------"));
16
+ console.log(`${error}`);
17
+ // Do something with request error
18
+ return Promise.reject(error);
19
+ });
20
+ // Add a response interceptor
21
+ axiosInstance.interceptors.response.use(function (response) {
22
+ // Do something with response data
23
+ //console.timeEnd(`${response.config.baseURL}${response.config.url}`);
24
+ return response;
25
+ }, function (error) {
26
+ console.log(chalk.red("---------------- ERROR CON REQUEST CMS ----------------"));
27
+ console.log(`${error}`);
28
+ // Do something with response error
29
+ const { response } = error;
30
+ const msgError = response
31
+ ? `HTTP ${response.status} ${response.statusText} - URL: ${response?.config?.baseURL}${response?.config?.url} - ${JSON.stringify(response?.data)}`
32
+ : error;
33
+ console.log(chalk.red(`${msgError}`));
34
+ throw new Error(msgError);
35
+ });
36
+ export const httpCMSAPI = axiosInstance;
@@ -0,0 +1 @@
1
+ export declare const httpCMSAPI: import("axios").AxiosInstance;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zauru-sdk/services",
3
- "version": "2.0.82",
3
+ "version": "2.0.83",
4
4
  "description": "Servicios de consulta a Zauru",
5
5
  "main": "./dist/esm/index.js",
6
6
  "module": "./dist/esm/index.js",
@@ -25,11 +25,11 @@
25
25
  "dependencies": {
26
26
  "@remix-run/node": "^2.8.1",
27
27
  "@zauru-sdk/common": "^2.0.78",
28
- "@zauru-sdk/config": "^2.0.73",
28
+ "@zauru-sdk/config": "^2.0.83",
29
29
  "@zauru-sdk/graphql": "^2.0.69",
30
30
  "@zauru-sdk/types": "^2.0.78",
31
31
  "axios": "^1.6.7",
32
32
  "chalk": "5.3.0"
33
33
  },
34
- "gitHead": "a680112df1b3824edcfb628add3ffb8e70746320"
34
+ "gitHead": "0a16ddea843474afc3f9ca44581bb6ac6d5a5ff5"
35
35
  }