Skip to content

Commit 3800e92

Browse files
committed
fix: build error
1 parent 06989da commit 3800e92

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

src/app/api/report-tag/route.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,21 @@ interface ReportTagBody {
1919

2020
const ALLOWED_FIELDS = ["subject", "courseCode", "exam", "slot", "year"];
2121

22-
const ratelimit = new Ratelimit({
23-
redis,
24-
limiter: Ratelimit.slidingWindow(3, "1 h"),//per id - 3 request - per hour
25-
analytics: true,
22+
function getRateLimit(){
23+
return new Ratelimit({
24+
redis,
25+
limiter: Ratelimit.slidingWindow(3, "1 h"),//per id - 3 request - per hour
26+
analytics: true,
2627
});
27-
28+
}
2829
function getClientIp(req: Request & { ip?: string}): string {
2930
return req.ip ?? "127.0.0.1";
3031
}
3132

3233
export async function POST(req: Request & { ip?: string }) {
3334
try {
3435
await connectToDatabase();
35-
36+
const ratelimit = getRateLimit();
3637
const body = (await req.json()) as ReportTagBody;
3738
const paperId = typeof body.paperId === "string" ? body.paperId : undefined;
3839

0 commit comments

Comments
 (0)