- Added Sentry integration for error tracking across various components, including error boundaries and user actions. - Updated global error handling to capture exceptions and provide detailed feedback to users. - Enhanced user notifications with toast messages for actions such as credit management, image generation, and canvas exports. - Improved user experience by displaying relevant messages during interactions, ensuring better visibility of system states and errors.
17 lines
375 B
TypeScript
17 lines
375 B
TypeScript
import { redis } from "./redis";
|
|
|
|
export async function rateLimit(
|
|
key: string,
|
|
limit: number,
|
|
windowSeconds: number
|
|
): Promise<{ success: boolean; remaining: number }> {
|
|
const count = await redis.incr(key);
|
|
if (count === 1) {
|
|
await redis.expire(key, windowSeconds);
|
|
}
|
|
return {
|
|
success: count <= limit,
|
|
remaining: Math.max(0, limit - count),
|
|
};
|
|
}
|