{"_id":"resource-routing","_rev":"28-4665f2bf8af193e3ef557feadda81c2e","name":"resource-routing","description":"Building simple, easy restful routes for nodejs & expressjs, with a viewable routing table","dist-tags":{"latest":"0.2.0"},"versions":{"0.0.1":{"name":"resource-routing","version":"0.0.1","description":"building simple, easy restful routes for nodejs & expressjs","keywords":["express","expressjs","restful","routes","routing","resource","resources"],"homepage":"https://github.com/mshiltonj/resource-routing","repository":{"type":"git","url":"https://github.com/mshiltonj/resource-routing"},"author":{"name":"Steven Hilton","email":"mshiltonj@gmail.com"},"main":"index.js","dependencies":{"inflector":"0.0.1"},"bugs":{"url":"https://github.com/mshiltonj/resource-routing/issues"},"_id":"resource-routing@0.0.1","dist":{"shasum":"7c11329dcede5f23ebf95cdebc89e8142a8bdbdc","tarball":"https://registry.npmjs.org/resource-routing/-/resource-routing-0.0.1.tgz","integrity":"sha512-nLVfh5OYRceF+DZHMHpeIZVX3LbmqCGj2sftCKfjKF/iK4dr/LwC/CxbKJH6Nw+5RKZk2FraRRnJCpzb2Buwfg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDK4aqYmxN+spIHrSkA7LDc+1xSo4lV7y7fYRqhb/f6vgIhAP+PE929Npj2DK6bSNVJ3LKH2I0DYmzbYnng/WPMIBss"}]},"_from":"./","_npmVersion":"1.3.11","_npmUser":{"name":"mshiltonj","email":"mshiltonj@gmail.com"},"maintainers":[{"name":"mshiltonj","email":"mshiltonj@gmail.com"}],"directories":{}},"0.0.2":{"name":"resource-routing","version":"0.0.2","description":"building simple, easy restful routes for nodejs & expressjs","keywords":["express","expressjs","restful","routes","routing","resource","resources"],"homepage":"https://github.com/mshiltonj/resource-routing","repository":{"type":"git","url":"https://github.com/mshiltonj/resource-routing"},"author":{"name":"Steven Hilton","email":"mshiltonj@gmail.com"},"main":"index.js","dependencies":{"inflector":"0.0.1"},"bugs":{"url":"https://github.com/mshiltonj/resource-routing/issues"},"_id":"resource-routing@0.0.2","dist":{"shasum":"ee6b83313b3f542a0e6320a6d0e7a10f1982c74c","tarball":"https://registry.npmjs.org/resource-routing/-/resource-routing-0.0.2.tgz","integrity":"sha512-tpUbqTQVmrqdmEWjxqmCcBRQTPxL66PFhlE6qxXs/ra3LbBL1Y/+xpmooiWdGDtEVSTdTDyPPm5rZs1J2yBzPg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCP7rqTqzzWUYGSv2UccznY/MZnxjYFhtYMziKvHWm02QIhALM78p3hBQKJ4jQH6JREQs5tuVL+bXxTzC+Eohqo+S2k"}]},"_from":"./","_npmVersion":"1.3.11","_npmUser":{"name":"mshiltonj","email":"mshiltonj@gmail.com"},"maintainers":[{"name":"mshiltonj","email":"mshiltonj@gmail.com"}],"directories":{}},"0.0.3":{"name":"resource-routing","version":"0.0.3","description":"building simple, easy restful routes for nodejs & expressjs","keywords":["express","expressjs","restful","routes","routing","resource","resources"],"homepage":"https://github.com/mshiltonj/resource-routing","repository":{"type":"git","url":"https://github.com/mshiltonj/resource-routing"},"author":{"name":"Steven Hilton","email":"mshiltonj@gmail.com"},"main":"index.js","dependencies":{"inflector":"0.0.1"},"bugs":{"url":"https://github.com/mshiltonj/resource-routing/issues"},"_id":"resource-routing@0.0.3","dist":{"shasum":"111517150c4fc66f0d100f776ea97bfef30b4424","tarball":"https://registry.npmjs.org/resource-routing/-/resource-routing-0.0.3.tgz","integrity":"sha512-aF5BWMRCCCkOCdB5JYedHrml6sMu5WjE9iguzdz87bQiJKFwIi2o15KPnGGPYTYbP046msj5OyHXbJKI2UJC+g==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCp6Z3fNYj+YtDTSxfhsgRb7RV1V+yOdl4g+yBmq71QPwIhAN7EY2/TMwJS30Sb4AWXRgTHjNzBx+LdZTUzCvyHR1bd"}]},"_from":"./","_npmVersion":"1.3.11","_npmUser":{"name":"mshiltonj","email":"mshiltonj@gmail.com"},"maintainers":[{"name":"mshiltonj","email":"mshiltonj@gmail.com"}],"directories":{}},"0.0.4":{"name":"resource-routing","version":"0.0.4","description":"building simple, easy restful routes for nodejs & expressjs","keywords":["express","expressjs","restful","routes","routing","resource","resources"],"homepage":"https://github.com/mshiltonj/resource-routing","repository":{"type":"git","url":"https://github.com/mshiltonj/resource-routing"},"author":{"name":"Steven Hilton","email":"mshiltonj@gmail.com"},"main":"index.js","dependencies":{"inflector":"0.0.1"},"bugs":{"url":"https://github.com/mshiltonj/resource-routing/issues"},"_id":"resource-routing@0.0.4","dist":{"shasum":"d24ac7fc1cfd248349996179304859d52cdc90b6","tarball":"https://registry.npmjs.org/resource-routing/-/resource-routing-0.0.4.tgz","integrity":"sha512-W0fzOMrP62vyIkcBad0yUwc1XPZ6N8SteRvjPWVa5A1F7wHJpKUHUFEq263swN8Vw52EG5FiYOiZDm6dGm1VYA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCs0LnjTQyc6z9bhjs55hDipWkPWGbD5Dp74CAAbly3fwIgG0w+u37Pk8f3SR1U7l7TJ7CQvJ3w3lSTIkLc/hE+17g="}]},"_from":"./","_npmVersion":"1.3.11","_npmUser":{"name":"mshiltonj","email":"mshiltonj@gmail.com"},"maintainers":[{"name":"mshiltonj","email":"mshiltonj@gmail.com"}],"directories":{}},"0.0.5":{"name":"resource-routing","version":"0.0.5","description":"building simple, easy restful routes for nodejs & expressjs","keywords":["express","expressjs","restful","routes","routing","resource","resources"],"homepage":"https://github.com/mshiltonj/resource-routing","repository":{"type":"git","url":"https://github.com/mshiltonj/resource-routing"},"author":{"name":"Steven Hilton","email":"mshiltonj@gmail.com"},"main":"index.js","dependencies":{"inflector":"0.0.1","methods":"~0.1.0"},"bugs":{"url":"https://github.com/mshiltonj/resource-routing/issues"},"_id":"resource-routing@0.0.5","dist":{"shasum":"b8208b49ca0b3b757774354217084053d1d2d989","tarball":"https://registry.npmjs.org/resource-routing/-/resource-routing-0.0.5.tgz","integrity":"sha512-QgtDc7TFS2YR3cj3Gz7akO1BxwFei94d8Drt9k+sYG4hDzbzdxXw9bYNtoOAn9r+ehnvPWy9zs878bOlBIBhtA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDebFxmDZZ58OrDsrFOStZC/CeEDVxVxJ/GleNf9RqlPAIhAMGmllBT5m5UVoIGeNBscvWQuhPQqyqaArp4HOaBxfOx"}]},"_from":"./","_npmVersion":"1.3.11","_npmUser":{"name":"mshiltonj","email":"mshiltonj@gmail.com"},"maintainers":[{"name":"mshiltonj","email":"mshiltonj@gmail.com"}],"directories":{}},"0.0.6":{"name":"resource-routing","version":"0.0.6","description":"Building simple, easy restful routes for nodejs & expressjs, with a viewable routing table","keywords":["express","expressjs","restful","routes","routing","resource","resources"],"homepage":"https://github.com/mshiltonj/resource-routing","repository":{"type":"git","url":"https://github.com/mshiltonj/resource-routing"},"author":{"name":"Steven Hilton","email":"mshiltonj@gmail.com"},"main":"index.js","dependencies":{"inflector":"0.0.1","methods":"~0.1.0"},"bugs":{"url":"https://github.com/mshiltonj/resource-routing/issues"},"_id":"resource-routing@0.0.6","dist":{"shasum":"1ffcb4a7a40913df2e4e425fdb7e0533e736d6ed","tarball":"https://registry.npmjs.org/resource-routing/-/resource-routing-0.0.6.tgz","integrity":"sha512-2m3j5B+WSIZ0CJPY6gsAWpGKeGv9X2Bh2+WCLjKLLGF1RS0lZFAaFTj47SrlkpEeC9bZmzrt5R6/iY9JN+S2pg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC0/cS4cjrq9fWq5K8NUL8agpV/DnMHe21uUHcrUEx0lwIgTeakaHIAszvjXaAl8SNXVx+J6QSFmQQt2c42v5IJ6cs="}]},"_from":"./","_npmVersion":"1.3.11","_npmUser":{"name":"mshiltonj","email":"mshiltonj@gmail.com"},"maintainers":[{"name":"mshiltonj","email":"mshiltonj@gmail.com"}],"directories":{}},"0.0.7":{"name":"resource-routing","version":"0.0.7","description":"Building simple, easy restful routes for nodejs & expressjs, with a viewable routing table","keywords":["express","expressjs","restful","routes","routing","resource","resources"],"homepage":"https://github.com/mshiltonj/resource-routing","repository":{"type":"git","url":"https://github.com/mshiltonj/resource-routing"},"author":{"name":"Steven Hilton","email":"mshiltonj@gmail.com"},"main":"index.js","dependencies":{"inflector":"0.0.1","methods":"~0.1.0"},"bugs":{"url":"https://github.com/mshiltonj/resource-routing/issues"},"_id":"resource-routing@0.0.7","dist":{"shasum":"f61de1d018b3a0db619b8043da4b90da4dffde60","tarball":"https://registry.npmjs.org/resource-routing/-/resource-routing-0.0.7.tgz","integrity":"sha512-gHIbeAGpRifsMibCBRDTV+fJG7Ufbx9PpirmNkPeGpBt50nuABCELticHA2g+EK5yyJfMg5MxeSsKR5RGSJZyA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBNGFpOEFLAx2gKXWMRL8I5hRx13szmrXtYsAHY3O1l+AiBznIv+7tIYlr1WoqX5rpnljUfrXHyI9QhpBLJB8nNdHQ=="}]},"_from":"./","_npmVersion":"1.3.11","_npmUser":{"name":"mshiltonj","email":"mshiltonj@gmail.com"},"maintainers":[{"name":"mshiltonj","email":"mshiltonj@gmail.com"}],"directories":{}},"0.0.8":{"name":"resource-routing","version":"0.0.8","description":"Building simple, easy restful routes for nodejs & expressjs, with a viewable routing table","keywords":["express","expressjs","restful","routes","routing","resource","resources"],"homepage":"https://github.com/mshiltonj/resource-routing","repository":{"type":"git","url":"https://github.com/mshiltonj/resource-routing"},"author":{"name":"Steven Hilton","email":"mshiltonj@gmail.com"},"main":"index.js","dependencies":{"inflector":"0.0.1","methods":"~0.1.0"},"bugs":{"url":"https://github.com/mshiltonj/resource-routing/issues"},"_id":"resource-routing@0.0.8","dist":{"shasum":"5e242df6351dc66370dac315512b6dfbf157d95b","tarball":"https://registry.npmjs.org/resource-routing/-/resource-routing-0.0.8.tgz","integrity":"sha512-CIBxTwYdtp3FM8EwyEyEM6Fn3JOKK/LI4ZIufFMTnPZyl9Ufb/E8Ht764TDpQa1Uj/x8pAah21i/lsXxMFk6ZQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD6cOhQbbUKKUrrTIX4EwBFzKsOuWwszz4GVLx7Uu8pvgIgY1Jqizk+yA9Df+TlGdorggXqztCR86DSfEDZeLLdNJw="}]},"_from":"./","_npmVersion":"1.3.11","_npmUser":{"name":"mshiltonj","email":"mshiltonj@gmail.com"},"maintainers":[{"name":"mshiltonj","email":"mshiltonj@gmail.com"}],"directories":{}},"0.1.0":{"name":"resource-routing","version":"0.1.0","description":"Building simple, easy restful routes for nodejs & expressjs, with a viewable routing table","keywords":["express","expressjs","restful","routes","routing","resource","resources"],"homepage":"https://github.com/mshiltonj/resource-routing","repository":{"type":"git","url":"https://github.com/mshiltonj/resource-routing"},"author":{"name":"Steven Hilton","email":"mshiltonj@gmail.com"},"main":"index.js","dependencies":{"inflector":"0.0.1","methods":"~0.1.0"},"bugs":{"url":"https://github.com/mshiltonj/resource-routing/issues"},"_id":"resource-routing@0.1.0","dist":{"shasum":"8a1f76908217df04a96158545d603a6709120cb8","tarball":"https://registry.npmjs.org/resource-routing/-/resource-routing-0.1.0.tgz","integrity":"sha512-eL9WU3V0PN3GD96dz6XmCWliH97jl4yTKFZ/3/KiR0Yz7/K6vMSOSdjB2njstVJTMx/Feqbu8ugk2o/yKXp0Mw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHDnnL5RekoFIbMOV4xUDUOERyc9Tfz71cc7IUT3TFXiAiABnjUZrXx3Me9ft60CCb+l5aFP3QdlCvEtkX0O9m8LJQ=="}]},"_from":".","_npmVersion":"1.3.11","_npmUser":{"name":"mshiltonj","email":"mshiltonj@gmail.com"},"maintainers":[{"name":"mshiltonj","email":"mshiltonj@gmail.com"}],"directories":{}},"0.2.0":{"name":"resource-routing","version":"0.2.0","type":"module","description":"Building simple, easy restful routes for nodejs & expressjs, with a viewable routing table","keywords":["express","expressjs","restful","routes","routing","resource","resources"],"scripts":{"lint":"eslint src","test":"jest","integration":"./integration/test.sh","build":"$npm_execpath run build:esm && $npm_execpath run build:cjs","build:cjs":"tsc --target esnext --module commonjs --moduleResolution node --outDir dist/cjs && ./bin/dist-fixup.sh cjs","build:esm":"tsc --target esnext --module esnext --moduleResolution node --outDir dist/esm && ./bin/dist-fixup.sh esm"},"homepage":"https://github.com/mshiltonj/resource-routing","repository":{"type":"git","url":"https://github.com/mshiltonj/resource-routing"},"author":{"name":"Steven Hilton","email":"mshiltonj@gmail.com"},"exports":{".":{"types":"./dist/*.d.ts","require":"./dist/cjs/index.js","import":"./dist/esm/index.js"}},"dependencies":{"easy-table":"^1.2.0","inflected":"^2.1.0"},"devDependencies":{"@babel/preset-env":"^7.24.4","@babel/preset-typescript":"^7.24.1","@eslint/eslintrc":"^3.0.2","@eslint/js":"^9.0.0","@jest/globals":"^29.7.0","@types/express":"^4.17.21","@types/inflected":"^2.1.3","@types/jest":"^29.5.12","@types/node":"^20.12.7","@typescript-eslint/eslint-plugin":"^6.4.0","eslint":"^8.0.1","eslint-config-prettier":"^9.1.0","eslint-config-standard-with-typescript":"^43.0.1","eslint-plugin-import":"^2.25.2","eslint-plugin-n":"^15.0.0 || ^16.0.0 ","eslint-plugin-promise":"^6.0.0","express":"^4.19.2","globals":"^15.0.0","jest":"^29.7.0","prettier":"^3.2.5","prettylint":"^2.0.0","supertest":"^6.3.4","ts-node":"^10.9.2","typescript":"*","typescript-eslint":"^7.6.0"},"licenseText":"The MIT License (MIT)\n\nCopyright (c) 2014> Steven Hilton <mshiltonj@gmail.com>\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n","license":"MIT","_id":"resource-routing@0.2.0","dist":{"shasum":"3b4a96c72e58b0e0a9097a569d5633b0a20ef250","integrity":"sha512-JbmOK6qNqpxu/yF1rCRDL+nPY2SSfKZQz0zQeJfoys3wUQtnPMIsZM0HrWYyXI+rV91j/FsaiDrxbvnhoWWoxA==","tarball":"https://registry.npmjs.org/resource-routing/-/resource-routing-0.2.0.tgz","fileCount":36,"unpackedSize":71000,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCSnCaqRWKPeuEnRySrQl+zz5jiHC2lDz75iXd8DxL9hgIgOd5Lg5WRHWcaKmJoB7o0/skwXeg++8wmX/2L9bsXjhA="}]},"_npmUser":{"name":"mshiltonj","email":"mshiltonj@gmail.com"},"directories":{},"maintainers":[{"name":"mshiltonj","email":"mshiltonj@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/resource-routing_0.2.0_1716156601235_0.7801286002809478"},"_hasShrinkwrap":false}},"readme":"# Resource Routing\n\nThe Resource Routing package provides a way to a build simple, easy restful route suite for nodejs & expressjs, with a viewable routing table.\n\n# Summary\n\nResource Routing provides:\n\n* A simple, easy method for generating restful routes for a model\n* Viewable routing table\n* Customize, override and extend the default restful routes\n* Opt-in interface for creating non-restful routes, so you don't have to build routes in different ways.\n* Easy declaration of your \"root\" or \"home\" route.\n\n# Installation\n\n    npm install resource-routing\n\nor \n\n    yarn add resource-routing\n\n# Usage\nCreate a new router for your app:\n\n## ESM\n    import express from \"express\"\n    import path from \"path\";\n    import Router from \"resource-routing\"\n\n    const app = express()\n    const controllerDir = path.resolve(\"./controllers\")\n    const router = new Router(app, controllerDir)\n\n## CJS\n    const express = require('express')\n    const path = require('path')\n    const Router = require('resource-routing').default // NOTE THE .default here\n\n    const app = express()\n    const controllerDir = path.resolve(\"./controllers\")\n    const router = new Router(app, controllerDir)\n\nThe router expects all controllers to be in the same directory. A good recommendation is `PROJECT_ROOT/controllers` or `PROJECT_ROOT/app/controllers`.\n\nThe Router constructor has a second, optional parameter to specify a filer extension. Its value could be, for example, `js`, `ts`, `cjs`, `mjs`, etc. The default is `js`. It is difficult to predict what the file exension may be in varied enviromnents with transpiling and different module types. When loading a file, we first to load the file *without* a file extension. If that fails, we try *with* the file extension. If that fails, we raise an error.\n\n## .resources(entity | entity[], options?)\nThe router expects all controllers to be named with common convention of [entities]_controller.js, like `posts_controller.js` or `comments_controller.js`\n\nThe router depends on the express.js engine.\n\nThe `resources()` method takes one or two parameters.\n\nThe first parameter is a string reprensenting is the entity/class/model_name, in pluralized form, that will have restful routes.\n\nThe first parameter may also be an array strings representing a nested route defintion. More on nested routes below.\n\nExample simple usage:\n\n    router.resources(\"users\")\n\nYou now have restful routing for your User model.\n\nThis will build the 18 standard restful routes for you:\n\n    Method  URL                       Handler\n    GET     /users                    users_controller.index\n    GET     /users.:format            users_controller.index\n    GET     /users/new                users_controller.new\n    GET     /users/new.:format        users_controller.new\n    POST    /users                    users_controller.create\n    POST    /users.format             users_controller.create\n    GET     /users/:id                users_controller.show\n    GET     /users/:id.:format        users_controller.show\n    GET     /users/:id/edit           users_controller.edit\n    GET     /users/:id/edit.:format   users_controller.edit\n    PUT     /users/:id                users_controller.update\n    POST    /users/:id                users_controller.update\n    PATCH   /users/:id                users_controller.update\n    PUT     /users/:id.:format        users_controller.update\n    POST    /users/:id.:format        users_controller.update\n    PATCH   /users/:id.:format        users_controller.update\n    DELETE  /users/:id                users_controller.destroy\n    DELETE  /users/:id.:format        users_controller.destroy\n\nIf the controller does not exist, it will raise an error on start up.\n\nIf the expected controller function does not exist, it will raise an error on start up.\n\nThe functions should be defined as normal express request handlers with request and response parameters:\n\n    function(req, res) {};\n\nThe `options` parameter recognizes these keys:\n\n### `except`\n\nAn array of standard route names. These standard routes\nwill be excluded from the route creation process. They will **not be created**.\n\nExample:\n\n    router.resources(\"users\", { except: [\"delete\"] });\n\nThis will create six of the seven standard routes, plus their `.format` variants, but the `delete` route\nwill not be created.\n\n### `only`\nAn array of standard route names. **ONLY** these standard routes\nwill be created. Other standard routes not included in this list will be excluded from the route creation process.\n\nExample:\n\n    router.resources(\"users\", { only: [\"index\", \"show\"] } );\n\nThis will suppress creation of the `new`, `create`,\n`update`, `edit`, and `delete` routes. In this case, only the `index` and `show` from the default set will be created.\n\nIf `only` is included in the options, the `except` option is ignored.\n\n### `memberActions`\n\nIf you need add additional custom member routes, you can declare them with the `memberActions` options attribute. It takes an array of custom route definitions, and each custom route defintions needs a `method`, an `action` (or function name), and option path `path`. If the path is not provide, the route creation will use the `action` string for the `action` and the `path`.\n\n* The `method` is the HTTP method ('GET', 'POST', 'PUT', 'DELETE'),\n* The `action` is method or function name of the controller to be called\n* The `path`, if included, URL part to be appended to the entity's base URL. If not defined, it use the `action` string as the URL\n\nExample:\n\n    router.resources(\"users\", { memberActions:[\n        {method: \"GET\", action: \"foo\", path: \"bar\"},\n        {method: \"GET\", action: \"baz\"}\n      ]\n    });\n\nWill generate (in addition to the regular routes):\n\n    Method  URL                       Handler\n    get     /users/:id/foo            users_controller.bar\n    get     /users/:id/foo.:format    users_controller.bar\n    get     /users/:id/baz            users_controller.baz\n    get     /users/:id/baz.:format    users_controller.baz\n\n### `collectionActions`\nIf you need additional custom collection routes, you can declare them with the `collectionActions` options attribute. It works the same way as the member attribute, but the base URL used does not include :id. Instead it uses the general controller URL.\n\nExample:\n\n    router.resources(\"users\", {collectionActions: [\n      { method: \"GET\", action: \"reset_request\", path: \"reset\" }\n    ]});\n\nWill generate:\n\n    Method    URL                           Handler\n    get       /users/reset_request          users_controller.reset\n    get       /users/reset_request.:format  users_controller.reset\n\n### `using`\n\nOverrides the automatic model-to-controller conversion (where passing in \"users\" will automatically try to load \"users_controller\") and let's you declare which controller you will be using.\n\nFor example:\n\n    router.resources(\"users\", { using: \"members\" });\n\nWill create:\n\n    Method  URL                       Handler\n    get     /users                    members_controller.index\n    get     /users.:format            members_controller.index\n    get     /users/new                members_controller.new\n    get     /users/new.:format        members_controller.new\n    [etc]\n\n\n### `prefix`\n\nOptional. When defined, it is prepended to the generated URL path. This is useful for namespacing or URL versioning:\n\nFor example:\n\n    router.resources(\"users\", { prefix: \"api/1.0\" });\n\nWill create:\n\n    Method  URL                       Handler\n    get     /api/1.0/users                    users_controller.index\n    get     /api/1.0/users.:format            users_controller.index\n    get     /api/1.0/users/new                users_controller.new\n    get     /api/1.0/users/new.:format        users_controller.new\n    [etc]\n\n### Declaring nested resources\nNested resources are supported. By passing more than the minimum number of paramaters, the extra strings are assumed to be parent resources. For example, a call like:\n\n    router.resources([\"users\", \"posts\"])\n\nResource Routing will build the routes for posts, as a nested\nresource for tables and users, and the request will include resource\nids for the parent resourses.\n\nThese are the routes that will get created with that method call:\n\n    Method  URL                                                        Handler\n    GET     /users/:userId/posts                   PostsController.index\n    GET     /users/:userId/posts.format            PostsController.index\n    GET     /users/:userId/posts/new               PostsController.new\n    GET     /users/:userId/posts/new.format        PostsController.new\n    POST    /users/:userId/posts                   PostsController.create\n    POST    /users/:userId/posts.format            PostsController.create\n    GET     /users/:userId/posts/:id               PostsController.show\n    GET     /users/:userId/posts/:id.format        PostsController.show\n    GET     /users/:userId/posts/:id/edit          PostsController.edit\n    GET     /users/:userId/posts/:id/edit.format   PostsController.edit\n    PUT     /users/:userId/posts/:id               PostsController.update\n    PUT     /users/:userId/posts/:id.format        PostsController.update\n    PATCH   /users/:userId/posts/:id               PostsController.update\n    PATCH   /users/:userId/posts/:id.format        PostsController.update\n    POST    /users/:userId/posts/:id               PostsController.update\n    POST    /users/:userId/posts/:id.format        PostsController.update\n    DELETE  /users/:userId/posts/:id               PostsController.destroy\n    DELETE  /users/:userId/posts/:id.format        PostsController.destroy\n\nNOTE: None of the 'parent' resource routes gets created. They will need their own call to the `resources` have them defined, like so:\n\n    router.resources(\"users\");\n    router.resources([\"users\", \"posts\"]);\n    router.resources([\"users\", \"posts\", \"comments\"]);\n\n## root\n\nDeclare your root or home URL with the .root() method:\n\n    router.root(\"index\", \"home\");\n\nThis creates multiple routes to IndexController.home.\n\n    GET   /                   index_controller.home\n    GET   /index.:format      index_controller.home\n    GET   /index              index_controller.home\n\n## Arbitrary routes (get, post, put, delete):\n\nYou can declare all arbitrary non-restful routes through the resource-routing interface instead of directly through the express app object.\n\nThere are two reasons to do this:\n\n1. Consistency in declaring routes in your applications\n1. Arbitrary routes declared through resource-routing are added to the renderable routing table.\n\nExample:\n\nInstead of doing this:\n\n    import sessionsController from \"./controllers/sessions_controller\";\n    app.get(\"/login\", sessions_controller.login)\n    app.post(\"/logout\", sessions_controller.logout)\n\nDo this:\n\n    router.get(\"/login\", \"sessions#login\")\n    router.get(\"/logout\", \"sessions#logout\")\n\nIt will generate the expected routes:\n\n    Method    URL                 Handler\n    get       /login          sessions_controller.login\n    get       /login.:format  sessions_controller.logout\n\n## `exposeRoutingTable`\nIf you have a lot of generated resource routes, you many want or need a convenient way to see all the routes. Resource Routing\ngive you a way to do this.\n\n    import express from 'express'\n    const app = express();\n    import path from \"path\";\n    const app = express()\n    const controllerDir = path.resolve(\"./controllers\")\n    import Router from'resource-routing'\n    \n    const router = new Router(app, controllerDir)\n    router.exposeRoutingTable();\n\nThis enables a display of the routing table at a default location of: `/routingTable`. This displays an html table of all the internally generated routes. It does NOT include routes not added by resource-routing.\n\nYou can override the location of the routing table by passing a string paramater:\n\n    router.exposeRoutingTable(\"/myRoutes\");\n\nSome users may want to conditionally enable it. (i.e. in development, but not in production);\n\n# Authors\n* Steven Hilton <mshiltonj@gmail.com>, mastodon: [@mshiltonj](https://mastodon.online/@mshiltonj)\n\n# LICENSE\n\nSee [License](LICENSE)\n\n# ChangeLog\n\nSee [Changelog](CHANGELOG)\n\n\n\n\n","maintainers":[{"name":"mshiltonj","email":"mshiltonj@gmail.com"}],"time":{"modified":"2024-05-19T22:10:01.596Z","created":"2014-01-20T19:10:56.817Z","0.0.1":"2014-01-20T19:10:58.079Z","0.0.2":"2014-01-26T14:32:45.694Z","0.0.3":"2014-01-27T11:18:06.856Z","0.0.4":"2014-01-27T11:35:37.089Z","0.0.5":"2014-01-28T09:53:21.582Z","0.0.6":"2014-01-30T02:23:31.329Z","0.0.7":"2014-01-30T12:21:51.480Z","0.0.8":"2014-02-02T18:07:33.561Z","0.1.0":"2014-03-01T14:03:40.674Z","0.2.0":"2024-05-19T22:10:01.434Z"},"author":{"name":"Steven Hilton","email":"mshiltonj@gmail.com"},"repository":{"type":"git","url":"https://github.com/mshiltonj/resource-routing"},"readmeFilename":"README.md","homepage":"https://github.com/mshiltonj/resource-routing","keywords":["express","expressjs","restful","routes","routing","resource","resources"],"users":{"mshiltonj":true},"license":"MIT"}