Files
svgl/src/server/redis.ts
T
pheralb 6fc3130fba
📦 Build / 🛠️ Build app (push) Has been cancelled
🧑‍🚀 Check / 📦 SVGs Size (push) Has been cancelled
🧑‍🚀 Check / ⚡ Testing with Vitest (push) Has been cancelled
🚀 Deploy / ☁️ API (push) Has been cancelled
⚙️ Trying to fix prod deployment
2025-07-13 20:51:48 +01:00

17 lines
484 B
TypeScript

import { Redis } from '@upstash/redis';
import { Ratelimit } from '@upstash/ratelimit';
import { UPSTASH_REDIS_TOKEN, UPSTASH_REDIS_URL, SVGL_API_REQUESTS } from '$env/static/private';
const cleanUrl = UPSTASH_REDIS_URL.replace(/^['"]|['"]$/g, '').trim();
const redis = new Redis({
url: cleanUrl,
token: UPSTASH_REDIS_TOKEN
});
export const ratelimit = new Ratelimit({
redis: redis,
limiter: Ratelimit.slidingWindow(Number(SVGL_API_REQUESTS), '60s'),
analytics: true
});