[Feature Request] Automatic REST API: Support for Nested Resource Endpoints (Hierarchical Routing)
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 15/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- typescript
- Área
- api
Línea de trabajo
This is a design-level request with no pointer into the code: the payload names only ZenStack's automatic REST API, the .zmodel schema and the REST plugin configuration. Read how the REST plugin maps models to flat routes and how ZModel attributes are parsed, then weigh a schema attribute (the suggested @@http.path) against plugin config. "Done" means nested routes like GET /threads/1/comments that scope children to their parent, auto-set the foreign key on POST, and 404 on mismatch — but the approach needs maintainer agreement first.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Description
Is your feature request related to a problem? Please describe.
Currently, ZenStack's automatic REST API generates "flat" endpoints for all models (e.g., /thread/1 and /comment/2). While functional, this doesn't reflect the logical ownership and hierarchy of data. For resources that are strictly dependent on a parent—such as a Comment that must always belong to a Thread—a flat structure lacks semantic clarity and forces the client to manually manage foreign keys in every request.
Without nested routing, the API doesn't express the constraint that a child resource's lifecycle is bound to its parent.
Describe the solution you'd like
I would like the ability to configure hierarchical or "nested" endpoints within the automatic REST API. This would allow for URLs like:
GET /threads/:threadId/comments/:commentId
Key Requirements:
- Logical Scoping: Accessing a child via a nested route should automatically apply a filter to ensure the child actually belongs to the specified parent.
- Simplified Creation: A
POSTto/threads/1/commentsshould automatically associate the new comment withthreadId: 1without requiring the ID in the request body. - ZModel Configuration: Ideally, this could be defined in the
.zmodelfile using an attribute (e.g.,@@http.path) or via the plugin configuration to specify parent-child relationships for routing.
Example Structure:
If a Thread has many Comments:
GET /threads/1/comments— Fetches all comments for thread 1.POST /threads/1/comments— Creates a comment specifically for thread 1.GET /threads/1/comments/2— Fetches comment 2, but only if it belongs to thread 1 (returning 404 otherwise).
Describe alternatives you've considered
- Flat Endpoints with Filters: Using
GET /comment?threadId=1. While this works, it is less RESTful and doesn't enforce the hierarchy at the routing level. - Custom Hooks/Routes: Writing manual Next.js or Express routes to wrap the ZenStack logic. This defeats the purpose of an "Automatic" REST API and increases boilerplate.
Additional context
Hierarchical routing is a staple of mature REST frameworks. For instance:
- Ruby on Rails allows
resources :threads do resources :comments end. - NestJS and Express developers frequently implement this to improve API discoverability and security through implicit scoping.
This feature would make ZenStack-generated APIs feel significantly more professional and "opinionated" in a way that aligns with standard REST best practices.
References:
- Lenguaje dominante
- TypeScript
- Estrellas
- 2.9k
- Forks
- 157
- Merge medio
- 11 h 42 min
- PR fusionados (30 d)
- 20
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de zenstackhq/zenstack
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
zenstackhq/zenstack#2873 ·
Los mantenedores suelen responder en 1 día
-
runtime
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
zenstackhq/zenstack#2868 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
zenstackhq/zenstack#2694 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 68/100
zenstackhq/zenstack#2659 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
zenstackhq/zenstack#2542 · 1 comentario ·
Los mantenedores suelen responder en 1 día
Todos los issues de zenstackhq/zenstack
Issues similares
-
First unknown-user login after boot is one scrypt run slower than a real user's wrong passwordAbiertoarea: backend bug priority: low
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
snapotter-hq/SnapOtter#2254 ·
Los mantenedores suelen responder en 1 día
-
bug ticket
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
cratestack/cratestack#1154 ·
Los mantenedores suelen responder en 1 día
-
server 消息处理器 cmd 分支补显式错误回报——竞态非法命令现走未处理拒绝Posiblemente ocupada @openaddr la tomó hoy. Abiertoready-for-agent refactor wayfinder:task
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
openaddr/dafung-web#428 ·
Los mantenedores suelen responder en 1 día
-
Flaky: mongodb-memory-server 'Port already in use' when another process starts a mongod concurrentlyAbiertoarea:testing bug effort:S priority:P2
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Los mantenedores suelen responder en 1 día
-
lens:agent lens:process process
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
thebristolsound/birdbrain#1772 ·
Los mantenedores suelen responder en 1 día