radix-router
Advanced tools
Comparing version 3.0.0 to 3.0.1
{ | ||
"name": "radix-router", | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"description": "Radix tree based router", | ||
@@ -13,6 +13,5 @@ "main": "index.js", | ||
"scripts": { | ||
"pretest": "eslint .", | ||
"test": "mocha test", | ||
"test-coverage": "istanbul cover _mocha --include-all-sources -- --ui bdd --reporter spec ./tests", | ||
"coveralls": "cat ./coverage/lcov.info | coveralls", | ||
"pretest": "npm run lint", | ||
"test": "nyc mocha test", | ||
"coverage": "nyc report --reporter=text-lcov | coveralls", | ||
"lint": "eslint ." | ||
@@ -34,4 +33,5 @@ }, | ||
"jshint": "^2.9.4", | ||
"mocha": "^3.1.2" | ||
"mocha": "^3.1.2", | ||
"nyc": "^11.2.1" | ||
} | ||
} |
@@ -18,2 +18,20 @@ # Radix Router | ||
A minimal example: | ||
```js | ||
const RadixRouter = require('radix-router') | ||
const router = new Router() | ||
router.insert({ | ||
path: '/api/people/:id', | ||
data: { some: 'data' } | ||
}) | ||
const { data, params } = router.lookup('/api/people/123456') | ||
const { id } = params | ||
console.log(id) // prints: '123456' | ||
console.log(data) // prints: { some: 'data' } | ||
``` | ||
#### Creating a new Router | ||
@@ -152,8 +170,5 @@ | ||
content fills the position of the placeholder will be added to the lookup result | ||
under the `params` attribute. The results within `params` is sorted by its occurrence | ||
in the route. | ||
under the `params` attribute. The name given for the placeholder in the path is the key to | ||
retrieve the parameter from. | ||
Note: Route placeholder params are placed into an array as an optimization. Your route handlers | ||
should be aware of the order placeholders are defined in the routes. | ||
Example: | ||
@@ -163,9 +178,7 @@ | ||
router.insert( | ||
path: '/api/v2/:myPlaceholder/route', | ||
very: 'placeholder' | ||
path: '/api/v2/:myPlaceholder/route' | ||
}) | ||
router.insert( | ||
path: '/api/v3/:organizations/directory/:groupId', | ||
very: 'placeholder' | ||
path: '/api/v3/:organizations/directory/:groupId' | ||
}) | ||
@@ -178,3 +191,2 @@ ``` | ||
path: '/api/v2/:myPlaceholder/route', | ||
very: 'placeholder', | ||
params: { | ||
@@ -190,3 +202,2 @@ myPlaceholder: 'application' | ||
path: '/api/v3/:organizations/directory/:groupId', | ||
very: 'placeholder', | ||
params: { | ||
@@ -193,0 +204,0 @@ organizations: 'test-org', |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
25230
204
0
15