{"_id":"@colucom/osseus-router","_rev":"7-ead1b9c18786d62dce59c4e042e6e2a5","name":"@colucom/osseus-router","dist-tags":{"latest":"0.4.1"},"versions":{"0.4.0":{"name":"@colucom/osseus-router","version":"0.4.0","description":"Osseus Router","scripts":{"build":"npm install","test":"standard"},"main":"index.js","repository":{"type":"git","url":"git+https://github.com/colucom/osseus-router.git"},"author":{"name":"LiorRabin"},"license":"MIT","devDependencies":{"standard":"^11.0.1"},"dependencies":{"json-routing-for-osseus":"^4.0.2"},"gitHead":"743245b1e7c263d9b1c09953c3002eeb3fb9c725","bugs":{"url":"https://github.com/colucom/osseus-router/issues"},"homepage":"https://github.com/colucom/osseus-router#readme","_id":"@colucom/osseus-router@0.4.0","_npmVersion":"6.4.1","_nodeVersion":"8.9.3","_npmUser":{"name":"liorrabin","email":"lior9586@gmail.com"},"dist":{"integrity":"sha512-QLlYHEIi8GXiMf38P026B3mbwM+l0zbiztXYXLCA3qwYI02V7xiZiPxG9vpzQmufDZRgkrDOcJEY8wnvCSG//w==","shasum":"44dc7f9d50657cc86d0338a7e6c85e70443e5a64","tarball":"https://registry.npmjs.org/@colucom/osseus-router/-/osseus-router-0.4.0.tgz","fileCount":9,"unpackedSize":9953,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbrM0cCRA9TVsSAnZWagAAZVQP/2zLs+ucUwaoB5DDMzq/\n3jq7Wb3sDD0QGM5b1ne7q570bHt83uRgny2QmJrnXAoifjkoTZdAp96MtZQV\n3DmQNEZXj7CGMRTAQeCN9KD9rsZddXTGW0bYbGzDiY3FwJA0/CkAPiJqs+OY\nncFZZOQGXg8UsstflEc9Exp6QhkR5k5S5YBd9jqBBCkYzPMx6k+HCTYFNIUZ\nUBnvVZin7n9UFVAQpcdcDYc7LybIgAkDEjU2pm2JbEoH8Ki6vdHkUhkque2J\nusMqscCTybcBtC5SbmBEr433TJuzTX/E9VdGQ6/W4XNvFaPHCTvZcJ5GeDdi\n4Tck0fLMJPa+B2o13JArHCWeguK6svpawKix2NsBjxBqsqEGpfh0aR1gNZ7W\nyMX/eRMr2UA8rZTxRUrkL0QqKchjBFd6jF6fIHyFtfbVaAiYEp1i5+g2bDW5\nP3MHU0pkRXUY9+nkq6GLgGDg4lsKvhApp+zbCzMMKkHLJfCo8ZzPGBUn91/P\nSLxc/+5y83OqxWcnvevMM3JC85oS6WbMgxhllT+bxVuVmelVeOeP5nRXBti+\nxwOVD/c6nYlWXNqavCoYvd5UW+GC7M3H+ip8vngvyvSLW2efCqMGaqoM91Vd\nUgH1ABzNXfbbmVV6P4I5vCLWHtDs6kfUc8pemzP9cbEgVYHr/F+FpvfEaV6P\nWxgy\r\n=VXVp\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCNquPWCYdrlJ5YKKb2lr7+ssIZ/wPer09dzoXJ6qCC8QIhAPw6VV5Ehe/8SGntl229ITty85Jo7bUSSCRMNtoPuDRJ"}]},"maintainers":[{"name":"grebenaha","email":"grebenakha@gmail.com"},{"name":"liorrabin","email":"lior9586@gmail.com"},{"name":"sapirshl","email":"sapir@colu.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/osseus-router_0.4.0_1538051355450_0.6534327973745011"},"_hasShrinkwrap":false},"0.4.1":{"name":"@colucom/osseus-router","version":"0.4.1","description":"Osseus Router","scripts":{"build":"npm install","test":"standard"},"main":"index.js","repository":{"type":"git","url":"git+https://github.com/colucom/osseus-router.git"},"author":{"name":"LiorRabin"},"license":"MIT","devDependencies":{"standard":"^11.0.1"},"dependencies":{"json-routing-for-osseus":"^4.0.2"},"gitHead":"a5c284b6ee2a8600ecc9ea8ef99dd5e77b449cdb","bugs":{"url":"https://github.com/colucom/osseus-router/issues"},"homepage":"https://github.com/colucom/osseus-router#readme","_id":"@colucom/osseus-router@0.4.1","_npmVersion":"5.4.2","_nodeVersion":"8.8.1","_npmUser":{"name":"grebenaha","email":"grebenakha@gmail.com"},"dist":{"integrity":"sha512-FXIFBOwdhRC/5Iq6+zGUakk9mxJRaNgVi7DyuIAP+euKL+nzw2Nf9ecweWqeiwJNFVmThpN5fLOjgkm9UO3bIA==","shasum":"f95800b5cd31f48c264e84652f6a8900fdbb46c5","tarball":"https://registry.npmjs.org/@colucom/osseus-router/-/osseus-router-0.4.1.tgz","fileCount":9,"unpackedSize":9953,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJb0FbDCRA9TVsSAnZWagAACuoP/3Xb21ONdahknlFlpRpI\nWcwcF3o0QVSqCxy+tgoJGQbgugUboruQ8zhjINAkR0t0xvEsT9dW8qHUXo0V\n0OP1IYFHDLi0bE0Idlm32YGhoOGGb7biyIeEl08DHFDrGbqOL4qbeaK23fgZ\nypsh2k0mNiuacoyGgyqWYwHHseysNrwAWJWeEhBLWv1W88MiLX2Bvs7p582I\nWuGdiX2kOek/c8Bs2c73dFJ+XypW0dVvouFm7OK54zheBMF+U33dzODY/cUn\nHfBCONnO1TegRrp9Wi6qL4V8g+N3pP2pz4/vBVss/lJ2rs2eClDTo7SrbuK0\nj98gRNg6sMWQcnMCXSgxMwd++R5p8voFrXMh7oGGVf5yecByALUNrtFpA53n\nSTl9MsVqaZz05if7wqfMsO4h9lovG4PwotshIb8g0DkeOwPN7SclzUIV1xbs\nYifnhMtBBzE0+Pt3DvdRzuAMYCqPHLau2AA3Q4qLkbHPnkTa55R7Ty04TvUx\nT023jWwhXZolVl0/FOazgfgoDDixOx+RhyliDU73G/JK3+pwOrSIg8eVzSml\n4UdAm1jkfAoHjoLMOFdCe+H0ub/blhZbZ+1afrhoSSkEMHj0Fr8U2wuo9V+b\ntEQq6PCEPCGj0Bg1IsCaHeXODnTtIBVaLC1aE5Jdj1fqYO32cKBtLYJf4WzX\nvRRv\r\n=lYnv\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEjHdalSu1Ngk0iMMt191R//QlDUALRxqbvZQ7K6Do0WAiBRlTe086Hd14bDWHua2yedB3A38R0LshUnhEMlX5u27g=="}]},"maintainers":[{"email":"grebenakha@gmail.com","name":"grebenaha"},{"email":"lior9586@gmail.com","name":"liorrabin"},{"email":"sapir@colu.com","name":"sapirshl"},{"email":"valery@colu.com","name":"valery-colu"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/osseus-router_0.4.1_1540380352357_0.9426818133085428"},"_hasShrinkwrap":false}},"time":{"created":"2018-09-27T12:29:15.355Z","0.4.0":"2018-09-27T12:29:15.543Z","modified":"2022-04-05T00:23:17.747Z","0.4.1":"2018-10-24T11:25:52.537Z"},"maintainers":[{"email":"lev.rotem@gmail.com","name":"rottev"},{"email":"eyal@colu.com","name":"quilamir"},{"email":"leonprou@gmail.com","name":"leonprou"},{"email":"valery@colu.com","name":"valery-colu"},{"email":"lior9586@gmail.com","name":"liorrabin"},{"email":"grebenakha@gmail.com","name":"grebenaha"}],"description":"Osseus Router","homepage":"https://github.com/colucom/osseus-router#readme","repository":{"type":"git","url":"git+https://github.com/colucom/osseus-router.git"},"author":{"name":"LiorRabin"},"bugs":{"url":"https://github.com/colucom/osseus-router/issues"},"license":"MIT","readme":"[![JavaScript Style Guide](https://cdn.rawgit.com/standard/standard/master/badge.svg)](https://github.com/standard/standard)\n\n# Osseus Router\n\n[JSON Routes (for osseus)](https://github.com/colucom/json-routing) based osseus module to work with [osseus-server](https://github.com/colucom/osseus-server)\n\n## Install\n```bash\n$ npm install @colucom/osseus-router\n```\n\n## Usage\n\n#### Configuration\n\nMandatory:\n\n* `OSSEUS_ROUTER_DEPENDENCIES`\n\t* Your application must use [osseus-server](https://github.com/colucom/osseus-server)\n\t* See osseus dependencies explanation [here](https://github.com/colucom/osseus#dependencies)\n\nOptional:\n\n* `OSSEUS_ROUTER_ROUTES_PATH`\n\t* the path to your routes folder\n\t* default is `./routes`\n* `OSSEUS_ROUTER_CONTROLLERS_PATH`\n\t* the path to your controllers folder\n\t* default is `./contollers`\n* `OSSEUS_ROUTER_POLICY_PATH`\n\t* the path to your policy (middlewares) folder\n\t* default is `./policy`\n* `OSSEUS_ROUTER_URL_PREFIX`\n\t* global prefix path for all routes\n* `OSSEUS_ROUTER_CONTROLLER_NAME_NO_UPPERCASE`\n  * set to `true` in order for contorller names not to begin with uppercase (which is the default)\n\n#### Example\n\n`/routes/examples.json`:\n\n```json\n{\n  \"/example\": {\n    \"GET\": {\n      \"policy\": \"global:firstPolicy\",\n      \"route\": \"exampleGET\"\n    },\n    \"POST\": {\n      \"policy\": [\n        \"global:firstPolicy\",\n        \"global:secondPolicy\"\n      ],\n      \"route\": \"./controllers/AnotherController:examplePOST\"\n    }\n  }\n}\n```\n\n***Note***\n\n*By default all routes in `/routes/example.json` are assumed to be in `/controllers/ExamplesController.js` but in case you want to use a route from another controller need to specify its location*\n\n`/policy/global.js`:\n\n```javascript\nmodule.exports = (osseus) => {\n  return {\n    firstPolicy: (req, res, next) => {\n      req.policies = req.policies || []\n      req.policies.push('firstPolicy')\n      next()\n    },\n    secondPolicy: (req, res, next) => {\n      req.policies = req.policies || []\n      req.policies.push('secondPolicy')\n      next()\n    }\n  }\n}\n```\n\n`/controllers/ExamplesController.js`:\n\n```javascript\nmodule.exports = (osseus) => {\n  return {\n    examplePOST: (req, res, next) => {\n      res.send({called: 'examplePOST', policies: req.policies})\n    }\n  }\n}\n```\n\n`/controllers/AnotherController.js`:\n\n```javascript\nmodule.exports = (osseus) => {\n  return {\n    examplePOST: (req, res, next) => {\n      res.send({called: 'examplePOST', policies: req.policies})\n    }\n  }\n}\n```\n\nRunning:\n\n```bash\n$ node index.js --OSSEUS_SERVER_PORT 8080\n```\n\nWill start your application and listen on 8080.\n\nNow, let's send some test requests and see what we get:\n\n```bash\n$ curl 0:3000/example\n```\n\nwill result in:\n\n```bash\n$ {\"called\":\"exampleGET\",\"policies\":[\"firstPolicy\"]}\n```\n\nand:\n\n```bash\n$ curl -XPOST 0:3000/example\n```\n\nwill result in:\n\n```bash\n$ {\"called\":\"examplePOST\",\"policies\":[\"firstPolicy\",\"secondPolicy\"]}\n```\n\nMore detailed examples can be found [here](https://github.com/colucom/json-routing)\n\n## Contributing\nPlease see [contributing guidelines](https://github.com/colucom/osseus-router/blob/master/.github/CONTRIBUTING.md).\n\n## License\nCode released under the [MIT License](https://github.com/colucom/osseus-router/blob/master/LICENSE).\n","readmeFilename":"README.md"}