mirror of
https://github.com/ahmadk953/tasko.git
synced 2025-04-03 02:04:13 +00:00
Compare commits
13 commits
15f879ebb0
...
e9b6d28591
Author | SHA1 | Date | |
---|---|---|---|
|
e9b6d28591 | ||
|
e0be79f5fd | ||
|
20055c3961 | ||
|
5ef2a3c67f | ||
|
8900584267 | ||
|
d77a768ce9 | ||
|
1238af3148 | ||
|
7b5713cee0 | ||
|
68bf086e36 | ||
|
ac4a4e5741 | ||
|
d10a572049 | ||
|
54c15cf242 | ||
|
cc1d28d343 |
5 changed files with 105 additions and 114 deletions
|
@ -1,62 +1,52 @@
|
|||
import { CacheHandler } from '@neshca/cache-handler';
|
||||
import createLruHandler from '@neshca/cache-handler/local-lru';
|
||||
import createRedisHandler from '@neshca/cache-handler/redis-stack';
|
||||
import Redis from 'ioredis';
|
||||
import redis from './lib/redis'
|
||||
|
||||
CacheHandler.onCreation(async () => {
|
||||
/** @type {import("@neshca/cache-handler").Handler | null} */
|
||||
let handler;
|
||||
|
||||
let client;
|
||||
|
||||
try {
|
||||
client = new Redis(`${process.env.REDIS_URL}`);
|
||||
|
||||
client.on('error', (error) => {
|
||||
if (typeof process.env.NEXT_PRIVATE_DEBUG_CACHE !== 'undefined') {
|
||||
console.error('Redis client error:', error);
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
console.warn('Failed to create Redis client:', error);
|
||||
export default class CacheHandler {
|
||||
constructor(options) {
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
if (client) {
|
||||
async get(key) {
|
||||
try {
|
||||
console.info('Connecting Redis client...');
|
||||
|
||||
await client.connect();
|
||||
console.info('Redis client connected.');
|
||||
|
||||
handler = createRedisHandler({
|
||||
client,
|
||||
timeoutMs: 1000,
|
||||
});
|
||||
const data = await redis.get(key);
|
||||
return data ? JSON.parse(data) : null;
|
||||
} catch (error) {
|
||||
console.warn('Failed to connect Redis client:', error);
|
||||
|
||||
console.warn('Disconnecting the Redis client...');
|
||||
client
|
||||
.disconnect()
|
||||
.then(() => {
|
||||
console.info('Redis client disconnected.');
|
||||
})
|
||||
.catch(() => {
|
||||
console.warn(
|
||||
'Failed to quit the Redis client after failing to connect.'
|
||||
);
|
||||
});
|
||||
|
||||
handler = createLruHandler();
|
||||
console.warn(
|
||||
'Falling back to LRU handler because Redis client is not available.'
|
||||
);
|
||||
console.error('Cache Get Error:', error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
handlers: [handler],
|
||||
};
|
||||
});
|
||||
async set(key, data, ctx) {
|
||||
try {
|
||||
const cacheData = {
|
||||
value: data,
|
||||
lastModified: Date.now(),
|
||||
tags: ctx.tags,
|
||||
};
|
||||
await redis.set(key, JSON.stringify(cacheData));
|
||||
} catch (error) {
|
||||
console.error('Cache Set Error:', error);
|
||||
}
|
||||
}
|
||||
|
||||
export default CacheHandler;
|
||||
async revalidateTag(tags) {
|
||||
try {
|
||||
tags = [tags].flat();
|
||||
const keys = await redis.keys('*');
|
||||
for (const key of keys) {
|
||||
const value = await redis.get(key);
|
||||
if (value) {
|
||||
const parsed = JSON.parse(value);
|
||||
if (parsed.tags.some((tag) => tags.includes(tag))) {
|
||||
await redis.del(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Cache RevalidateTag Error:', error);
|
||||
}
|
||||
}
|
||||
|
||||
resetRequestCache() {
|
||||
// TODO: Implement request-specific cache reset if needed
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,14 +3,6 @@ import * as Sentry from '@sentry/nextjs';
|
|||
export async function register() {
|
||||
if (process.env.NEXT_RUNTIME === 'nodejs') {
|
||||
await import('./sentry.server.config');
|
||||
|
||||
const { registerInitialCache } = await import(
|
||||
'@neshca/cache-handler/instrumentation'
|
||||
);
|
||||
|
||||
const CacheHandler = (await import('./cache-handler.mjs')).default;
|
||||
|
||||
await registerInitialCache(CacheHandler);
|
||||
}
|
||||
|
||||
if (process.env.NEXT_RUNTIME === 'edge') {
|
||||
|
|
13
lib/redis.ts
Normal file
13
lib/redis.ts
Normal file
|
@ -0,0 +1,13 @@
|
|||
import Redis from 'ioredis';
|
||||
|
||||
let redis: Redis | null = null;
|
||||
|
||||
if (!redis) {
|
||||
redis = new Redis(process.env.REDIS_URL!);
|
||||
|
||||
redis.on('error', (err) => {
|
||||
console.error('Redis Client Error:', err);
|
||||
});
|
||||
}
|
||||
|
||||
export default redis;
|
10
package.json
10
package.json
|
@ -19,14 +19,13 @@
|
|||
"dependencies": {
|
||||
"@arcjet/next": "^1.0.0-beta.1",
|
||||
"@clerk/nextjs": "^6.10.1",
|
||||
"@clerk/themes": "^2.2.10",
|
||||
"@clerk/themes": "^2.2.12",
|
||||
"@hello-pangea/dnd": "^17.0.0",
|
||||
"@liveblocks/client": "^2.16.1",
|
||||
"@liveblocks/node": "^2.16.1",
|
||||
"@liveblocks/react": "^2.16.1",
|
||||
"@mdx-js/loader": "^3.1.0",
|
||||
"@mdx-js/react": "^3.1.0",
|
||||
"@neshca/cache-handler": "^1.9.0",
|
||||
"@next/mdx": "^15.1.6",
|
||||
"@prisma/client": "^6.2.1",
|
||||
"@prisma/extension-accelerate": "^1.2.1",
|
||||
|
@ -38,7 +37,7 @@
|
|||
"@radix-ui/react-popover": "^1.1.3",
|
||||
"@radix-ui/react-separator": "^1.0.3",
|
||||
"@radix-ui/react-slot": "^1.1.0",
|
||||
"@radix-ui/react-tooltip": "^1.1.6",
|
||||
"@radix-ui/react-tooltip": "^1.1.7",
|
||||
"@radix-ui/react-visually-hidden": "^1.1.0",
|
||||
"@sentry/nextjs": "8",
|
||||
"@tanstack/react-query": "^5.64.2",
|
||||
|
@ -82,11 +81,12 @@
|
|||
"@testing-library/react": "^16.2.0",
|
||||
"@types/compression": "^1.7.5",
|
||||
"@types/dompurify": "^3",
|
||||
"@types/ioredis": "^5.0.0",
|
||||
"@types/jest": "^29.5.14",
|
||||
"@types/lodash": "^4.17.14",
|
||||
"@types/mdx": "^2.0.13",
|
||||
"@types/node": "^22.10.7",
|
||||
"@types/react": "^19.0.7",
|
||||
"@types/react": "^19.0.8",
|
||||
"@types/react-dom": "^19.0.3",
|
||||
"@typescript-eslint/eslint-plugin": "^8.21.0",
|
||||
"@typescript-eslint/parser": "^8.21.0",
|
||||
|
@ -102,7 +102,7 @@
|
|||
"jest-junit": "^16.0.0",
|
||||
"postcss": "^8.5.1",
|
||||
"prettier": "^3.4.2",
|
||||
"prettier-plugin-tailwindcss": "^0.6.10",
|
||||
"prettier-plugin-tailwindcss": "^0.6.11",
|
||||
"prisma": "^6.2.1",
|
||||
"tailwindcss": "^3.4.16",
|
||||
"ts-node": "^10.9.2",
|
||||
|
|
92
yarn.lock
92
yarn.lock
|
@ -776,22 +776,13 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@clerk/themes@npm:^2.2.10":
|
||||
version: 2.2.10
|
||||
resolution: "@clerk/themes@npm:2.2.10"
|
||||
"@clerk/themes@npm:^2.2.12":
|
||||
version: 2.2.12
|
||||
resolution: "@clerk/themes@npm:2.2.12"
|
||||
dependencies:
|
||||
"@clerk/types": "npm:^4.42.0"
|
||||
"@clerk/types": "npm:^4.44.0"
|
||||
tslib: "npm:2.4.1"
|
||||
checksum: 10c0/68641c88465d9a7f5c8c409ded5ab9ca450bd40955ccda537e6e118de4ba8b010207eefca0c4dbf7c56659c880be96a6e104903645f9dda55785bce63e90e1e8
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@clerk/types@npm:^4.42.0":
|
||||
version: 4.42.0
|
||||
resolution: "@clerk/types@npm:4.42.0"
|
||||
dependencies:
|
||||
csstype: "npm:3.1.1"
|
||||
checksum: 10c0/156f516c83de8c25dabbae8a0ee741521d1a644aa3df6f5462157e66fa8bdc432d7dfc75416a65c3fb7ad78108aae153ea7ad08276425b2eba058bc917c24120
|
||||
checksum: 10c0/4089ee25763a2a028d17c3d656dd972d75428650b49fcb3b708a377bfef87a6833d10771f59a04ab62345d94d7bba0aba33cd04efbdca0130494c79314cc72e6
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
|
@ -804,6 +795,15 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@clerk/types@npm:^4.44.0":
|
||||
version: 4.44.0
|
||||
resolution: "@clerk/types@npm:4.44.0"
|
||||
dependencies:
|
||||
csstype: "npm:3.1.1"
|
||||
checksum: 10c0/fbd6bd42c6be5bc1f78dde99754ffb4c2d363c9451219ee40a3550e4ab4daddae2f2cca2dd3584db2ea6688d82b8570705527d53b995410c8b444159e8ca1275
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@codecov/bundler-plugin-core@npm:^1.8.0":
|
||||
version: 1.8.0
|
||||
resolution: "@codecov/bundler-plugin-core@npm:1.8.0"
|
||||
|
@ -2012,19 +2012,6 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@neshca/cache-handler@npm:^1.9.0":
|
||||
version: 1.9.0
|
||||
resolution: "@neshca/cache-handler@npm:1.9.0"
|
||||
dependencies:
|
||||
cluster-key-slot: "npm:1.1.2"
|
||||
lru-cache: "npm:10.4.3"
|
||||
peerDependencies:
|
||||
next: ">= 13.5.1 < 15"
|
||||
redis: ">= 4.6"
|
||||
checksum: 10c0/883360e0979181448c8a81886d69e3460d3ea60283ceaaf1941a8bc8255cb1dedf5ba448951cf0cabf9969381a4481777d3c408cd7a5537e7e4d0c13f89544a4
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@next/env@npm:15.1.6":
|
||||
version: 15.1.6
|
||||
resolution: "@next/env@npm:15.1.6"
|
||||
|
@ -3518,14 +3505,14 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@radix-ui/react-tooltip@npm:^1.1.6":
|
||||
version: 1.1.6
|
||||
resolution: "@radix-ui/react-tooltip@npm:1.1.6"
|
||||
"@radix-ui/react-tooltip@npm:^1.1.7":
|
||||
version: 1.1.7
|
||||
resolution: "@radix-ui/react-tooltip@npm:1.1.7"
|
||||
dependencies:
|
||||
"@radix-ui/primitive": "npm:1.1.1"
|
||||
"@radix-ui/react-compose-refs": "npm:1.1.1"
|
||||
"@radix-ui/react-context": "npm:1.1.1"
|
||||
"@radix-ui/react-dismissable-layer": "npm:1.1.3"
|
||||
"@radix-ui/react-dismissable-layer": "npm:1.1.4"
|
||||
"@radix-ui/react-id": "npm:1.1.0"
|
||||
"@radix-ui/react-popper": "npm:1.2.1"
|
||||
"@radix-ui/react-portal": "npm:1.1.3"
|
||||
|
@ -3544,7 +3531,7 @@ __metadata:
|
|||
optional: true
|
||||
"@types/react-dom":
|
||||
optional: true
|
||||
checksum: 10c0/6e2e83b2ef448bcc486e8f73bfd303b18b723f86239f40f5e06cf930f074494f6fefb1a48bcaf24b215ec7bd7f87f6884d1ef9394cddcf50d1b30e26f9e15093
|
||||
checksum: 10c0/25c11cbc8b6aa4115c5fd10aa6fb414e5f4169d83334bd7711fd597dad938122839b801a4b4c13bd0295131db4b0527e18338a203cc6281721342251d01a2d48
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
|
@ -4338,6 +4325,15 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@types/ioredis@npm:^5.0.0":
|
||||
version: 5.0.0
|
||||
resolution: "@types/ioredis@npm:5.0.0"
|
||||
dependencies:
|
||||
ioredis: "npm:*"
|
||||
checksum: 10c0/e52ce4239f0334701fc95fb5aaf1753d75f7582099fdf152743192f49d9ee4a88478b339d015e50cb5e111e38925846cf20668355f4046af7855021d2be181f0
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@types/istanbul-lib-coverage@npm:*, @types/istanbul-lib-coverage@npm:^2.0.0, @types/istanbul-lib-coverage@npm:^2.0.1":
|
||||
version: 2.0.6
|
||||
resolution: "@types/istanbul-lib-coverage@npm:2.0.6"
|
||||
|
@ -4516,12 +4512,12 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@types/react@npm:^19.0.7":
|
||||
version: 19.0.7
|
||||
resolution: "@types/react@npm:19.0.7"
|
||||
"@types/react@npm:^19.0.8":
|
||||
version: 19.0.8
|
||||
resolution: "@types/react@npm:19.0.8"
|
||||
dependencies:
|
||||
csstype: "npm:^3.0.2"
|
||||
checksum: 10c0/818e546fa03a2a65ac2652fc472891ac96684211e8967bc25e1da6a8a09e2301ad972b1b038d128f8b4cbbd7691f6f57fee274db568169e9b6b01556abbb5bee
|
||||
checksum: 10c0/5fa7236356b1476de03519c66ef65d4fd904826956105619e2ad60cb0b55ae7b251dd5fff02234076225b5e15333d0d936bf9dbe1d461406f8a2ba01c197ddcd
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
|
@ -5722,7 +5718,7 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"cluster-key-slot@npm:1.1.2, cluster-key-slot@npm:^1.1.0":
|
||||
"cluster-key-slot@npm:^1.1.0":
|
||||
version: 1.1.2
|
||||
resolution: "cluster-key-slot@npm:1.1.2"
|
||||
checksum: 10c0/d7d39ca28a8786e9e801eeb8c770e3c3236a566625d7299a47bb71113fb2298ce1039596acb82590e598c52dbc9b1f088c8f587803e697cb58e1867a95ff94d3
|
||||
|
@ -8008,7 +8004,7 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"ioredis@npm:^5.4.2":
|
||||
"ioredis@npm:*, ioredis@npm:^5.4.2":
|
||||
version: 5.4.2
|
||||
resolution: "ioredis@npm:5.4.2"
|
||||
dependencies:
|
||||
|
@ -9311,7 +9307,7 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"lru-cache@npm:10.4.3, lru-cache@npm:^10.0.1, lru-cache@npm:^10.2.0":
|
||||
"lru-cache@npm:^10.0.1, lru-cache@npm:^10.2.0":
|
||||
version: 10.4.3
|
||||
resolution: "lru-cache@npm:10.4.3"
|
||||
checksum: 10c0/ebd04fbca961e6c1d6c0af3799adcc966a1babe798f685bb84e6599266599cd95d94630b10262f5424539bc4640107e8a33aa28585374abf561d30d16f4b39fb
|
||||
|
@ -10965,9 +10961,9 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"prettier-plugin-tailwindcss@npm:^0.6.10":
|
||||
version: 0.6.10
|
||||
resolution: "prettier-plugin-tailwindcss@npm:0.6.10"
|
||||
"prettier-plugin-tailwindcss@npm:^0.6.11":
|
||||
version: 0.6.11
|
||||
resolution: "prettier-plugin-tailwindcss@npm:0.6.11"
|
||||
peerDependencies:
|
||||
"@ianvs/prettier-plugin-sort-imports": "*"
|
||||
"@prettier/plugin-pug": "*"
|
||||
|
@ -11019,7 +11015,7 @@ __metadata:
|
|||
optional: true
|
||||
prettier-plugin-svelte:
|
||||
optional: true
|
||||
checksum: 10c0/9e1e8d59285acb915c647235867e0c6da4f66e60a05984375036998c207662988cb59a362390f86050c09863e4ee982102dfcffb0131cc1413aec1b7d1d8fb08
|
||||
checksum: 10c0/e5688a86f457b4eaa682d83a86702826d2d828db4cfc153b8b1f0b8409c94530a4bde8deb3e819497ba8e4bd0eda08ed55468a41a8138f82db43d633cf332121
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
|
@ -12594,7 +12590,7 @@ __metadata:
|
|||
dependencies:
|
||||
"@arcjet/next": "npm:^1.0.0-beta.1"
|
||||
"@clerk/nextjs": "npm:^6.10.1"
|
||||
"@clerk/themes": "npm:^2.2.10"
|
||||
"@clerk/themes": "npm:^2.2.12"
|
||||
"@codecov/nextjs-webpack-plugin": "npm:^1.8.0"
|
||||
"@content-collections/cli": "npm:^0.1.6"
|
||||
"@content-collections/core": "npm:^0.8.0"
|
||||
|
@ -12609,7 +12605,6 @@ __metadata:
|
|||
"@mdx-js/loader": "npm:^3.1.0"
|
||||
"@mdx-js/react": "npm:^3.1.0"
|
||||
"@microsoft/eslint-formatter-sarif": "npm:^3.1.0"
|
||||
"@neshca/cache-handler": "npm:^1.9.0"
|
||||
"@next/eslint-plugin-next": "npm:15.1.6"
|
||||
"@next/mdx": "npm:^15.1.6"
|
||||
"@prisma/client": "npm:^6.2.1"
|
||||
|
@ -12622,7 +12617,7 @@ __metadata:
|
|||
"@radix-ui/react-popover": "npm:^1.1.3"
|
||||
"@radix-ui/react-separator": "npm:^1.0.3"
|
||||
"@radix-ui/react-slot": "npm:^1.1.0"
|
||||
"@radix-ui/react-tooltip": "npm:^1.1.6"
|
||||
"@radix-ui/react-tooltip": "npm:^1.1.7"
|
||||
"@radix-ui/react-visually-hidden": "npm:^1.1.0"
|
||||
"@sentry/nextjs": "npm:8"
|
||||
"@tailwindcss/typography": "npm:^0.5.16"
|
||||
|
@ -12632,11 +12627,12 @@ __metadata:
|
|||
"@testing-library/react": "npm:^16.2.0"
|
||||
"@types/compression": "npm:^1.7.5"
|
||||
"@types/dompurify": "npm:^3"
|
||||
"@types/ioredis": "npm:^5.0.0"
|
||||
"@types/jest": "npm:^29.5.14"
|
||||
"@types/lodash": "npm:^4.17.14"
|
||||
"@types/mdx": "npm:^2.0.13"
|
||||
"@types/node": "npm:^22.10.7"
|
||||
"@types/react": "npm:^19.0.7"
|
||||
"@types/react": "npm:^19.0.8"
|
||||
"@types/react-dom": "npm:^19.0.3"
|
||||
"@typescript-eslint/eslint-plugin": "npm:^8.21.0"
|
||||
"@typescript-eslint/parser": "npm:^8.21.0"
|
||||
|
@ -12663,7 +12659,7 @@ __metadata:
|
|||
next-themes: "npm:^0.4.4"
|
||||
postcss: "npm:^8.5.1"
|
||||
prettier: "npm:^3.4.2"
|
||||
prettier-plugin-tailwindcss: "npm:^0.6.10"
|
||||
prettier-plugin-tailwindcss: "npm:^0.6.11"
|
||||
prisma: "npm:^6.2.1"
|
||||
react: "npm:^19.0.0"
|
||||
react-day-picker: "npm:^9.5.0"
|
||||
|
|
Loading…
Add table
Reference in a new issue