Closed gamedevsam closed 4 years ago
Hi Samuel,
it's currently not possible. Would there be any drawback for your use case to do the following instead?
endpoints.users_create = async function() {...};
endpoints.posts_create = async function() {...};
Note that with Wildcard it's best not to think in terms of CRUD operations. Rather, you can see Wildcard just as a thin secure layer wrapping SQL/ORM queries; image you'd directly use SQL/ORM queries on your frontend. Does that make sense to you?
Yes this is not much of an issue, was more of a curiosity for my own sake. I imagine adding this type of functionality would not be too difficult if someone really wanted it since endpoints is just a proxy which could be modified to handle objects with function keys as well as simple functions.
On a separate note, can you explain why named arrow functions are not allowed in wildcard? Is it for consistency or is there a runtime reason why they are problematic?
Yes and let's keep this open to gauge community interest :).
Because arrow functions don't have a this
object.
Let me know if you have any other questions :)
Closing this but if someone wants this let me know. I'm open to implement what Samuel said:
I imagine adding this type of functionality would not be too difficult if someone really wanted it since endpoints is just a proxy which could be modified to handle objects with function keys as well as simple functions.
Can you have namespaced endpoints with wildcard?
For example:
I know this is a bit semantics since you could have a
createUser
andcreatePost
endpoints, but as the API surface grows being able to have namespaced routes becomes a valuable tool.