samchon / nestia

NestJS Helper Libraries + TypeScript OpenAPI generator
https://nestia.io/
MIT License
1.82k stars 94 forks source link

Enhancing GET Request Flexibility for Parameter Parsing in Nestia #675

Closed Val0429 closed 12 months ago

Val0429 commented 12 months ago

Feature Request

I'd like to request an enhancement for Nestia that allows for extended queries while using a GET request. This feature would be really helpful in certain situations.

For instance, ZenStack provides a helpful format in its CRUD API like this: LINK

GET /api/model/post/findMany?q={"where":{"published":true},"include":{"author":true}}

With the 'q' parameter, Prisma's findMany interface is exposed, which is very flexible and useful.

I'm wondering if it's possible to incorporate this kind of parameter parsing into Nestia. To explain in more detail, this would involve first using JSON.parse on the 'q' parameter's string, and then using assertEqual to validate the interface.

Thank you.

samchon commented 12 months ago

Duplicated issue: https://github.com/samchon/nestia/issues/600

I hope you to make the router function to have another method like PATCH, and use @TypedBody() instead.

The standard URL query allows only Record<string, string | string[] | undefined> type. I know there're some insane libraries writing JSON string on URL query properties, but it is violating the standard spec. Furthermore, the URL address has length limitation, so such raw JSON string assignment causes unexepcted error that hard to trace and debug.

This is the reason why @TypedQuery() decorator is not supporting the JSON type, and enforcing restriction following the standard spec. It is on your mind that whether calling JSON.stringify() and JSON.parse() functions on a string typed property of @TypedQuery() or not, but nestia doesn't have plan to support such standard violating feature.

https://nestia.io/docs/core/TypedQuery/#restriction