@zauru-sdk/services 2.0.143 → 2.0.144

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.
@@ -7,32 +7,16 @@ const headers = {
7
7
  Accept: "application/json",
8
8
  "Content-Type": "application/json",
9
9
  };
10
- const expiresToSeconds = (expires) => {
11
- return Math.floor((expires.getTime() - new Date().getTime()) / 1000);
12
- };
13
- export async function fetchWithRetries(url, config = {}, retries = 3, backoff = 200) {
14
- try {
15
- return await fetch(url, config);
16
- }
17
- catch (error) {
18
- if (retries > 0) {
19
- console.warn(`=> Node Fetch request falló (${url}), reintentando en ${backoff}ms... (${retries} intentos restantes)`, `Error message: ${error instanceof Error ? error.message : String(error)}`);
20
- await new Promise((resolve) => setTimeout(resolve, backoff));
21
- return fetchWithRetries(url, config, retries - 1, backoff * 2);
22
- }
23
- else {
24
- console.error(`=> Node Fetch request falló (${url}), no se pudo recuperar.`, `Error message: ${error instanceof Error ? error.message : String(error)}`);
25
- return null;
26
- }
27
- }
28
- }
10
+ //Le quité la expiración porque era muy corta para recepciones,
11
+ //antes se definía algo así: await fetch(`${redisBaseURL}/set/${id}?EX=${expiresToSeconds(expires)}`
12
+ //Estaba en el createData y en el updateData
29
13
  // For more info check https://remix.run/docs/en/v1/api/remix#createsessionstorage
30
14
  export function createUpstashSessionStorage({ cookie }) {
31
15
  return createSessionStorage({
32
16
  cookie,
33
17
  async createData(data, expires) {
34
18
  const id = crypto.randomUUID();
35
- await fetchWithRetries(`${redisBaseURL}/set/${id}?EX=${expires ? expiresToSeconds(expires) : 60 * 60 * 8}`, {
19
+ await fetch(`${redisBaseURL}/set/${id}?EX=${259200}`, {
36
20
  method: "post",
37
21
  body: JSON.stringify({ data }),
38
22
  headers,
@@ -45,22 +29,21 @@ export function createUpstashSessionStorage({ cookie }) {
45
29
  });
46
30
  try {
47
31
  const { result } = (await response.json());
48
- return JSON.parse(result)?.data;
32
+ return JSON.parse(result).data;
49
33
  }
50
34
  catch (error) {
51
- console.error("Error al leer la sesión: ", error);
52
- return {};
35
+ return null;
53
36
  }
54
37
  },
55
38
  async updateData(id, data, expires) {
56
- await fetchWithRetries(`${redisBaseURL}/set/${id}?EX=${expires ? expiresToSeconds(expires) : 60 * 60 * 8}`, {
39
+ await fetch(`${redisBaseURL}/set/${id}?EX=${259200}`, {
57
40
  method: "post",
58
41
  body: JSON.stringify({ data }),
59
42
  headers,
60
43
  });
61
44
  },
62
45
  async deleteData(id) {
63
- await fetchWithRetries(`${redisBaseURL}/del/${id}`, {
46
+ await fetch(`${redisBaseURL}/del/${id}`, {
64
47
  method: "post",
65
48
  headers,
66
49
  });
@@ -1,2 +1 @@
1
- export declare function fetchWithRetries(url: string, config?: {}, retries?: number, backoff?: number): Promise<Response | null>;
2
1
  export declare function createUpstashSessionStorage({ cookie }: any): import("@remix-run/node").SessionStorage<import("@remix-run/node").SessionData, import("@remix-run/node").SessionData>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zauru-sdk/services",
3
- "version": "2.0.143",
3
+ "version": "2.0.144",
4
4
  "description": "Servicios de consulta a Zauru",
5
5
  "main": "./dist/esm/index.js",
6
6
  "module": "./dist/esm/index.js",
@@ -29,8 +29,7 @@
29
29
  "@zauru-sdk/graphql": "^2.0.119",
30
30
  "@zauru-sdk/types": "^2.0.109",
31
31
  "axios": "^1.6.7",
32
- "chalk": "5.3.0",
33
- "node-fetch": "^3.3.2"
32
+ "chalk": "5.3.0"
34
33
  },
35
- "gitHead": "de97bb773cbc14801c39cec4640a860261a9c5e0"
34
+ "gitHead": "7a901bdb17b9954a233c4e1f1bef2230eec5dfe4"
36
35
  }
@@ -1,10 +0,0 @@
1
- import axios from "axios";
2
- import http from "node:http";
3
- import https from "node:https";
4
- const httpAgent = new http.Agent({ keepAlive: true });
5
- const httpsAgent = new https.Agent({ keepAlive: true });
6
- export const httpUpstash = axios.create({
7
- httpAgent,
8
- httpsAgent,
9
- timeout: 5000,
10
- });
@@ -1 +0,0 @@
1
- export declare const httpUpstash: import("axios").AxiosInstance;