Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
cursee171596yMaybe I do not fully understood but
if you are calling more than Read or Search routes, how are you gonna handle all the different attributes of your models if you use a dynamic routes? -
JhonDoe28186y@cursee yo. I got an orm running, so after getting the :moduleName param, I go to the orm regarding that table and check the fields
-
JhonDoe28186yI'll elaborate if I'm not clear :)
here's some logic present in those endpoints
1. I got the module name from the request
2. I search in the models if there is model matching that name
3. I get the fields from the model file
4. do some validations here now that I got the field names, types and whatnot
5. call find, update, remove or whatever operation is needed -
v1nc3nt67276yIf i understand right, I did something similar in php using class introspection of my model and annotation ( can use many different thing tho ). I did the security using the annotation and didnt seem like an issue until POST PATCH PUT and DELETE but at least i got all my /:entity /:entity/{id} /:entity/{id}/:collection and all the filters going along with them
Related Rants
hello folks, any help would appreciated :). serious question about designing/developing a rest backend.
here is a little insight: I want to reduce the endpoints for many CRUD operations as I can. So for that approach I defined a set of "dynamic" routes like /:moduleName/list, /:moduleName/update and so on.
Now I want to also reduce hardcoding as much stuff as I can for the front end. like I want forms/view/components to know which fields can be sent in the "/:moduleName/xxx" endpoints from above. So I'm thinking to make some /:moduleName/list/map, /:moduleName/update/map endpoints that tells the frontend which fields/keys can be sent for X or Y operation.
regarding design/security concerns Is that a good approach? do you know any other approach that's like to what I want to achieve?
question
don't want to ask this in so
rest
rest design