{"_id":"odino.router","_rev":"31-b8134ae6b3b3761b0e638c8ebfe925b0","name":"odino.router","description":"An HTTP router","dist-tags":{"latest":"0.1.1"},"versions":{"0.0.1":{"name":"odino.router","version":"0.0.1","description":"An HTTP router","main":"./lib/router","author":{"name":"odino","email":"alessandro.nadalin@gmail.com"},"license":"MIT","dependencies":{"underscore":"~1.5","underscore.string":"~2.0"},"devDependencies":{"mocha":"~1.0","should":"~2.0"},"readme":"# odino-router\n\nA very simple and lightweight HTTP router.\n\n## Usage\n\n```\nvar router = require('./odino.router');\nrouter.routes.push({\n    path: '/hello/:what'\n});\n\nvar route = router.resolve('/hello/world', request);\n\nconsole.log(route.parameters.what);\n```","readmeFilename":"README.md","_id":"odino.router@0.0.1","dist":{"shasum":"b1234b40be0287dcd41aeff8c03622b8fe30d83f","tarball":"https://registry.npmjs.org/odino.router/-/odino.router-0.0.1.tgz","integrity":"sha512-TgW+rdz9o4miz0Vb+NVAzIy7uN+F6Pqagw93nk/Skuw3wsiH67TkHllD4xwLF+U+OfmUgvssqrKU5MfzihPBIg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBsSrFgGC2CPKAyPexnDYizQ9U9sZDVPunQgaGA5u1aeAiAkFcOe+BiBBXDI7utjVaDlpxVbtFaT3NqV6wpksBedAg=="}]},"_from":".","_npmVersion":"1.3.14","_npmUser":{"name":"odino","email":"alessandro.nadalin@gmail.com"},"maintainers":[{"name":"odino","email":"alessandro.nadalin@gmail.com"}],"directories":{}},"0.0.2":{"name":"odino.router","version":"0.0.2","description":"An HTTP router","main":"./lib/router","author":{"name":"odino","email":"alessandro.nadalin@gmail.com"},"license":"MIT","dependencies":{"underscore":"~1.5","underscore.string":"~2.0"},"devDependencies":{"mocha":"~1.0","should":"~2.0"},"readme":"# odino-router\n\nA very simple and lightweight HTTP router.\n\n## Usage\n\n```\nvar router = require('./odino.router');\nrouter.routes.push({\n    path: '/hello/:what'\n});\n\nvar route = router.resolve('/hello/world', request);\n\nconsole.log(route.parameters.what);\n```\n\n## Declaring routes\n\nA route is a plain object with a few properties:\n\n* `pattern`, which defines the pattern that the path info of the request needs to match (it is the **only mandatory** property)\n* `methods`, which defines which [HTTP methods](http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html) are\nsupported by the route\n* `host`, which defines the host supported by the route\n\nFor example, this is  a very simple route:\n\n```\nvar route = {\n    pattern: '/example.com'\n};\n```\n\nwhich matches the following requests:\n\n* `GET /example.com`\n* `POST /example.com`\n* `PUT /example.com`\n\n## Routing by HTTP method\n\nBy adding some methods, we restrict the possible matches:\n\n```\nroute.methods = [\"GET\", \"HEAD\"];\n```\n\nNow our route will only match:\n\n* `GET /example.com`\n* `HEAD /example.com`\n\n## Routing by host\n\nSuppose you have an application running on multiple hosts (`api.example.org` and `example.org`), you can\ndefine routes which will be only matched when the request is against one of the hosts:\n\n```\nroute.host = \"api.example.org\";\n```\n\n## Tests\n\nThis library is somehow tested using mocha: after an `npm install` you can simply run `mocha` (or its verbose cousin\n`./node_modules/mocha/bin/mocha`).","readmeFilename":"README.md","_id":"odino.router@0.0.2","dist":{"shasum":"f24d9d73eed12fc6c2c3ab74516daa5cc79873c9","tarball":"https://registry.npmjs.org/odino.router/-/odino.router-0.0.2.tgz","integrity":"sha512-7LDL+WG2SppdX2eFS4ljbXpm51d1p6h1WeVMPaqTFsL714TswGnLMG6DkARTOepBiXBR8ZQ5Bi+58TwjyIK3/A==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEpVIcUSyVr4KDICRroPOCJ0P4jMZ1fbjbeUGU8BC1I0AiAID7f9I5F+E0yhyXtoDC9s2kNrUT6gqsz4zz0omCj8Bg=="}]},"_from":".","_npmVersion":"1.3.14","_npmUser":{"name":"odino","email":"alessandro.nadalin@gmail.com"},"maintainers":[{"name":"odino","email":"alessandro.nadalin@gmail.com"}],"directories":{}},"0.0.3":{"name":"odino.router","version":"0.0.3","description":"An HTTP router","main":"./lib/router","author":{"name":"odino","email":"alessandro.nadalin@gmail.com"},"license":"MIT","dependencies":{"underscore":"~1.5","underscore.string":"~2.0"},"devDependencies":{"mocha":"~1.0","should":"~2.0"},"readme":"# odino.router\n\nA very simple and lightweight HTTP router.\n\n## Usage\n\n```\nvar router = require('./odino.router');\nrouter.routes.push({\n    path: '/hello/:what'\n});\n\nvar route = router.resolve('/hello/world', request);\n\nconsole.log(route.parameters.what); // world\n```\n\n## Declaring routes\n\nA route is a plain object with a few properties:\n\n* `pattern`, which defines the pattern that the path info of the request needs to match (it is the **only mandatory** property)\n* `methods`, which defines which [HTTP methods](http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html) are\nsupported by the route\n* `host`, which defines the host supported by the route\n\nFor example, this is  a very simple route:\n\n```\nvar route = {\n    pattern: '/example.com'\n};\n```\n\nwhich matches the following requests:\n\n* `GET /example.com`\n* `POST /example.com`\n* `PUT /example.com`\n\n## Routing by HTTP method\n\nBy adding some methods, we restrict the possible matches:\n\n```\nroute.methods = [\"GET\", \"HEAD\"];\n```\n\nNow our route will only match:\n\n* `GET /example.com`\n* `HEAD /example.com`\n\n## Routing by host\n\nSuppose you have an application running on multiple hosts (`api.example.org` and `example.org`), you can\ndefine routes which will be only matched when the request is against one of the hosts:\n\n```\nroute.host = \"api.example.org\";\n```\n\n## Tests\n\nThis library is somehow tested using mocha: after an `npm install` you can simply run `mocha` (or its verbose cousin\n`./node_modules/mocha/bin/mocha`).","readmeFilename":"README.md","_id":"odino.router@0.0.3","dist":{"shasum":"a34d267dc43b6130fbeebe3c812915ae9ab0099d","tarball":"https://registry.npmjs.org/odino.router/-/odino.router-0.0.3.tgz","integrity":"sha512-8aJnFSZZr7IdeaCgNHurGoqTibZ9KAmYpPHXMpXSLUynlR0RwBx21TqZIWxpaGXQz2CplXJXobXSnP4k4h3Vkw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCWHnrvREtIlfIPmMusCr+M3tYGzcOsvzoVcJkl9+lUHQIgWmPGxtJ6oyR5XnCIFjfsPIhmVGfHbx9OJ6pLS2NKsC8="}]},"_from":".","_npmVersion":"1.3.14","_npmUser":{"name":"odino","email":"alessandro.nadalin@gmail.com"},"maintainers":[{"name":"odino","email":"alessandro.nadalin@gmail.com"}],"directories":{}},"0.0.4":{"name":"odino.router","version":"0.0.4","description":"An HTTP router","main":"./lib/router","author":{"name":"odino","email":"alessandro.nadalin@gmail.com"},"license":"MIT","dependencies":{"underscore":"~1.5","underscore.string":"~2.0"},"devDependencies":{"mocha":"~1.0","should":"~2.0"},"readme":"# odino.router\n\nA very simple and lightweight HTTP router.\n\n## Usage\n\n```\nvar router = require('./odino.router');\nrouter.routes.push({\n    path: '/hello/:what'\n});\n\nvar route = router.resolve('/hello/world', request);\n\nconsole.log(route.parameters.what); // world\n```\n\n## Declaring routes\n\nA route is a plain object with a few properties:\n\n* `pattern`, which defines the pattern that the path info of the request needs to match (it is the **only mandatory** property)\n* `methods`, which defines which [HTTP methods](http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html) are\nsupported by the route\n* `host`, which defines the host supported by the route\n\nFor example, this is  a very simple route:\n\n```\nvar route = {\n    pattern: '/example.com'\n};\n```\n\nwhich matches the following requests:\n\n* `GET /example.com`\n* `POST /example.com`\n* `PUT /example.com`\n\n## Routing by HTTP method\n\nBy adding some methods, we restrict the possible matches:\n\n```\nroute.methods = [\"GET\", \"HEAD\"];\n```\n\nNow our route will only match:\n\n* `GET /example.com`\n* `HEAD /example.com`\n\n## Routing by host\n\nSuppose you have an application running on multiple hosts (`api.example.org` and `example.org`), you can\ndefine routes which will be only matched when the request is against one of the hosts:\n\n```\nroute.host = \"api.example.org\";\n```\n\n## Tests\n\nThis library is somehow tested using mocha: after an `npm install` you can simply run `mocha` (or its verbose cousin\n`./node_modules/mocha/bin/mocha`).","readmeFilename":"README.md","_id":"odino.router@0.0.4","dist":{"shasum":"51b5b9e28da72321276f1cf61de7fe39c71f5a3a","tarball":"https://registry.npmjs.org/odino.router/-/odino.router-0.0.4.tgz","integrity":"sha512-Cv1R+855UyOgBHIbc0Sy7vtVoOJMy903HDiV5a5FPns8VwKCiGJHZw/NDUFNnd1eRIffO8R+RO/nw1axOA+Yeg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBVP4+k+AcWErw3Ay21kxWibBhX7ykAuI59YxjLQzi8lAiBQvb4trsBfdq934CUZnLvhau0E0F+Jmt+jRVm5o+1SNg=="}]},"_from":".","_npmVersion":"1.3.14","_npmUser":{"name":"odino","email":"alessandro.nadalin@gmail.com"},"maintainers":[{"name":"odino","email":"alessandro.nadalin@gmail.com"}],"directories":{}},"0.1.0":{"name":"odino.router","version":"0.1.0","description":"An HTTP router","main":"./lib/router","author":{"name":"odino","email":"alessandro.nadalin@gmail.com"},"license":"MIT","dependencies":{"underscore":"~1.5","underscore.string":"~2","js-yaml":"~3"},"devDependencies":{"mocha":"~1.0","should":"~2.0"},"scripts":{"test":"./node_modules/mocha/bin/mocha"},"readme":"# odino.router\n\n[![NPM version](https://badge.fury.io/js/odino.router.png)](http://badge.fury.io/js/odino.router)\n[![Build Status](https://travis-ci.org/odino/odino.router.png?branch=travis-ci)](https://travis-ci.org/odino/odino.router)\n[![Dependency Status](https://gemnasium.com/odino/odino.router.png)](https://gemnasium.com/odino/odino.router)\n\nA very simple and lightweight HTTP router.\n\n## Usage\n\n```\nvar routes = {\n    example: {\n        path: '/hello/:what'\n    }\n};\nvar router = require('./odino.router');\n\nrouter.load(routes);\n\nvar route = router.resolve('/hello/world', request);\n\nconsole.log(route.parameters.what); // world\n```\n\n## Declaring routes\n\nA route is a plain object with a few properties:\n\n* `pattern`, which defines the pattern that the path info of the request needs to match (it is the **only mandatory**\nproperty and must be a string)\n* `methods`, which defines which [HTTP methods](http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html) are\nsupported by the route\n* `host`, which defines the host supported by the route\n\nFor example, this is  a very simple route:\n\n```\nvar route = {\n    pattern: '/example.com'\n};\n```\n\nwhich matches the following requests:\n\n* `GET /example.com`\n* `POST /example.com`\n* `PUT /example.com`\n\n## Routing by HTTP method\n\nBy adding some methods, we restrict the possible matches:\n\n```\nroute.methods = [\"GET\", \"HEAD\"];\n```\n\nNow our route will only match:\n\n* `GET /example.com`\n* `HEAD /example.com`\n\n## Routing by host\n\nSuppose you have an application running on multiple hosts (`api.example.org` and `example.org`), you can\ndefine routes which will be only matched when the request is against one of the hosts:\n\n```\nroute.host = \"api.example.org\";\n```\n\n## Loading routes\n\nYou have 3 ways to load routes into your router, and all of them serve for a specific purpose:\n\n### Direct loading\n\nYou can **directly set the routes object** when you want to reset the current routes:\n\n```\nvar myFirstRoutes = {\n    example: {\n        pattern: '/hello/:what'\n    }\n};\n\nrouter.load(myFirstRoutes)\n\n// oh sheez, we made a mistake!\n\nvar mySecondRoutes = {\n    example2: {\n        pattern: '/hello2/:what'\n    }\n};\n\nrouter.routes = myRoutes;\n\nconsole.log(router.routes) // mySecondRoutes\n```\n\nSince you are directly overriding the route objects, this method makes sure that all the previous routes go to hell :)\n\n### Loading routes on-the-fly\n\nIn the context of a web application, you might want to provide dynamic routes by adding or removing routes on-the-fly:\nyou can achieve this by using the `#load()` method, which takes an object as its argument:\n\n```\nvar myFirstRoutes = {\n    example: {\n        pattern: '/hello/:what'\n    }\n};\n\nrouter.load(myFirstRoutes)\n\n// some logic\n\nvar mySecondRoutes = {\n    example2: {\n        pattern: '/hello2/:what'\n    }\n};\n\nrouter.load(mySecondRoutes)\n\nconsole.log(router.routes) // an object containing routes from both myFirstRoutes and mySecondRoutes\n```\n\n### Config file\n\nWhen you have to clean up the mess, it's better to then use a simple configuration file for your routes:\n\n```\nexample:\n  pattern: \"/hello/:what\"\nexample2:\n  pattern: \"/hello2/:what\"\n```\n\nand load it with the router itself:\n\n```\nrouter.loadFromFile('./path/to/my/routes.yml');\n```\n\nInternally, this method uses the `#load()` method after converting the YML content in a JS object.\n\n## Tests\n\nThis library is somehow tested using mocha: after an `npm install` you can simply run `mocha` (or its verbose cousin\n`./node_modules/mocha/bin/mocha`).","readmeFilename":"README.md","_id":"odino.router@0.1.0","dist":{"shasum":"ab439a26fa11c2419f776ca4aa2205d9b3dc4b4f","tarball":"https://registry.npmjs.org/odino.router/-/odino.router-0.1.0.tgz","integrity":"sha512-PHJPEtCejCn+nXreng9y4N6bcG7ojG+6d3yQkkkeZENwBTarvMmMQaMe35wb26NNuwpCs5aUYUUYoWjeVphAUA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBYZKD8VfOnRRQ39UiKHYUqLlcbwGlWbvu10WNGgIFDHAiEA6Af6FwSWuZtOqRO0KqqUmKn131sq91WoJpNGLvZeXWE="}]},"_from":".","_npmVersion":"1.3.14","_npmUser":{"name":"odino","email":"alessandro.nadalin@gmail.com"},"maintainers":[{"name":"odino","email":"alessandro.nadalin@gmail.com"}],"directories":{}},"0.1.1":{"name":"odino.router","version":"0.1.1","description":"An HTTP router","homepage":"https://github.com/odino/odino.router","repository":{"type":"git","url":"http://github.com/odino/odino.router.git"},"keywords":["router","route","http","url","urls","https"],"main":"./lib/router","author":{"name":"odino","email":"alessandro.nadalin@gmail.com"},"license":"MIT","dependencies":{"underscore":"~1.5","underscore.string":"~2","js-yaml":"~3"},"devDependencies":{"mocha":"~1.0","should":"~2.0"},"scripts":{"test":"./node_modules/mocha/bin/mocha"},"readme":"# odino.router\n\n[![NPM version](https://badge.fury.io/js/odino.router.png)](http://badge.fury.io/js/odino.router)\n[![Build Status](https://travis-ci.org/odino/odino.router.png?branch=travis-ci)](https://travis-ci.org/odino/odino.router)\n[![Dependency Status](https://gemnasium.com/odino/odino.router.png)](https://gemnasium.com/odino/odino.router)\n\nA very simple and lightweight HTTP router.\n\n## Usage\n\n```\nvar routes = {\n    example: {\n        path: '/hello/:what'\n    }\n};\nvar router = require('./odino.router');\n\nrouter.load(routes);\n\nvar route = router.resolve('/hello/world', request);\n\nconsole.log(route.parameters.what); // world\n\nvar myRoute = router.generate('example', { what: 'wait' });\n\nconsole.log(myRoute); // '/hello/wait'\n```\n\n## Declaring routes\n\nA route is a plain object with a few properties:\n\n* `pattern`, which defines the pattern that the path info of the request needs to match (it is the **only mandatory**\nproperty and must be a string)\n* `methods`, which defines which [HTTP methods](http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html) are\nsupported by the route\n* `host`, which defines the host supported by the route\n\nFor example, this is  a very simple route:\n\n```\nvar route = {\n    pattern: '/example.com'\n};\n```\n\nwhich matches the following requests:\n\n* `GET /example.com`\n* `POST /example.com`\n* `PUT /example.com`\n\n## Routing by HTTP method\n\nBy adding some methods, we restrict the possible matches:\n\n```\nroute.methods = [\"GET\", \"HEAD\"];\n```\n\nNow our route will only match:\n\n* `GET /example.com`\n* `HEAD /example.com`\n\n## Routing by host\n\nSuppose you have an application running on multiple hosts (`api.example.org` and `example.org`), you can\ndefine routes which will be only matched when the request is against one of the hosts:\n\n```\nroute.host = \"api.example.org\";\n```\n\n## Loading routes\n\nYou have 3 ways to load routes into your router, and all of them serve for a specific purpose:\n\n### Direct loading\n\nYou can **directly set the routes object** when you want to reset the current routes:\n\n```\nvar myFirstRoutes = {\n    example: {\n        pattern: '/hello/:what'\n    }\n};\n\nrouter.load(myFirstRoutes)\n\n// oh sheez, we made a mistake!\n\nvar mySecondRoutes = {\n    example2: {\n        pattern: '/hello2/:what'\n    }\n};\n\nrouter.routes = myRoutes;\n\nconsole.log(router.routes) // mySecondRoutes\n```\n\nSince you are directly overriding the route objects, this method makes sure that all the previous routes go to hell :)\n\n### Loading routes on-the-fly\n\nIn the context of a web application, you might want to provide dynamic routes by adding or removing routes on-the-fly:\nyou can achieve this by using the `#load()` method, which takes an object as its argument:\n\n```\nvar myFirstRoutes = {\n    example: {\n        pattern: '/hello/:what'\n    }\n};\n\nrouter.load(myFirstRoutes)\n\n// some logic\n\nvar mySecondRoutes = {\n    example2: {\n        pattern: '/hello2/:what'\n    }\n};\n\nrouter.load(mySecondRoutes)\n\nconsole.log(router.routes) // an object containing routes from both myFirstRoutes and mySecondRoutes\n```\n\n### Config file\n\nWhen you have to clean up the mess, it's better to then use a simple configuration file for your routes:\n\n```\nexample:\n  pattern: \"/hello/:what\"\nexample2:\n  pattern: \"/hello2/:what\"\n```\n\nand load it with the router itself:\n\n```\nrouter.loadFromFile('./path/to/my/routes.yml');\n```\n\nInternally, this method uses the `#load()` method after converting the YML content in a JS object.\n\n## Generating routes\n\nYou can use the router to **generate links** and valid routes by simply calling the `generate` method, specifying which\nroute you want to generate and with which parameters:\n\n```\n// suppose you have the route 'test' => /hello/:name/:lastname in your config\n\nvar route = router.generate('test', { name: 'john', lastname: 'calipari' });\n\nconsole.log(route); // '/hello/john/calipari'\n```\n\n## Tests\n\nThis library is somehow tested using mocha: after an `npm install` you can simply run `mocha` (or its verbose cousin\n`./node_modules/mocha/bin/mocha`).","readmeFilename":"README.md","bugs":{"url":"https://github.com/odino/odino.router/issues"},"_id":"odino.router@0.1.1","dist":{"shasum":"faf7b2e5e58fc841d84ba2a5a1a0f02a4d8fb55d","tarball":"https://registry.npmjs.org/odino.router/-/odino.router-0.1.1.tgz","integrity":"sha512-Uh3jGIkIW3zWscD8DpL87Sz7egI0O0ngh1+mqB0cQEwN5TO1nOq+0dtQ+cRcu8rWL9vRi0qUVFyvdkuHeQwihw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCDekS1mIafA8dhaDnOVhvhu7SIBoYcOnidAW8RrBN+bAIhAJFH5h4zI1ewsWtBKpOA7gYgwnPQaAXOqzRc15W3r3op"}]},"_from":".","_npmVersion":"1.3.14","_npmUser":{"name":"odino","email":"alessandro.nadalin@gmail.com"},"maintainers":[{"name":"odino","email":"alessandro.nadalin@gmail.com"}]}},"readme":"# odino-router\n\nA very simple and lightweight HTTP router.\n\n## Usage\n\n```\nvar router = require('./odino.router');\nrouter.routes.push({\n    path: '/hello/:what'\n});\n\nvar route = router.resolve('/hello/world', request);\n\nconsole.log(route.parameters.what);\n```","maintainers":[{"name":"odino","email":"alessandro.nadalin@gmail.com"}],"time":{"modified":"2022-06-22T19:08:38.076Z","created":"2014-01-03T14:38:02.435Z","0.0.1":"2014-01-03T14:38:04.800Z","0.0.2":"2014-01-03T15:27:19.549Z","0.0.3":"2014-01-03T15:36:32.336Z","0.0.4":"2014-01-03T15:50:20.945Z","0.1.0":"2014-01-04T13:48:38.148Z","0.1.1":"2014-01-05T19:06:37.875Z"},"author":{"name":"odino","email":"alessandro.nadalin@gmail.com"},"repository":{"type":"git","url":"http://github.com/odino/odino.router.git"}}