mirror of
https://github.com/Sea-Haven-Industries/meal-order-manager.git
synced 2026-10-07 16:18:54 +00:00
fix: address review comments
This commit is contained in:
parent
be0cfce943
commit
308f46eafd
2 changed files with 9 additions and 4 deletions
|
|
@ -236,11 +236,14 @@ def handle_publish_menu(event):
|
||||||
body = json.loads(event.get("body", "{}"))
|
body = json.loads(event.get("body", "{}"))
|
||||||
except json.JSONDecodeError:
|
except json.JSONDecodeError:
|
||||||
return response(400, {"error": "Invalid JSON"})
|
return response(400, {"error": "Invalid JSON"})
|
||||||
|
|
||||||
|
if not isinstance(body, dict):
|
||||||
|
return response(400, {"error": "Request body must be a JSON object"})
|
||||||
|
|
||||||
meals = body.get("meals")
|
meals = body.get("meals")
|
||||||
if not isinstance(meals, list) or not meals:
|
if not isinstance(meals, list) or not meals:
|
||||||
return response(400, {"error": "At least one meal is required"})
|
return response(400, {"error": "At least one meal is required"})
|
||||||
|
|
||||||
for meal in meals:
|
for meal in meals:
|
||||||
price = meal.get("price") if isinstance(meal, dict) else None
|
price = meal.get("price") if isinstance(meal, dict) else None
|
||||||
if (
|
if (
|
||||||
|
|
@ -253,7 +256,7 @@ def handle_publish_menu(event):
|
||||||
return response(
|
return response(
|
||||||
400, {"error": "Each meal requires a name and non-negative price"}
|
400, {"error": "Each meal requires a name and non-negative price"}
|
||||||
)
|
)
|
||||||
|
|
||||||
week = current_week()
|
week = current_week()
|
||||||
menu = {
|
menu = {
|
||||||
"scraped_at": body.get("scraped_at"),
|
"scraped_at": body.get("scraped_at"),
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,8 @@ def signed_request(
|
||||||
body: dict | None = None,
|
body: dict | None = None,
|
||||||
region: str = "us-east-1",
|
region: str = "us-east-1",
|
||||||
) -> dict:
|
) -> dict:
|
||||||
|
if not api_url.startswith(("http://", "https://")):
|
||||||
|
raise ValueError(f"api_url must use http(s) scheme: {api_url!r}")
|
||||||
data = json.dumps(body).encode() if body is not None else None
|
data = json.dumps(body).encode() if body is not None else None
|
||||||
headers = {"Content-Type": "application/json"} if data is not None else {}
|
headers = {"Content-Type": "application/json"} if data is not None else {}
|
||||||
request = AWSRequest(
|
request = AWSRequest(
|
||||||
|
|
@ -37,7 +39,7 @@ def signed_request(
|
||||||
SigV4Auth(credentials.get_frozen_credentials(), "execute-api", region).add_auth(
|
SigV4Auth(credentials.get_frozen_credentials(), "execute-api", region).add_auth(
|
||||||
request
|
request
|
||||||
)
|
)
|
||||||
|
|
||||||
prepared = request.prepare()
|
prepared = request.prepare()
|
||||||
http_request = urllib.request.Request(
|
http_request = urllib.request.Request(
|
||||||
prepared.url,
|
prepared.url,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue