{"_id":"@bockit/simple-router","_rev":"7-239033c2450882fcd36b1a88ee452176","name":"@bockit/simple-router","description":"Universal router, takes a uri as input and calls a handler. Define handlers for patterns or regexes.","dist-tags":{"latest":"1.1.0"},"versions":{"1.0.0":{"name":"@bockit/simple-router","version":"1.0.0","description":"Universal router, takes a uri as input and calls a handler. Define handlers for patterns or regexes.","main":"index.js","directories":{"test":"tests"},"scripts":{"test":"tape tests/index.js"},"repository":{"type":"git","url":"git+ssh://git@github.com/bockit/simple-router.git"},"keywords":["browser","router","universal","isomorphic"],"browserify":{"transform":["babelify"]},"author":{"name":"James Hiscock","email":"james@jameshiscock.com","url":"http://jameshiscock.com/"},"license":"BSD-3-Clause","bugs":{"url":"https://github.com/bockit/simple-router/issues"},"homepage":"https://github.com/bockit/simple-router#readme","devDependencies":{"babel":"^5.8.23","tape":"^4.2.1"},"dependencies":{"babelify":"^6.3.0"},"gitHead":"99d87af14df577c598b54561704346391686e397","_id":"@bockit/simple-router@1.0.0","_shasum":"e71a6478a98b4080412be1beaf5ad48b360e8f60","_from":".","_npmVersion":"2.13.5","_nodeVersion":"0.10.36","_npmUser":{"name":"bockit","email":"bockit@gmail.com"},"dist":{"shasum":"e71a6478a98b4080412be1beaf5ad48b360e8f60","tarball":"https://registry.npmjs.org/@bockit/simple-router/-/simple-router-1.0.0.tgz","integrity":"sha512-hhjuup8PtbBp2Lzn4ZaiH4MVsMMDORe52gqY2VYudiu6W8EAU6mdHUMo6NWh/TgJNZ+Ki6xpjHnC6nAGFFRRXQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICEvW0wPHo5x8c9becAkVF8OjQkNjd5iGYuVGjKygi06AiAufTydmTCB3yMrOWN0Z9YCgVINeefrSyyi7VPzqMjoQQ=="}]},"maintainers":[{"name":"bockit","email":"bockit@gmail.com"}]},"1.0.1":{"name":"@bockit/simple-router","version":"1.0.1","description":"Universal router, takes a uri as input and calls a handler. Define handlers for patterns or regexes.","main":"index.js","directories":{"test":"tests"},"scripts":{"test":"tape tests/index.js"},"repository":{"type":"git","url":"git+ssh://git@github.com/bockit/simple-router.git"},"keywords":["browser","router","universal","isomorphic"],"browserify":{"transform":["babelify"]},"author":{"name":"James Hiscock","email":"james@jameshiscock.com","url":"http://jameshiscock.com/"},"license":"BSD-3-Clause","bugs":{"url":"https://github.com/bockit/simple-router/issues"},"homepage":"https://github.com/bockit/simple-router#readme","devDependencies":{"babel":"^5.8.23","tape":"^4.2.1"},"dependencies":{"babelify":"^6.3.0"},"gitHead":"569268da182cab77472b98051e88eb02d2dc44a5","_id":"@bockit/simple-router@1.0.1","_shasum":"b17dfa729d275a79c46bd2a9aa58c08a41910226","_from":".","_npmVersion":"2.13.5","_nodeVersion":"0.10.36","_npmUser":{"name":"bockit","email":"bockit@gmail.com"},"dist":{"shasum":"b17dfa729d275a79c46bd2a9aa58c08a41910226","tarball":"https://registry.npmjs.org/@bockit/simple-router/-/simple-router-1.0.1.tgz","integrity":"sha512-zrdAInYMMT8/WbwY3Sv1FQOgm33nYI/AvPtXJXThwA5XaU9M8ELSB65yFdjYXirClKmGlQ/RD1D7GHxTkdP4Dw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDPRsKh7HbKujweTy7PAHqsq0IV5WMIMs6gOBqUUCJ1KwIgAeCtT1dvuoMZnO96rT8UWgHIkNVVaJfCVaT8p1cBeqU="}]},"maintainers":[{"name":"bockit","email":"bockit@gmail.com"}]},"1.0.2":{"name":"@bockit/simple-router","version":"1.0.2","description":"Universal router, takes a uri as input and calls a handler. Define handlers for patterns or regexes.","main":"index.js","directories":{"test":"tests"},"scripts":{"test":"tape tests/index.js"},"repository":{"type":"git","url":"git+ssh://git@github.com/bockit/simple-router.git"},"keywords":["browser","router","universal","isomorphic"],"browserify":{"transform":["babelify"]},"author":{"name":"James Hiscock","email":"james@jameshiscock.com","url":"http://jameshiscock.com/"},"license":"BSD-3-Clause","bugs":{"url":"https://github.com/bockit/simple-router/issues"},"homepage":"https://github.com/bockit/simple-router#readme","devDependencies":{"babel":"^5.8.23","tape":"^4.2.1"},"dependencies":{"babelify":"^6.3.0"},"gitHead":"76919b800fea8a5c719657d152474ef2588dec80","_id":"@bockit/simple-router@1.0.2","_shasum":"590f0b7e58b7a66fdc295af9deaea86a7c6b8fe3","_from":".","_npmVersion":"2.13.5","_nodeVersion":"0.10.36","_npmUser":{"name":"bockit","email":"bockit@gmail.com"},"dist":{"shasum":"590f0b7e58b7a66fdc295af9deaea86a7c6b8fe3","tarball":"https://registry.npmjs.org/@bockit/simple-router/-/simple-router-1.0.2.tgz","integrity":"sha512-KoRazoul7QwJk1HK7PP56WmmVvgq/er5/12mubK5Gcy0lbN+hVBn4qfA01+4cQ9aMGGNCkRy30Tc8C/Zd/2rog==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGPLBT2MfQD6ZZolTTfYvMwmzSJqLWPp7EVIy5bcZuw8AiAVHQ/TR5grP9ULrYb7J0Ap54AsgTA8Z8gN+sLnbAYKaQ=="}]},"maintainers":[{"name":"bockit","email":"bockit@gmail.com"}]},"1.0.3":{"name":"@bockit/simple-router","version":"1.0.3","description":"Universal router, takes a uri as input and calls a handler. Define handlers for patterns or regexes.","main":"index.js","directories":{"test":"tests"},"scripts":{"test":"tape tests/index.js"},"repository":{"type":"git","url":"git+ssh://git@github.com/bockit/simple-router.git"},"keywords":["browser","router","universal","isomorphic"],"browserify":{"transform":["babelify"]},"author":{"name":"James Hiscock","email":"james@jameshiscock.com","url":"http://jameshiscock.com/"},"license":"BSD-3-Clause","bugs":{"url":"https://github.com/bockit/simple-router/issues"},"homepage":"https://github.com/bockit/simple-router#readme","devDependencies":{"babel":"^5.8.23","tape":"^4.2.1"},"dependencies":{"babelify":"^6.3.0"},"gitHead":"083c991d1d4b5130a6abde7bdcab28c416dd5ce2","_id":"@bockit/simple-router@1.0.3","_shasum":"776b2cca3b3bb49638ed52ae8c45bcb95591c258","_from":".","_npmVersion":"2.13.5","_nodeVersion":"0.10.36","_npmUser":{"name":"bockit","email":"bockit@gmail.com"},"dist":{"shasum":"776b2cca3b3bb49638ed52ae8c45bcb95591c258","tarball":"https://registry.npmjs.org/@bockit/simple-router/-/simple-router-1.0.3.tgz","integrity":"sha512-yYDgLPRQruUctFoV/KY1rcqfVwBQm0KIrD+Ohf6kyrEOeKm1WoDbMZ76S8L7jqPYvZhPvDgF2sTTc+mLTzgx7A==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDXUa+jstMzdF1ExgpXe2FWKuqCNikTcGW/NAbmrvwQawIgTc78Wb72TMNAjC9uOkzVDtj7jHOKk4ISzQhL9EmLqHM="}]},"maintainers":[{"name":"bockit","email":"bockit@gmail.com"}]},"1.1.0":{"name":"@bockit/simple-router","version":"1.1.0","description":"Universal router, takes a uri as input and calls a handler. Define handlers for patterns or regexes.","main":"index.js","directories":{"test":"tests"},"scripts":{"test":"tape tests/index.js"},"repository":{"type":"git","url":"git+ssh://git@github.com/bockit/simple-router.git"},"keywords":["browser","router","universal","isomorphic"],"browserify":{"transform":["babelify"]},"author":{"name":"James Hiscock","email":"james@jameshiscock.com","url":"http://jameshiscock.com/"},"license":"BSD-3-Clause","bugs":{"url":"https://github.com/bockit/simple-router/issues"},"homepage":"https://github.com/bockit/simple-router#readme","devDependencies":{"tape":"^4.2.1"},"dependencies":{"babel-preset-es2015":"^6.3.13","babel-register":"^6.4.3","babelify":"^7.2.0"},"gitHead":"df0bff768b1a0384b5165a74171c0f3520a6140e","_id":"@bockit/simple-router@1.1.0","_shasum":"df18267f5ce6c4642cdc6a890da76dd074c6188a","_from":".","_npmVersion":"3.6.0","_nodeVersion":"4.2.4","_npmUser":{"name":"bockit","email":"bockit@gmail.com"},"dist":{"shasum":"df18267f5ce6c4642cdc6a890da76dd074c6188a","tarball":"https://registry.npmjs.org/@bockit/simple-router/-/simple-router-1.1.0.tgz","integrity":"sha512-Q92oD4Zu3NO5V4Zv897O82yl88m2yiB2xy65EGCUhW6sNCa3or47p3S+2/u7BeHWc2GLlTlw81/gFzNhi8deOw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDhiok4pAO0cnQc0ygfSG+e9REDNkyqckGa+c+jhd6oEgIhAK+583py1H1nJP7AVA4C+3sOmpIBkfn5eTsfi6BC1lsK"}]},"maintainers":[{"name":"bockit","email":"bockit@gmail.com"}]}},"readme":"Simple Router\n=============\n\nDefine your routes as string or regex patterns that map to functions to call. Intended to be used in universal javascript applications. \n\nOne way it could be used is to turn uris into actions to dispatch to stores in a flux architecture.\n\nInstallation\n------------\n\n`npm i @bockit/simple-router`\n\nUsage\n-----\n\n```javascript\nimport SimpleRouter from '@bockit/simple-router'\n\nvar router = new SimpleRouter()\n\nrouter.route('/hello/:name', (req) => {\n    console.log('hello ' + req.params.name + '!')\n})\n\nrouter.process('/hello/James') // 'hello James!'\n```\n\nAPI\n---\n\n### `new SimpleRouter()`\n\nInstantiates a new router instance. Has public methods `route(pattern, handler)` and `process(uri)`.\n\n### `route(pattern, handler)`\n\nSet up a handler function for routes that match a pattern. The pattern can be a regex or a string. If it's a string, we use [backbone's route matching patterns.][backbone routes]\n\n[backbone routes]: http://backbonejs.org/#Router-routes\n\n`handler` is a function that takes one argument, the request object.\n\n##### The request object\n\nThe request object has the following properties: \n\n* `uri`: The uri that was matched.\n* `regex`: The regex used to match the route.\n* `pattern`: The pattern for this route. If the pattern was a regex, this is null.\n* `matched`: The matched groups in the `uri` from the `regex`.\n* `query`: An object representing the query parameters, if available, in the `uri`.\n* `params`: An object whose keys are the names of the params and splats in `pattern` and values are their corresponding values in `matched`. If the pattern was a regex, the keys are indices and the values are the corresponding matched values.\n\nFor example, `/foo/:bar` matching `/foo/quux?beep=boop` becomes:\n\n```javascript\n{\n    uri: '/foo/quux?beep=boop',\n    regex: /^/foo/([^/?]+)(?:\\?([\\s\\S]*))?$/,\n    pattern: '/foo/:bar',\n    matched: [ 'quux' ],\n    query: {\n        beep: 'boop'\n    },\n    params: {\n        bar: 'quux'\n    }\n}\n```\n\n### `process(uri)`\n\nRun a `uri` through the routes in a router, calling the handler if a match is found.","maintainers":[{"name":"bockit","email":"bockit@gmail.com"}],"time":{"modified":"2022-06-12T15:24:00.323Z","created":"2015-10-06T13:20:12.836Z","1.0.0":"2015-10-06T13:20:12.836Z","1.0.1":"2015-10-08T14:22:58.565Z","1.0.2":"2015-10-08T14:24:10.385Z","1.0.3":"2015-10-08T14:29:15.209Z","1.1.0":"2016-01-30T06:49:10.117Z"},"homepage":"https://github.com/bockit/simple-router#readme","keywords":["browser","router","universal","isomorphic"],"repository":{"type":"git","url":"git+ssh://git@github.com/bockit/simple-router.git"},"author":{"name":"James Hiscock","email":"james@jameshiscock.com","url":"http://jameshiscock.com/"},"bugs":{"url":"https://github.com/bockit/simple-router/issues"},"license":"BSD-3-Clause","readmeFilename":"README.md"}