Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions app/routes/clothing.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@


@clothing.route("/<clothing_id>", methods=["GET"])
@limiter.limit("5 per minute")
@limiter.limit("60 per minute")
@authorize_request
def get_clothing_piece(clothing_id: str):
clothing = clothing_manager.get_clothing_by_id(g.user_id, clothing_id)
return jsonify(clothing.to_dict()), 200


@clothing.route("/<clothing_id>", methods=["DELETE"])
@limiter.limit("5 per minute")
@limiter.limit("60 per minute")
@authorize_request
def delete_clothing_piece(clothing_id: str):
clothing_manager.soft_delete_clothing_by_id(g.user_id, clothing_id)
Expand All @@ -25,7 +25,7 @@ def delete_clothing_piece(clothing_id: str):


@clothing.route("/<clothing_id>", methods=["PATCH"])
@limiter.limit("5 per minute")
@limiter.limit("60 per minute")
@authorize_request
def patch_clothing_piece(clothing_id: str):
request.headers["Authorization"]
Expand Down
4 changes: 2 additions & 2 deletions app/routes/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def _build_temp_url(image_id: str) -> str:


@images.route("/preview", methods=["POST"])
@limiter.limit("1 per minute")
@limiter.limit("20 per minute")
@authorize_request
def generate_image():
if "file" not in request.files:
Expand Down Expand Up @@ -63,7 +63,7 @@ def generate_image():


@images.route("/preview/<job_id>", methods=["GET"])
@limiter.limit("30 per minute")
@limiter.limit("120 per minute")
@authorize_request
def get_preview_status(job_id: str):
try:
Expand Down
20 changes: 10 additions & 10 deletions app/routes/outfits.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@


@outfits.route("/<outfit_id>", methods=["GET"])
@limiter.limit("5 per minute")
@limiter.limit("60 per minute")
@authorize_request
def get_outfit(outfit_id: str):
outfit = outfit_manager.get_outfit_by_id(g.user_id, outfit_id)
Expand All @@ -24,7 +24,7 @@ def get_outfit(outfit_id: str):


@outfits.route("/<outfit_id>", methods=["DELETE"])
@limiter.limit("5 per minute")
@limiter.limit("60 per minute")
@authorize_request
def delete_outfit(outfit_id: str):
outfit_manager.soft_delete_outfit_by_id(g.user_id, outfit_id)
Expand All @@ -33,7 +33,7 @@ def delete_outfit(outfit_id: str):


@outfits.route("/<outfit_id>", methods=["PATCH"])
@limiter.limit("3 per minute")
@limiter.limit("60 per minute")
@authorize_request
def patch_outfit(outfit_id: str):
data: dict = request.get_json()
Expand Down Expand Up @@ -63,7 +63,7 @@ def patch_outfit(outfit_id: str):


@outfits.route("/<outfit_id>/wears", methods=["POST"])
@limiter.limit("10 per minute")
@limiter.limit("60 per minute")
@authorize_request
def log_outfit_wear(outfit_id: str) -> ResponseReturnValue:
data: dict = request.get_json(silent=True) or {}
Expand All @@ -84,7 +84,7 @@ def log_outfit_wear(outfit_id: str) -> ResponseReturnValue:


@outfits.route("/<outfit_id>/wears", methods=["GET"])
@limiter.limit("10 per minute")
@limiter.limit("60 per minute")
@authorize_request
def get_outfit_wears(outfit_id: str) -> ResponseReturnValue:
limit = request.args.get("limit", 50, type=int)
Expand All @@ -101,7 +101,7 @@ def get_outfit_wears(outfit_id: str) -> ResponseReturnValue:


@outfits.route("/wears/<wear_id>", methods=["GET"])
@limiter.limit("10 per minute")
@limiter.limit("60 per minute")
@authorize_request
def get_outfit_wear(wear_id: str) -> ResponseReturnValue:
wear = wear_manager.get_wear_by_id(g.user_id, wear_id)
Expand All @@ -110,7 +110,7 @@ def get_outfit_wear(wear_id: str) -> ResponseReturnValue:


@outfits.route("/wears/<wear_id>", methods=["PATCH"])
@limiter.limit("10 per minute")
@limiter.limit("60 per minute")
@authorize_request
def patch_outfit_wear(wear_id: str) -> ResponseReturnValue:
data: dict = request.get_json(silent=True) or {}
Expand All @@ -121,7 +121,7 @@ def patch_outfit_wear(wear_id: str) -> ResponseReturnValue:


@outfits.route("/wears/<wear_id>", methods=["DELETE"])
@limiter.limit("10 per minute")
@limiter.limit("60 per minute")
@authorize_request
def delete_outfit_wear(wear_id: str) -> ResponseReturnValue:
wear_manager.delete_wear(g.user_id, wear_id)
Expand All @@ -130,7 +130,7 @@ def delete_outfit_wear(wear_id: str) -> ResponseReturnValue:


@outfits.route("/recommend", methods=["POST"])
@limiter.limit("10 per minute")
@limiter.limit("60 per minute")
@authorize_request
def recommend_outfits() -> ResponseReturnValue:
data: dict = request.get_json(silent=True) or {}
Expand All @@ -150,7 +150,7 @@ def recommend_outfits() -> ResponseReturnValue:


@outfits.route("/generate", methods=["POST"])
@limiter.limit("10 per minute")
@limiter.limit("60 per minute")
@authorize_request
def generate_outfits() -> ResponseReturnValue:
data: dict = request.get_json(silent=True) or {}
Expand Down
6 changes: 3 additions & 3 deletions app/routes/static.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

