feat(api): public GET /restaurants/by-slug/{slug}

Prerequisite for the customer webapp module (aiolabs/webapp,
branch feat/restaurant-bundle): the webapp's /r/:slug route needs
to resolve a slug to a Restaurant payload without an admin key.

crud.get_restaurant_by_slug already exists (used by the server-
rendered CMS routes in views.py); just expose it as a public REST
endpoint. Mirrors api_get_restaurant by id and is declared before
the bare-id route so the static prefix wins FastAPI's path match.

Verified live against seeded 'Big Jay's Bustaurant':
  GET /restaurant/api/v1/restaurants/by-slug/big-jays-bustaurant
  -> 200 with the Restaurant payload.
This commit is contained in:
Padreug 2026-05-11 09:03:10 +02:00
commit 6dae57f3f4
3 changed files with 27 additions and 1 deletions

View file

@ -9,7 +9,17 @@ of restaurants, especially the multi-restaurant cart pattern.
A webapp can either talk to one restaurant directly or aggregate
many. There's no central directory inside this extension — grouping
("festival", "collective space", "food court") is **emergent** via
NIP-51 list events curated by whoever runs the venue:
NIP-51 list events curated by whoever runs the venue.
For the **single-venue** case, a webapp that routes on a URL slug
(`/r/big-jays-bustaurant`) resolves the slug → restaurant via the
public `GET /restaurants/by-slug/{slug}` endpoint
([[api-reference]]) and proceeds with that one `id` for menu reads
and order placement. Slug is just a URL nicety — internally
everything continues to key on the restaurant `id`.
For the **aggregator** case (multiple restaurants in one cart), the
webapp consumes a curated NIP-51 list event:
```
{