@zauru-sdk/services 2.0.124 → 2.0.125
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.
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { createCookie } from "@remix-run/node";
|
|
2
|
-
import { createUpstashSessionStorage } from "./upstash.js";
|
|
3
|
-
export const MAX_AGE_SESSION_COOKIE = 60 * 60 * 5; //5 hours
|
|
2
|
+
import { createUpstashSessionStorage, MAX_AGE_SESSION_COOKIE, } from "./upstash.js";
|
|
4
3
|
const sessionCookie = createCookie("_rj_session", {
|
|
5
4
|
secrets: ["r3m1xr0ck1"],
|
|
6
5
|
path: "/",
|
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import { createSessionStorage } from "@remix-run/node";
|
|
2
2
|
import crypto from "crypto";
|
|
3
3
|
import { config } from "@zauru-sdk/config";
|
|
4
|
+
export const MAX_AGE_SESSION_COOKIE = 60 * 60 * 5; //5 hours
|
|
4
5
|
const redisBaseURL = config.redisBaseURL;
|
|
5
6
|
const headers = {
|
|
6
7
|
Authorization: `Bearer ${config.redisToken}`,
|
|
7
8
|
Accept: "application/json",
|
|
8
9
|
"Content-Type": "application/json",
|
|
9
10
|
};
|
|
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
|
|
13
|
-
//Ahora lo manejo en el maxAge de la cookie <- lo actualizo en cada request
|
|
14
11
|
// For more info check https://remix.run/docs/en/v1/api/remix#createsessionstorage
|
|
15
12
|
export function createUpstashSessionStorage({ cookie }) {
|
|
16
13
|
return createSessionStorage({
|
|
@@ -18,7 +15,7 @@ export function createUpstashSessionStorage({ cookie }) {
|
|
|
18
15
|
async createData(data, expires) {
|
|
19
16
|
try {
|
|
20
17
|
const id = crypto.randomUUID();
|
|
21
|
-
await fetch(`${redisBaseURL}/set/${id}`, {
|
|
18
|
+
await fetch(`${redisBaseURL}/set/${id}?EX=${MAX_AGE_SESSION_COOKIE}`, {
|
|
22
19
|
method: "post",
|
|
23
20
|
body: JSON.stringify({ data }),
|
|
24
21
|
headers,
|
|
@@ -45,7 +42,7 @@ export function createUpstashSessionStorage({ cookie }) {
|
|
|
45
42
|
},
|
|
46
43
|
async updateData(id, data, expires) {
|
|
47
44
|
try {
|
|
48
|
-
await fetch(`${redisBaseURL}/set/${id}`, {
|
|
45
|
+
await fetch(`${redisBaseURL}/set/${id}?EX=${MAX_AGE_SESSION_COOKIE}`, {
|
|
49
46
|
method: "post",
|
|
50
47
|
body: JSON.stringify({ data }),
|
|
51
48
|
headers,
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
export declare const MAX_AGE_SESSION_COOKIE: number;
|
|
2
1
|
declare const getSession: (cookieHeader?: string | null, options?: import("cookie").CookieParseOptions) => Promise<import("@remix-run/node").Session<import("@remix-run/node").SessionData, import("@remix-run/node").SessionData>>, commitSession: (session: import("@remix-run/node").Session<import("@remix-run/node").SessionData, import("@remix-run/node").SessionData>, options?: import("cookie").CookieSerializeOptions) => Promise<string>, destroySession: (session: import("@remix-run/node").Session<import("@remix-run/node").SessionData, import("@remix-run/node").SessionData>, options?: import("cookie").CookieSerializeOptions) => Promise<string>;
|
|
3
2
|
export { getSession, commitSession, destroySession };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zauru-sdk/services",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.125",
|
|
4
4
|
"description": "Servicios de consulta a Zauru",
|
|
5
5
|
"main": "./dist/esm/index.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -31,5 +31,5 @@
|
|
|
31
31
|
"axios": "^1.6.7",
|
|
32
32
|
"chalk": "5.3.0"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "f5d03d5f8a5808ca303e5d7862ec9d3a11260a81"
|
|
35
35
|
}
|