Add free tier rate limiting with Upstash Redis and API key handling
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
import { Ratelimit } from "@upstash/ratelimit"
|
||||
import { Redis } from "@upstash/redis"
|
||||
|
||||
const redis = new Redis({
|
||||
url: process.env.UPSTASH_REDIS_REST_URL!,
|
||||
token: process.env.UPSTASH_REDIS_REST_TOKEN!,
|
||||
})
|
||||
|
||||
// Free tier: 1 comic per week (fixed window)
|
||||
export const freeTierRateLimit = new Ratelimit({
|
||||
redis,
|
||||
limiter: Ratelimit.fixedWindow(1, "7 d"),
|
||||
analytics: true,
|
||||
prefix: "ratelimit:free-comics",
|
||||
})
|
||||
+1
-1
@@ -7,7 +7,7 @@ export const stories = pgTable('stories', {
|
||||
title: text('title').notNull(),
|
||||
slug: text('slug').notNull().unique(),
|
||||
description: text('description'),
|
||||
userId: uuid('user_id').notNull(), // Required Clerk user ID
|
||||
userId: text('user_id').notNull(), // Required Clerk user ID
|
||||
createdAt: timestamp('created_at').defaultNow().notNull(),
|
||||
updatedAt: timestamp('updated_at').defaultNow().notNull(),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user