@static.route("/clothing_images/<clothing_id>.webp", methods=["GET"])
@static.route("/clothing_images/<clothing_id>", methods=["GET"])
@limiter.limit("10 per minute")
@limiter.limit("300 per minute")
def getClothingImage(clothing_id):
try:
return send_from_directory("app/static/clothing_images", f"{clothing_id}.webp")
Expand All @@ -19,7 +19,7 @@ def getClothingImage(clothing_id):


@static.route("/temp/<filename>", methods=["GET"])
@limiter.limit("2 per minute")
@limiter.limit("120 per minute")
def getTempImage(filename):
if not filename:
return jsonify({"error": "Filename is required"}), 400
Expand All @@ -36,7 +36,7 @@ def getTempImage(filename):


@static.route("/outfit_images/<filename>", methods=["GET"])
@limiter.limit("10 per minute")
@limiter.limit("300 per minute")
def get_outfit_image(filename):
filename = (
filename.strip() + ".webp" if not filename.endswith(".webp") else filename
Expand Down
2 changes: 1 addition & 1 deletion app/routes/taxonomy.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def _build_taxonomy() -> dict[str, list[str]]:

@taxonomy.route("", methods=["GET"])
@taxonomy.route("/", methods=["GET"])
@limiter.limit("30 per minute")
@limiter.limit("120 per minute")
def get_taxonomy():
response = jsonify(_TAXONOMY)
response.set_etag(_TAXONOMY_ETAG)
Expand Down
26 changes: 13 additions & 13 deletions app/routes/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def upgrade_guest() -> ResponseReturnValue:


@users.route("/me/clothing/sync", methods=["GET"])
@limiter.limit("5 per minute")
@limiter.limit("30 per minute")
@authorize_request
def sync_my_clothes():
updated_since_param = request.args.get("updated_since")
Expand Down Expand Up @@ -82,7 +82,7 @@ def sync_my_clothes():


@users.route("/me/outfits/sync", methods=["GET"])
@limiter.limit("5 per minute")
@limiter.limit("30 per minute")
@authorize_request
def sync_my_outfits():
updated_since_param = request.args.get("updated_since")
Expand Down Expand Up @@ -111,7 +111,7 @@ def sync_my_outfits():


@users.route("/me/outfit-wears/sync", methods=["GET"])
@limiter.limit("5 per minute")
@limiter.limit("30 per minute")
@authorize_request
def sync_my_outfit_wears():
updated_since_param = request.args.get("updated_since")
Expand Down Expand Up @@ -140,7 +140,7 @@ def sync_my_outfit_wears():


@users.route("/me/outfit-wears/stats", methods=["GET"])
@limiter.limit("10 per minute")
@limiter.limit("60 per minute")
@authorize_request
def get_my_outfit_wear_stats() -> ResponseReturnValue:
stats = wear_manager.get_stats(
Expand All @@ -154,7 +154,7 @@ def get_my_outfit_wear_stats() -> ResponseReturnValue:


@users.route("/me/outfit-wears", methods=["GET"])
@limiter.limit("10 per minute")
@limiter.limit("60 per minute")
@authorize_request
def get_my_outfit_wears() -> ResponseReturnValue:
limit = request.args.get("limit", 50, type=int)
Expand All @@ -176,7 +176,7 @@ def get_my_outfit_wears() -> ResponseReturnValue:


@users.route("/me/clothing/wear-stats", methods=["GET"])
@limiter.limit("10 per minute")
@limiter.limit("60 per minute")
@authorize_request
def get_my_clothing_wear_stats() -> ResponseReturnValue:
limit = request.args.get("limit", 50, type=int)
Expand All @@ -200,7 +200,7 @@ def get_my_clothing_wear_stats() -> ResponseReturnValue:


@users.route("/<user_id>/outfits", methods=["GET"])
@limiter.limit("5 per minute")
@limiter.limit("60 per minute")
@authorize_request
def get_outfit_list(user_id: str):
limit = request.args.get("limit", 50, type=int)
Expand All @@ -217,7 +217,7 @@ def get_outfit_list(user_id: str):


@users.route("/me/outfits", methods=["GET"])
@limiter.limit("5 per minute")
@limiter.limit("60 per minute")
@authorize_request
def get_outfit_list_private():
limit = request.args.get("limit", 50, type=int)
Expand All @@ -234,7 +234,7 @@ def get_outfit_list_private():


@users.route("/me/outfits", methods=["POST"])
@limiter.limit("5 per minute")
@limiter.limit("60 per minute")
@authorize_request
def create_outfit():
data = request.get_json()
Expand All @@ -256,7 +256,7 @@ def create_outfit():


@users.route("/<user_id>/clothing", methods=["GET"])
@limiter.limit("5 per minute")
@limiter.limit("60 per minute")
@authorize_request
def get_clothing_list(user_id: str):
limit = request.args.get("limit", 50, type=int)
Expand Down Expand Up @@ -285,7 +285,7 @@ def get_clothing_list(user_id: str):


@users.route("/me/clothing", methods=["GET"])
@limiter.limit("5 per minute")
@limiter.limit("60 per minute")
@authorize_request
def get_clothing_list_private() -> ResponseReturnValue:
limit = request.args.get("limit", 50, type=int)
Expand Down Expand Up @@ -318,7 +318,7 @@ def get_clothing_list_private() -> ResponseReturnValue:


@users.route("/me/clothing", methods=["POST"])
@limiter.limit("5 per minute")
@limiter.limit("60 per minute")
@authorize_request
def create_clothing_piece():
data = request.get_json()
Expand Down Expand Up @@ -432,7 +432,7 @@ def delete_account():

@users.route("/me", methods=["GET"])
@authorize_request
@limiter.limit("3 per minute")
@limiter.limit("60 per minute")
def get_current_user():
user = user_manager.get_private_user_profile_by_id(g.user_id)
return jsonify({"user": user.model_dump(mode="json")}), 200
Loading