mirror of
https://github.com/lukevella/rallly.git
synced 2025-04-28 17:56:37 +02:00
Handle connection error
This commit is contained in:
parent
7f877689b2
commit
0bcc4cd9f1
1 changed files with 12 additions and 5 deletions
|
@ -28,10 +28,17 @@ export async function rateLimit(
|
|||
|
||||
const session = await auth();
|
||||
const identifier = session?.user?.id || (await getIPAddress());
|
||||
try {
|
||||
const ratelimit = new Ratelimit({
|
||||
redis: kv,
|
||||
limiter: Ratelimit.slidingWindow(requests, duration),
|
||||
});
|
||||
|
||||
return ratelimit.limit(`${identifier}:${name}`);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
return {
|
||||
success: true,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue