diff --git a/views_api.py b/views_api.py index 74ca8e3..ad26520 100644 --- a/views_api.py +++ b/views_api.py @@ -59,6 +59,7 @@ from .crud import ( get_print_job, get_print_jobs, get_restaurant, + get_restaurant_by_slug, get_restaurants, get_settings, move_menu_node, @@ -248,6 +249,20 @@ async def api_list_restaurants( return await get_restaurants(wallet_ids) +@restaurant_api_router.get("/api/v1/restaurants/by-slug/{slug}") +async def api_get_restaurant_by_slug(slug: str) -> Restaurant: + """Public — used by the customer webapp to resolve a URL slug + (e.g. /r/big-jays-bustaurant) to a restaurant. Mirrors + api_get_restaurant; declared *before* the bare-id route so the + static prefix wins the path match in FastAPI's router.""" + restaurant = await get_restaurant_by_slug(slug) + if not restaurant: + raise HTTPException( + status_code=HTTPStatus.NOT_FOUND, detail="Restaurant not found." + ) + return restaurant + + @restaurant_api_router.get("/api/v1/restaurants/{restaurant_id}") async def api_get_restaurant(restaurant_id: str) -> Restaurant: """Public — used by the webapp to fetch profile metadata."""