{"_id":"@booli/named-routes","_rev":"21-f3b8784999892393db2c3057e5c3600f","name":"@booli/named-routes","description":"Register and work with route functions instead of hardcoded strings. Translates a url string with placeholder params to a path with injected params.","dist-tags":{"latest":"1.1.2"},"versions":{"1.0.1":{"name":"@booli/named-routes","version":"1.0.1","description":"Register and work with route functions instead of hardcoded strings. Translates a url string with placeholder params to a path with injected params.","repository":{"type":"git","url":"https://git.booli.se/open-source/booli-common.git"},"main":"dist/index.js","author":{"name":"Booli Search Technologies AB"},"license":"MIT","publishConfig":{"access":"public"},"_id":"@booli/named-routes@1.0.1","_npmVersion":"5.4.2","_nodeVersion":"8.7.0","_npmUser":{"name":"marcusmalmberg","email":"marcus.j.malmberg@gmail.com"},"dist":{"integrity":"sha512-8XnOcVfNxV1hK0aZHr/rG0cZl/NZJACT8agkcpY5JcjDMy+CdPL9juHjheTZ1F3t9Gd1USNoBbtbHh+YKt32qg==","shasum":"4f182db35278c7e7fa0e85a322ad4c96f0744db7","tarball":"https://registry.npmjs.org/@booli/named-routes/-/named-routes-1.0.1.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDq3vPLpPbO9MH7u+RcWFrkRW1+E/gBHx1EWksSFCi4LQIgXj5g1dMT2BtpXSBorQxYj+jEodjKc5JLyMXUDNIsc0E="}]},"maintainers":[{"name":"marcusmalmberg","email":"marcus.j.malmberg@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/named-routes-1.0.1.tgz_1512734641884_0.2643144375178963"},"directories":{}},"1.0.2":{"name":"@booli/named-routes","version":"1.0.2","description":"Register and work with route functions instead of hardcoded strings. Translates a url string with placeholder params to a path with injected params.","repository":{"type":"git","url":"https://git.booli.se/open-source/booli-common.git"},"main":"dist/index.js","author":{"name":"Booli Search Technologies AB"},"license":"MIT","publishConfig":{"access":"public"},"_id":"@booli/named-routes@1.0.2","_npmVersion":"5.4.2","_nodeVersion":"8.7.0","_npmUser":{"name":"marcusmalmberg","email":"marcus.j.malmberg@gmail.com"},"dist":{"integrity":"sha512-YrchBcfzddCL2As6q82EgHklj//XGc57/up+tjZp43GeUldzsGsohnGaKtgSlhjZSXg5cnINbyOUSjjYVbmJqg==","shasum":"80717eea4ac603e0d87b2963903424aab603dc3d","tarball":"https://registry.npmjs.org/@booli/named-routes/-/named-routes-1.0.2.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDsHZTaPMwHUO5B5sNm5q706NOVymuHlE1MQA/AovhmfgIhAISMeF0APwlQlBnBwkYvz9UMzV7icvpD9TYrZIocmVKg"}]},"maintainers":[{"name":"marcusmalmberg","email":"marcus.j.malmberg@gmail.com"},{"name":"claudijo_booli","email":"claudijo.borovic@booli.se"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/named-routes-1.0.2.tgz_1512747373964_0.19516689935699105"},"directories":{}},"1.1.0":{"name":"@booli/named-routes","version":"1.1.0","description":"Register and work with route functions instead of hardcoded strings. Translates a url string with placeholder params to a path with injected params.","repository":{"type":"git","url":"https://git.booli.se/open-source/booli-common.git"},"main":"dist/index.js","author":{"name":"Booli Search Technologies AB"},"license":"MIT","publishConfig":{"access":"public"},"gitHead":"bf72ec46b990be272834c962283c93e11d6565d6","_id":"@booli/named-routes@1.1.0","_nodeVersion":"12.14.1","_npmVersion":"lerna/3.20.2/node@v12.14.1+x64 (darwin)","dist":{"integrity":"sha512-p3h/w/fZZLgJPgzAHcEZSMVwkRgBeIPtCd1M3fpH4Ib5aIiHa2Qc09hvvCmUcgVSsOdaAH1KOwm+DIFlEF8SQw==","shasum":"e58deb79a961d4a8aef2215f9ef17c829f3bea15","tarball":"https://registry.npmjs.org/@booli/named-routes/-/named-routes-1.1.0.tgz","fileCount":6,"unpackedSize":11630,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJes/byCRA9TVsSAnZWagAAy7kP/0TT1+wdbxJ+En+oqecc\ngvQXg72RhX9VFki8T5mcyhAAC6vrJxwjawItw8t+9wnwIbtBpabiRnKKlcob\nvBWXTl7O3bxVGOnkVokLXye4s4ygDVIrbCwAspF373iWvgETuabbdbENQf0i\nTHlEHP7QVywCk/BAcu6G0FnIwXbExKEFJyvm9AT2NY1WwxbY87Yn9Jz1R1WS\nQ6Pf993VYXXJSZH/TAvAoDvLxLkot0QUzF3tT/8RbP5Rbzqi3vKENfEnkZIx\niVrNlC5NBxs11UWUPYrHQGVvVmbtUM/mMSqlNuAAm0Qg9GVMwLuWzV6WN4W5\nccKMAWBpWRTAkghTZS1y//oRyhnwz0aFZCXBCev5AsBAnCQgq9KRIUSPDy0X\nkq8hl/Fy0MHA3FfVY1BqjYlMUajeBMDUuNQBVWR/qpdC/bdmYCXn23J5s2mb\nQr1FO8hswhZ/RfL11j9Mn6izO1KOjlzMi4TMH4pUpnobK4IiBiVi5N1zAck/\nPjf4fJcpzG9E0VWt6FsO69yYA5Z8MM4DX4EqnhQT7ixPqZKV0xR+oH23JKFP\nNEa/jaMLfMII8qNf6Z9xRCClBoc1A00zT9xspVXqT5SePnQIR8tW+2VQASCX\nWpbLceTA/ISlfQBUywMf22xIuyttSbH3yg35U5tuYObW2atGufuzbC3xQaeu\nvInr\r\n=TJPU\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDflf0KEriS2dALm1KOZO09iR3lZQ2L9ZADei9dw/Wv9AIgHT0HPTUxOzVqIy4XgcMpaxxn6zAEaH8ul8EhS8oqMB4="}]},"maintainers":[{"email":"alexander.bergstrom@booli.se","name":"booli.alexander"},{"email":"claudijo.borovic@booli.se","name":"claudijo_booli"},{"email":"flpchrsn@gmail.com","name":"filipchr"},{"email":"linus.eriksson@booli.se","name":"lers"},{"email":"marcus.j.malmberg@gmail.com","name":"marcusmalmberg"},{"email":"mickehalen@gmail.com","name":"mickehalen"},{"email":"hello@johanwest.com","name":"mrwest808"},{"email":"patrik.soderberg@booli.se","name":"paso"}],"_npmUser":{"name":"marcusmalmberg","email":"marcus.j.malmberg@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/named-routes_1.1.0_1588852466032_0.3581125906935212"},"_hasShrinkwrap":false,"deprecated":"Broken build, fixed in next version"},"1.1.1":{"name":"@booli/named-routes","version":"1.1.1","description":"Register and work with route functions instead of hardcoded strings. Translates a url string with placeholder params to a path with injected params.","repository":{"type":"git","url":"https://git.booli.se/open-source/booli-common.git"},"main":"dist/index.js","author":{"name":"Booli Search Technologies AB"},"license":"MIT","publishConfig":{"access":"public"},"gitHead":"6513ca60f554c022d20898ad7cbc6a6cf83f6e60","_id":"@booli/named-routes@1.1.1","_nodeVersion":"12.14.1","_npmVersion":"lerna/3.20.2/node@v12.14.1+x64 (darwin)","dist":{"integrity":"sha512-ZVzoAmxnmIvMJ0ARYSLMjaUvfF5XZLRSfziMtIgnVbdkos6pMnlnDjNJsjistYDIObpaKiOZmulfcmyztyd1XA==","shasum":"30c21f45dd452d1b3faa7a598a816200da0515f3","tarball":"https://registry.npmjs.org/@booli/named-routes/-/named-routes-1.1.1.tgz","fileCount":6,"unpackedSize":12150,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJetBgWCRA9TVsSAnZWagAAgWEP/2XNuQEyQ2GMoc+/l3hX\nJRBINMgtLgs61pd2U4kTRMGi7rLd9VtT/X8l34/LKjncERLRDMsndVoO44Fl\nmsuY0PeehNH3OqSkR7s5+6Bwgam5Z+z712kOflUb65riPSFcoqkpprsJjuqq\nMGv6G3GIbVysUkPFrRR5prYWRLoI16Mu+xr7gYHJF7VwAwEhfcbdEr5++sz6\nqynDqbQ17tOcAmm/RUYhb3UCDgyQCMvsxIYqtYuS3EcuN0SNz8V3040NEXld\n05uPN6DPWox4Dwt58l86Sda24qYynV4K4yGXP+Zz5X+949XDYFu1zCP/suBF\nsD/u8Qy3ALqvpDvOe1Kl+0nMDTPDMADvkSMRjIqEeiQqI0iQhTAOUjWPPind\nACdogqtdca25yXDXfyBpUzhVSIjimX3ogNNMg3EbGRKmOs/18ZF9IZg1zAmZ\nmdLCU/2DhSbU5CzPZK1iNqmBv0h4n40+4RLJ1RCsijaRrr4pIKiObcYeQM/i\nO7tAqEpzOgygsNkoAs5rLj8PKlPTX5jdgYc89V4H+1a2Su2gqdwBaAIP239T\nxvEOsMyR+LRZ9D/A1SXpTPrzo2l+ds9rVWb9O1/7yx4PDcZSrN3NbdvsUm8V\n3UsQ6wtPmwlTeAVmH3R+FKy4VXYN3D3b4zLnlGpFR/1QswPMeHRYe+W4WCeO\nJ7Xo\r\n=a3s/\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBe25Br+DNk+XX4H/QB5dbsgw5OzuqSv+TC2SbtdRHOFAiANE39dpnlaZM3BFb/k2nlYoesyZiehcMm/AOmlZBWzmA=="}]},"maintainers":[{"email":"alexander.bergstrom@booli.se","name":"booli.alexander"},{"email":"claudijo.borovic@booli.se","name":"claudijo_booli"},{"email":"flpchrsn@gmail.com","name":"filipchr"},{"email":"linus.eriksson@booli.se","name":"lers"},{"email":"marcus.j.malmberg@gmail.com","name":"marcusmalmberg"},{"email":"mickehalen@gmail.com","name":"mickehalen"},{"email":"hello@johanwest.com","name":"mrwest808"},{"email":"patrik.soderberg@booli.se","name":"paso"}],"_npmUser":{"name":"marcusmalmberg","email":"marcus.j.malmberg@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/named-routes_1.1.1_1588860950266_0.02680425295523503"},"_hasShrinkwrap":false},"1.1.2":{"name":"@booli/named-routes","version":"1.1.2","description":"Register and work with route functions instead of hardcoded strings. Translates a url string with placeholder params to a path with injected params.","repository":{"type":"git","url":"https://git.booli.se/open-source/booli-common.git"},"main":"dist/index.js","author":{"name":"Booli Search Technologies AB"},"license":"MIT","publishConfig":{"access":"public"},"gitHead":"18dd273e994c305ae72759740cd4cee95172f8ab","_id":"@booli/named-routes@1.1.2","_nodeVersion":"10.19.0","_npmVersion":"lerna/3.20.2/node@v10.19.0+x64 (darwin)","dist":{"integrity":"sha512-IMDoxja6+za+dMVTxalObNLhBfeS/TJa2afs5S79Kb9kbkPRqfKp10RPSZ5JRBlr4AJPBzrbmhGm4QwESCXaNA==","shasum":"30e8c3f1c62610544d9a20eea491c68e0e57a959","tarball":"https://registry.npmjs.org/@booli/named-routes/-/named-routes-1.1.2.tgz","fileCount":6,"unpackedSize":12184,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJewmgUCRA9TVsSAnZWagAAuuQP/1ZqT5GoB9XQbtnbfbXn\ngCHTTGeZzivOM59OX4Q/t7dCgAfSq2EYTV0M+102wgHo5krw3XZ/E3d3kM3s\naV8MVe/ZPM4yLinRt2AdlwG+wer2UhajLn9qW2+e3tGTh6ZmbLb8ZhXG12AJ\n4AB7jwuik/3BR9SKL/qat3yHJ6+GEKFarrdQVJeV5YFc68SeQAon3Qwz67+w\nU+r+/1TmmrxuF7pfSle9B5AScKcFwJMWHEfkE2T66dfaTlz+YFE3wW3Lh2Uy\nudXtBL1MqufEIcfzngE4e6gcrS1TYYw4TP8Za3YR7UMmZGR4WkJ98lptfDQG\n1I4nJp/vCfX5jKzYY4alL0uWj+z7qlfHZIsojKMdIfVN8EKo7IglknGwTXAY\nzMm3BOh6EjlWS93kurwoBr1a09hWN6K67WaT8Lm920DfV1K53+HCYLDcRJvy\ntirq7q66ONDz0GrIdDdGGQ3vpQLSujiI6yx7kjPKLL+hKypfFtZVmHC+prsp\ndU4DizVOPXeCk4HGiQVI+diXDMK/WhngpG9oCYnVl/Mmrvu+qKwbKX6IVxK7\nDnK1JzilE6slvYtL4NfEH4y8wY8hAPtV951bEYa7uarks+EyVhMeSp1/rmik\ntImvLhLCOR01ViCCw++wFeBpFL4tcOZ50UhoZQ+c+LsqtP5I+p7Ej8vFFvMT\nCp7v\r\n=VQOQ\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDCp0BPqahH6KwLiUpv18/214zS2eeNjEoAurLCDQ7S7gIhAL1IDOAWdBSzuZvX2UfmNCPo10Roav18xbY40nmMO8qs"}]},"maintainers":[{"email":"alexander.bergstrom@booli.se","name":"booli.alexander"},{"email":"claudijo.borovic@booli.se","name":"claudijo_booli"},{"email":"flpchrsn@gmail.com","name":"filipchr"},{"email":"linus.eriksson@booli.se","name":"lers"},{"email":"marcus.j.malmberg@gmail.com","name":"marcusmalmberg"},{"email":"mickehalen@gmail.com","name":"mickehalen"},{"email":"hello@johanwest.com","name":"mrwest808"},{"email":"patrik.soderberg@booli.se","name":"paso"}],"_npmUser":{"name":"booli.alexander","email":"alexander.bergstrom@booli.se"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/named-routes_1.1.2_1589798931789_0.6473480625136472"},"_hasShrinkwrap":false}},"readme":"# Named Routes\n\nHelper to handle routes in your project. \n\n## Required polyfills\n\nNone\n\n## Motivation\n\nInstead of using hardcoded strings as URLs in your code base you can use NamedRoutes. \nThis will give you both centralized way to define routes and a simple way to \ninterpolate params into the URL.\n\nA few benefits are:\n\n- If you ever need to change a path it's a simple matter of changing it in the definition and all paths throughout the project will be updated.\n- You can easily get an overview of all available routes in your project (using `export()`)\n- You don't need to do string interpolation when you create links, the lib will handle all the magic\n\n## Usage\n\nRegister and use paths:\n\n```js\nimport NamedRoutes from '@booli/named-routes'\n\nconst namedRoutes = new NamedRoutes()\nconst routes = namedRoutes.register({\n  users_path: '/users/',\n  user_path: '/users/:id/',\n})\n\nroutes.users_path()  // => '/users/'\nroutes.user_path(20) // => '/users/20/'\n```\n\nA common use case is to define the routes in a module which exports the routes, then they can easily be imported and used throughout the project.\n\n```js\n// routes.js\nconst namedRoutes = new NamedRoutes()\nconst Routes = namedRoutes.register({\n  users_path: '/users/',\n  user_path: '/users/:id/',\n})\n\nexport default Routes\n```\n\n```js\nimport Routes from '../routes'\n\n// Use in the router\n<Switch>\n  <Route path={Routes.user_path()} ... />\n  <Route path={Routes.users_path()} ... />\n</Switch>\n\n// Use when creating links\n<Link to={Routes.users_path()}>Users</Link>\n<Link to={Routes.user_path(42)}>User 42</Link>\n```\n\n## Route translation details\n\nPaths including params (eg. `user/:id/`) will be translated from left to right. Any params that have not been translated will remain in the output, and any extra arguments passed to the function will be ignored.\n\n```js\nconst routes = namedRoutes.register({\n  user_path: '/:one/:two/'\n})\n\nuser_path()        // => /:one/:two/\nuser_path(1)       // => /1/:two/\nuser_path(1, 2)    // => /1/2/\nuser_path(1, 2, 3) // => /1/2/\n```\n\nThis is also useful when used in react-router, since the router uses the colon pattern for path parameters.\n\n## Export available routes\n\nSometimes it's useful to see which routes are available. Calling the export function will give you a list of pairs including all route names with the corresponding raw path.\n\n```js\nimport NamedRoutes from '@booli/named-routes'\n\nconst namedRoutes = new NamedRoutes()\nconst routes = namedRoutes.register({\n  users_path: '/users/',\n  user_path: '/users/:id/',\n})\n\nnamedRoutes.export() // => \n  // [\n  //   [\"users_path\", \"/users/\"], \n  //   [\"user_path\", \"/users/:id/\"]\n  // ]\n```\n","maintainers":[{"email":"ludde@ludde.net","name":"eddul"},{"email":"hello@johanwest.com","name":"mrwest808"},{"email":"linus.eriksson@booli.se","name":"lers"},{"email":"marcus.j.malmberg@gmail.com","name":"marcusmalmberg"},{"email":"flpchrsn@gmail.com","name":"filipchr"},{"email":"mickehalen@gmail.com","name":"mickehalen"},{"email":"linus.velin@booli.se","name":"linusvelin"}],"time":{"modified":"2022-04-04T20:07:59.759Z","created":"2017-12-08T12:04:03.153Z","1.0.1":"2017-12-08T12:04:03.153Z","1.0.2":"2017-12-08T15:36:14.043Z","1.1.0":"2020-05-07T11:54:26.157Z","1.1.1":"2020-05-07T14:15:50.376Z","1.1.2":"2020-05-18T10:48:51.898Z"},"repository":{"type":"git","url":"https://git.booli.se/open-source/booli-common.git"},"author":{"name":"Booli Search Technologies AB"},"license":"MIT","readmeFilename":"README.md"}