What is it?
A isomorphic, bullet-proof, ninja-ready payload parsing, matching, and reversing library for Javascript in Node and the browser.
Based on route-parser.
Is it any good?
Yes.
Why do I want it?
You want to write string payloads in a way that makes sense, capture named parameters, add additional constraints, and be able to easily generate payloads.
How do I install it?
npm install --save payload-parser
How do I use it?
Payload = ;var payload = 'MY_FANCY_PAYLOAD_:id';payload // { id: 7 }payload // -> 'MY_FANCY_PAYLOAD_3'
What can I use in my routes?
Example | Description |
---|---|
:name |
a parameter to capture from the payload up to / , ? , or end of string |
*splat |
a splat to capture from the payload up to ? or end of string |
() |
Optional group that doesn't have to be part of the query. Can contain nested optional groups, params, and splats |
anything else | free form literals |
Some examples:
SOME_(optional_):thing
ITEM_ID_:id