修复限流器问题

This commit is contained in:
2026-04-01 16:05:57 +08:00
parent 4e99ca2b21
commit 23319d8e10
8 changed files with 129 additions and 95 deletions

View File

@@ -7,7 +7,7 @@ Author: Canglan <admin@sea-studio.top>
License: AGPL v3
"""
from fastapi import APIRouter, HTTPException, Query
from fastapi import APIRouter, HTTPException, Query, Request
from typing import Optional, List
from ...dependencies import CurrentUserDependency, DbDependency
from ...models import Note
@@ -19,6 +19,7 @@ router = APIRouter(prefix="/api/v1/notes", tags=["notes"])
@router.get("/", response_model=List[NoteResponse])
@rate_limit(requests=100, period=60)
async def get_notes(
request: Request, # 添加 request 参数
current_user: CurrentUserDependency,
db: DbDependency,
skip: int = Query(0, ge=0),
@@ -33,6 +34,7 @@ async def get_notes(
@router.post("/", response_model=NoteResponse, status_code=201)
@rate_limit(requests=50, period=60)
async def create_note(
request: Request, # 添加 request 参数
data: NoteCreate,
current_user: CurrentUserDependency,
db: DbDependency
@@ -46,6 +48,7 @@ async def create_note(
@router.put("/{note_id}", response_model=NoteResponse)
@rate_limit(requests=50, period=60)
async def update_note(
request: Request, # 添加 request 参数
note_id: int,
data: NoteUpdate,
current_user: CurrentUserDependency,
@@ -66,6 +69,7 @@ async def update_note(
@router.delete("/{note_id}")
@rate_limit(requests=30, period=60)
async def delete_note(
request: Request, # 添加 request 参数
note_id: int,
current_user: CurrentUserDependency,
db: DbDependency