mirror of
https://github.com/rowboatlabs/rowboat.git
synced 2026-05-19 18:35:18 +02:00
add rate-limiting
This commit is contained in:
parent
024f6c75cc
commit
200e8d2e38
9 changed files with 188 additions and 2 deletions
|
|
@ -6,6 +6,7 @@ import { ObjectId, WithId } from "mongodb";
|
|||
import { authCheck } from "../../../utils";
|
||||
import { AgenticAPIChatRequest, convertFromAgenticAPIChatMessages, convertToAgenticAPIChatMessages, convertWorkflowToAgenticAPI } from "@/app/lib/types";
|
||||
import { callClientToolWebhook, getAgenticApiResponse } from "@/app/lib/utils";
|
||||
import { check_query_limit } from "@/app/lib/rate_limiting";
|
||||
|
||||
const chatsCollection = db.collection<z.infer<typeof apiV1.Chat>>("chats");
|
||||
const chatMessagesCollection = db.collection<z.infer<typeof apiV1.ChatMessage>>("chatMessages");
|
||||
|
|
@ -18,6 +19,11 @@ export async function POST(
|
|||
return await authCheck(req, async (session) => {
|
||||
const { chatId } = await params;
|
||||
|
||||
// check query limit
|
||||
if (!await check_query_limit(session.projectId)) {
|
||||
return Response.json({ error: "Query limit exceeded" }, { status: 429 });
|
||||
}
|
||||
|
||||
// parse and validate the request body
|
||||
let body;
|
||||
try {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue