feat: add basic webui
This commit is contained in:
17
packages/rate-limit/index.ts
Normal file
17
packages/rate-limit/index.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { env } from '@konobangu/env';
|
||||
import { Ratelimit, type RatelimitConfig } from '@upstash/ratelimit';
|
||||
import { Redis } from '@upstash/redis';
|
||||
|
||||
export const redis = new Redis({
|
||||
url: env.UPSTASH_REDIS_REST_URL,
|
||||
token: env.UPSTASH_REDIS_REST_TOKEN,
|
||||
});
|
||||
|
||||
export const createRateLimiter = (props: Omit<RatelimitConfig, 'redis'>) =>
|
||||
new Ratelimit({
|
||||
redis,
|
||||
limiter: props.limiter ?? Ratelimit.slidingWindow(10, '10 s'),
|
||||
prefix: props.prefix ?? 'next-forge',
|
||||
});
|
||||
|
||||
export const { slidingWindow } = Ratelimit;
|
||||
18
packages/rate-limit/package.json
Normal file
18
packages/rate-limit/package.json
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "@konobangu/rate-limit",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"clean": "git clean -xdf .cache .turbo dist node_modules",
|
||||
"typecheck": "tsc --noEmit --emitDeclarationOnly false"
|
||||
},
|
||||
"dependencies": {
|
||||
"@konobangu/env": "workspace:*",
|
||||
"@upstash/ratelimit": "^2.0.5",
|
||||
"@upstash/redis": "^1.34.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@konobangu/typescript-config": "workspace:*",
|
||||
"typescript": "^5.7.2"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user