Open amitguptagwl opened 6 years ago
Can I try to tackle this issue? Do you have more details about the method name for this and what should I return? An object with all routes, each formatted like the ones on find
?
Yes please. If you check the code, you'll find there are 2 objects to hold static and dynamic routes. You'll have to iterate them to get the list. You can even create 2 function: one to return a list of routes another for formatted list like a tree.
You can also check recently closed PR.
On Thu 25 Oct, 2018, 6:13 AM Lucas Heim, notifications@github.com wrote:
Can I try to tackle this issue? Do you have more details about the method name for this and what should I return? An object with all routes, each formatted like the ones on find?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/node-muneem/anumargak/issues/12#issuecomment-432874789, or mute the thread https://github.com/notifications/unsubscribe-auth/AHVgKBEKpAWaY1sOsWu0NZ32tgNR6c3Pks5uoQlBgaJpZM4XvurV .
@lucasheim are you working on this issue?
I'm not @amitguptagwl. It's been hard for me to find some time recently.
no problem
Hi, can I please be assigned this issue, I would like to try to tackle it.
Hi I have a question regarding a closed PR from October 2018 which is relevant to this issue
https://github.com/node-muneem/anumargak/pull/13
It seems that someone was trying to work on the issue with the router lists and tried to merge their PR but the PR was closed because of lack of features or functionality ? I am not quite sure but I would like to not make the same mistakes going further, so any clarification would be great ! Thank you.
Expected output
{
"GET" : [
"/this/is/static",
{ "/this/is/static/with/versions" : [ '1.2.3', '*' ] }
"/this/is/{dynamic}"
]
}
The goal is to print the routes without revealing the internal complexity of the application. Though we can prepare the list at the time of adding/deleting the route, printing routes is generally one-time operation hence I was avoiding to store it in a variable. However, this option can be considered to reduce complexity.
Thanks for your reply, a few new questions, I see inside of the letsRoute.js file there is a function commented out as shown below on line 541:
/* Anumargak.prototype.print = function(){ var urlTree = {
}
for(var i=0; i < httpMethods.length; i++){
this.staticRoutes [ httpMethods[i] ]
}
} */
Is this what you are trying to request to be completed, or is that something different ?
Second questions, there are 34 different OBJECTS inside of the staticRoutes and dynamicRoutes objects as shown below: ACL,BIND,CHECKOUT,CONNECT,COPY,DELETE,GET,HEAD,LINK,LOCK,M-SEARCH,MERGE,MKACTIVITY,MKCALENDAR,MKCOL,MOVE,NOTIFY,OPTIONS,PATCH,POST,PROPFIND,PROPPATCH,PURGE,PUT,REBIND,REPORT,SEARCH,SOURCE,SUBSCRIBE,TRACE,UNBIND,UNLINK,UNLOCK,UNSUBSCRIBE
As of right now I am under the assumption that you only want to print the properties from the GET objects as per your example above. However, there are also objects within those objects which brings up the question which data from those sub objects would you like to have displayed for the user ? It is my understanding that you want it to be as clean and user friendly as possible.
As an example if I do a crude console.log[this.staticRoute.GET] it will print
{ '/': { data: { handler: [Function], store: undefined }, verMap: undefined, params: undefined }, '/a': { data: { handler: [Function], store: undefined }, verMap: undefined, params: undefined }, '/login/as/admin': { data: { handler: undefined, store: undefined }, verMap: undefined, params: { role: 'admin' } }, '/login/as/user': { data: { handler: undefined, store: undefined }, verMap: undefined, params: { role: 'user' } }, '/login/as/staff': { data: { handler: undefined, store: undefined }, verMap: undefined, params: { role: 'staff' } }, '/some/route': { data: undefined, verMap: SemVerStore { tree: [Node] }, params: undefined } }
I am guessing the verMap is where the version will be stored, my question is, is there any other data from those sub objects you want to be displayed for the user ?
The above example you provided will give me a starting point but I would like to know exactly what you are looking for.
Thank you.
I believe most of the things are self-explainable. However, there is nothing wrong to verify them.
Further, we can think to print a route as follow,
"GET" : [
"this: : {
"is" : {
"static",
"with" : {
"versions" : [ '1.2.3', '*' ]
},
"{dynamic}"
}
}
]
}
Hi, I submitted a PR but it is failing on a test
1) Anumargak events should emit not-found and request event when the route is not registered
Message:
TypeError: Cannot read property 'version' of undefined
Stack:
at
mainly because I am trying to access the version property of objects which don't have a version on them and regardless of what I do ( check to see if there is a version before saving ) it will always fail that test case. I took your advice on collecting the data of the routes when they are being registered in the prorotype.on method but I do not know how to get around this particular problem, if you have any idea of how to approach this that would be great. My alternative would be to print from the staticRoutes and dynamicRoutes objects.
Sure.. I'll check it tomorrow. Thanks
It can be a good user experience if the library can return the list of registered routes. They can be useful for debugging purpose as well.