A dojo JsonRest will likely send something like this to the server:
/FooObject/?foo=value1&sortBy=+foo,-bar
I have express and mongodb on the other side.
It's easy enough to get foo. But then, I was just about to write my own function to parse sortBy when I realised: there must be a better way? Surely, this is a common problem which should have an established solution...? Maybe a well-known middleware that is escaping me right now?
I will also need to make it possible to add wildcards (/FooObject/?foo=value%&sortBy=+foo,-bar
so that anything starting with value
will work. But then again, I wonder if there is some kind of established pattern for this too?
I think you're looking for qs, which you can install with npm install qs
:
> qs.parse('foo=value%&sortBy=%2bfoo,-bar');
{ foo: 'value%', sortBy: '+foo,-bar' }
Well, there is no way to do it... time to write something and place it in GitHub!