@zauru-sdk/services 2.0.143 → 2.0.145
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.
|
@@ -10,29 +10,16 @@ const headers = {
|
|
|
10
10
|
const expiresToSeconds = (expires) => {
|
|
11
11
|
return Math.floor((expires.getTime() - new Date().getTime()) / 1000);
|
|
12
12
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
}
|
|
13
|
+
//Le quité la expiración porque era muy corta para recepciones,
|
|
14
|
+
//antes se definía algo así: await fetch(`${redisBaseURL}/set/${id}?EX=${expiresToSeconds(expires)}`
|
|
15
|
+
//Estaba en el createData y en el updateData
|
|
29
16
|
// For more info check https://remix.run/docs/en/v1/api/remix#createsessionstorage
|
|
30
17
|
export function createUpstashSessionStorage({ cookie }) {
|
|
31
18
|
return createSessionStorage({
|
|
32
19
|
cookie,
|
|
33
20
|
async createData(data, expires) {
|
|
34
21
|
const id = crypto.randomUUID();
|
|
35
|
-
await
|
|
22
|
+
await fetch(`${redisBaseURL}/set/${id}?EX=${expires ? expiresToSeconds(expires) : 60 * 60 * 8}`, {
|
|
36
23
|
method: "post",
|
|
37
24
|
body: JSON.stringify({ data }),
|
|
38
25
|
headers,
|
|
@@ -45,22 +32,21 @@ export function createUpstashSessionStorage({ cookie }) {
|
|
|
45
32
|
});
|
|
46
33
|
try {
|
|
47
34
|
const { result } = (await response.json());
|
|
48
|
-
return JSON.parse(result)
|
|
35
|
+
return JSON.parse(result).data;
|
|
49
36
|
}
|
|
50
37
|
catch (error) {
|
|
51
|
-
|
|
52
|
-
return {};
|
|
38
|
+
return null;
|
|
53
39
|
}
|
|
54
40
|
},
|
|
55
41
|
async updateData(id, data, expires) {
|
|
56
|
-
await
|
|
42
|
+
await fetch(`${redisBaseURL}/set/${id}?EX=${expires ? expiresToSeconds(expires) : 60 * 60 * 8}`, {
|
|
57
43
|
method: "post",
|
|
58
44
|
body: JSON.stringify({ data }),
|
|
59
45
|
headers,
|
|
60
46
|
});
|
|
61
47
|
},
|
|
62
48
|
async deleteData(id) {
|
|
63
|
-
await
|
|
49
|
+
await fetch(`${redisBaseURL}/del/${id}`, {
|
|
64
50
|
method: "post",
|
|
65
51
|
headers,
|
|
66
52
|
});
|
|
@@ -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.
|
|
3
|
+
"version": "2.0.145",
|
|
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": "
|
|
34
|
+
"gitHead": "22df05a1b83fc385c1abedef0c0543f4e37cfea9"
|
|
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;
|