@akinon/next 1.93.0-snapshot-ZERO-3586-20250827113246 → 1.93.0-snapshot-ZERO-3586-20250827125222
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/CHANGELOG.md +3 -3
- package/api/cache.ts +30 -7
- package/lib/cache.ts +11 -5
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @akinon/next
|
|
2
2
|
|
|
3
|
-
## 1.93.0-snapshot-ZERO-3586-
|
|
3
|
+
## 1.93.0-snapshot-ZERO-3586-20250827125222
|
|
4
4
|
|
|
5
5
|
### Minor Changes
|
|
6
6
|
|
|
@@ -69,9 +69,9 @@
|
|
|
69
69
|
- 4de5303c: ZERO-2504: add cookie filter to api client request
|
|
70
70
|
- dc678c3: ZERO-3523: Enhance redirect tests with dynamic locale handling and settings integration
|
|
71
71
|
- f2c92d5c7: ZERO-2816: Update cookie name
|
|
72
|
-
-
|
|
72
|
+
- a420947d: ZERO-3517: Fix optional chaining for rawData in error logging for category data handlers
|
|
73
73
|
- 7bd3d9928: ZERO-2801: Refactor locale middleware to handle single locale configuration
|
|
74
|
-
-
|
|
74
|
+
- acd2afdf: ZERO-3431: Fix import statement for findBaseDir in next-config test
|
|
75
75
|
- 2d3f1788: ZERO-3417: Enhance FileInput component with additional props for customization
|
|
76
76
|
- fdd255ee: ZERO-3054: Refactor cache handler to use custom Redis handler and implement key hashing
|
|
77
77
|
- b434ac8: ZERO-3545: Update fetchCheckout API URL to include page parameter
|
package/api/cache.ts
CHANGED
|
@@ -21,32 +21,55 @@ async function handleRequest(...args) {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
const formData = await req.formData();
|
|
24
|
-
const body = {} as {
|
|
24
|
+
const body = {} as {
|
|
25
|
+
key: string;
|
|
26
|
+
value?: string;
|
|
27
|
+
expire?: number;
|
|
28
|
+
keyValuePairs?: string;
|
|
29
|
+
compressed?: string;
|
|
30
|
+
};
|
|
25
31
|
|
|
26
32
|
formData.forEach((value, key) => {
|
|
27
33
|
body[key] = value;
|
|
28
34
|
});
|
|
29
35
|
|
|
30
|
-
const { key, value, expire, keyValuePairs } = body;
|
|
31
|
-
let response:
|
|
36
|
+
const { key, value, expire, keyValuePairs, compressed } = body;
|
|
37
|
+
let response: any;
|
|
32
38
|
|
|
33
39
|
try {
|
|
34
40
|
if (req.method === 'POST') {
|
|
35
|
-
|
|
41
|
+
// GET request - check if compressed flag is set
|
|
42
|
+
if (compressed === 'true') {
|
|
43
|
+
response = await Cache.getCompressed(key);
|
|
44
|
+
} else {
|
|
45
|
+
response = await Cache.get(key);
|
|
46
|
+
}
|
|
36
47
|
} else if (req.method === 'PUT') {
|
|
37
48
|
if (keyValuePairs) {
|
|
38
49
|
try {
|
|
39
50
|
const parsedKeyValuePairs = JSON.parse(keyValuePairs);
|
|
40
|
-
if (
|
|
51
|
+
if (
|
|
52
|
+
typeof parsedKeyValuePairs !== 'object' ||
|
|
53
|
+
parsedKeyValuePairs === null ||
|
|
54
|
+
Array.isArray(parsedKeyValuePairs)
|
|
55
|
+
) {
|
|
41
56
|
throw new Error('Invalid keyValuePairs format - must be an object');
|
|
42
57
|
}
|
|
43
58
|
response = await Cache.mset(parsedKeyValuePairs, expire);
|
|
44
59
|
} catch (error) {
|
|
45
60
|
logger.error('Invalid keyValuePairs in mset request', { error });
|
|
46
|
-
return NextResponse.json(
|
|
61
|
+
return NextResponse.json(
|
|
62
|
+
{ error: 'Invalid keyValuePairs format' },
|
|
63
|
+
{ status: 400 }
|
|
64
|
+
);
|
|
47
65
|
}
|
|
48
66
|
} else {
|
|
49
|
-
|
|
67
|
+
// SET request - check if compressed flag is set
|
|
68
|
+
if (compressed === 'true') {
|
|
69
|
+
response = await Cache.setCompressed(key, value, expire);
|
|
70
|
+
} else {
|
|
71
|
+
response = await Cache.set(key, value, expire);
|
|
72
|
+
}
|
|
50
73
|
}
|
|
51
74
|
}
|
|
52
75
|
} catch (error) {
|
package/lib/cache.ts
CHANGED
|
@@ -223,6 +223,9 @@ export class Cache {
|
|
|
223
223
|
const body = new URLSearchParams();
|
|
224
224
|
|
|
225
225
|
body.append('key', formattedKey);
|
|
226
|
+
if (_options.compressed) {
|
|
227
|
+
body.append('compressed', 'true');
|
|
228
|
+
}
|
|
226
229
|
|
|
227
230
|
cachedValue = await Cache.proxyRequest('POST', body);
|
|
228
231
|
logger.debug('Cache proxy request success', { key });
|
|
@@ -253,6 +256,9 @@ export class Cache {
|
|
|
253
256
|
'expire',
|
|
254
257
|
String(_options?.expire ?? Settings.redis.defaultExpirationTime)
|
|
255
258
|
);
|
|
259
|
+
if (_options.compressed) {
|
|
260
|
+
body.append('compressed', 'true');
|
|
261
|
+
}
|
|
256
262
|
await Cache.proxyRequest('PUT', body);
|
|
257
263
|
|
|
258
264
|
logger.debug('Cache proxy request', { key, body: body.toString() });
|
|
@@ -382,10 +388,12 @@ export class Cache {
|
|
|
382
388
|
zstd.compress(new Uint8Array(Buffer.from(serializedValue, 'utf8')), 3)
|
|
383
389
|
);
|
|
384
390
|
|
|
391
|
+
const compressedBase64 = compressed.toString('base64');
|
|
392
|
+
|
|
385
393
|
if (expire) {
|
|
386
|
-
await client.set(key,
|
|
394
|
+
await client.set(key, compressedBase64, { EX: expire });
|
|
387
395
|
} else {
|
|
388
|
-
await client.set(key,
|
|
396
|
+
await client.set(key, compressedBase64);
|
|
389
397
|
}
|
|
390
398
|
|
|
391
399
|
success = true;
|
|
@@ -428,9 +436,7 @@ export class Cache {
|
|
|
428
436
|
const compressed = await client.get(key);
|
|
429
437
|
|
|
430
438
|
if (compressed) {
|
|
431
|
-
const compressedBuffer = Buffer.
|
|
432
|
-
? compressed
|
|
433
|
-
: Buffer.from(compressed, 'binary');
|
|
439
|
+
const compressedBuffer = Buffer.from(compressed, 'base64');
|
|
434
440
|
|
|
435
441
|
await initZstd();
|
|
436
442
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akinon/next",
|
|
3
3
|
"description": "Core package for Project Zero Next",
|
|
4
|
-
"version": "1.93.0-snapshot-ZERO-3586-
|
|
4
|
+
"version": "1.93.0-snapshot-ZERO-3586-20250827125222",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"bin": {
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"set-cookie-parser": "2.6.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@akinon/eslint-plugin-projectzero": "1.93.0-snapshot-ZERO-3586-
|
|
38
|
+
"@akinon/eslint-plugin-projectzero": "1.93.0-snapshot-ZERO-3586-20250827125222",
|
|
39
39
|
"@babel/core": "7.26.10",
|
|
40
40
|
"@babel/preset-env": "7.26.9",
|
|
41
41
|
"@babel/preset-typescript": "7.27.0",
|