{"_id":"@ambiere/router-route","_rev":"1-b68c046a3b71566cf3dd4fbb710162a4","name":"@ambiere/router-route","description":"Write organized complex route hierarchies for React-router","dist-tags":{"latest":"0.1.1"},"versions":{"0.1.0":{"name":"@ambiere/router-route","version":"0.1.0","keywords":["router","react","object","util"],"author":{"name":"Zidikhery Mchomvu","email":"itsambiere@gmail.com"},"license":"MIT","_id":"@ambiere/router-route@0.1.0","homepage":"https://github.com/ambiere/rr-route#readme","bugs":{"url":"https://github.com/ambiere/rr-route/issues"},"dist":{"shasum":"c13b9338a37c92fca6c4a78f8bf0cb4530861547","tarball":"https://registry.npmjs.org/@ambiere/router-route/-/router-route-0.1.0.tgz","fileCount":5,"integrity":"sha512-EqHltcF/wY3E1xtb0c/LQsjGHnnpmxqxT+XzOiEvvfe3ot6kYSTcPoo4T5bd1XSlT6h665fYO+nJ6+cba9wkdw==","signatures":[{"sig":"MEUCIQDZJXN7593fCWXv+nG+Kw3/BQkBp3lItlPEBDQ5JJCUvwIgcg0bN2GC1DMwt/MzW/Hp5XYwfnM94Cs0PlwAZFSrcKA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":8742},"main":"./src/index.js","type":"module","types":"./src/index.d.ts","exports":{"types":"./src/index.d.ts","default":"./src/index.js"},"gitHead":"3b29df0a37065a74f1f5f059840cb76766cc48e7","scripts":{"test":"standard --fix && vitest"},"_npmUser":{"name":"ambiere","email":"itsambiere@gmail.com"},"repository":{"url":"git+https://github.com/ambiere/rr-route.git","type":"git"},"_npmVersion":"10.2.4","description":"Write organized complex route hierarchies for React-router","directories":{},"_nodeVersion":"21.6.1","dependencies":{"react-router":"^6.23.1"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^1.6.0","standard":"^17.1.0"},"_npmOperationalInternal":{"tmp":"tmp/router-route_0.1.0_1719500491501_0.47098549582677784","host":"s3://npm-registry-packages"}},"0.1.1":{"name":"@ambiere/router-route","version":"0.1.1","description":"Write organized complex route hierarchies for React-router","main":"./src/index.js","type":"module","types":"./src/index.d.ts","exports":{"types":"./src/index.d.ts","default":"./src/index.js"},"scripts":{"test":"standard --fix && vitest"},"keywords":["router","react","object","util"],"author":{"name":"Zidikhery Mchomvu","email":"itsambiere@gmail.com"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/ambiere/router-route.git"},"bugs":{"url":"https://github.com/ambiere/router-route/issues"},"homepage":"https://github.com/ambiere/router-route#readme","dependencies":{"react-router":"^6.23.1"},"devDependencies":{"standard":"^17.1.0","vitest":"^1.6.0"},"_id":"@ambiere/router-route@0.1.1","gitHead":"78f7ac21204281725a775fcc011463aa079a8077","_nodeVersion":"21.6.1","_npmVersion":"10.2.4","dist":{"integrity":"sha512-yIiFSctVfFmXlh0CvGtwQeqb68GByLVd92b0BmLoaLaNGV1cdLqTLxF+HIDY/KOuyZlnqYaHBTtawbnsdQFcig==","shasum":"f95bfbe7e413fe8df267251a9a95ae9de7771aa0","tarball":"https://registry.npmjs.org/@ambiere/router-route/-/router-route-0.1.1.tgz","fileCount":5,"unpackedSize":8754,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBBRQDiIj0Fl50c7ycPN8JPOrUTSxnjJ3Mp2kw4arV2FAiBziYENEBFp0aofmYRehsjk9zMzZmRP7fk8VdHBvGxv8w=="}]},"_npmUser":{"name":"ambiere","email":"itsambiere@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/router-route_0.1.1_1719501802607_0.3804305762392275"},"_hasShrinkwrap":false}},"time":{"created":"2024-06-27T15:01:31.396Z","modified":"2024-06-27T15:23:22.912Z","0.1.0":"2024-06-27T15:01:31.663Z","0.1.1":"2024-06-27T15:23:22.757Z"},"maintainers":[{"name":"ambiere","email":"itsambiere@gmail.com"}],"author":{"name":"Zidikhery Mchomvu","email":"itsambiere@gmail.com"},"repository":{"type":"git","url":"git+https://github.com/ambiere/router-route.git"},"keywords":["router","react","object","util"],"license":"MIT","homepage":"https://github.com/ambiere/router-route#readme","bugs":{"url":"https://github.com/ambiere/router-route/issues"},"readme":"# router-route [![CI](https://github.com/ambiere/router-route/actions/workflows/main.yml/badge.svg)](https://github.com/ambiere/router-route/actions/workflows/main.yml)\n\n> Utility package designed to simplify the process of defining routes in `react-router`.\n\nrouter-route takes a custom route map and convert it into a standard route object that can be directly\nused with react-router's `createBrowserRouter` API. This package streamlines the management of complex\nroute hierarchies by linking parents and children routes through reference keys, ensuring a clean and\norganized route structure.\n\n## Features\n\n1. **Custom Route map**: Define your routes using a custom map with parent-child references.\n\n```ts\ninterface Parent extends Omit<RouteObject, \"children\"> {\n  childrenRef?: string | number /** Reference key to children routes*/\n}\n\ninterface RouteMap {\n  parents: Parent[]\n  childrens: Record<string | number, RouteMap>\n}\n```\n2. **Automatic Conversion**: Effortlessly convert the custom route map into a standard route object for use with `createBrowserRouter` API.\n3. **Simplified management**: Easily manage and organize complex route hierarchies with reference keys.\n4. **Recursive Building**: Recursively constructs the route tree, linking parent routes to their respective children.\n\n## Installation\n\n```bash\nnpm install @ambiere/router-route\n\n```\n\n## Usage\n\n```js\nimport RouterRoute from \"@ambiere/router-route\"\n\nconst routeMap = {\n  parents: [\n    {\n      element: <RootLayout />,\n      errorElement: <RootError />,\n      childrenRef: '_rootChildRef'\n    },\n    /** Support modularization for parents */\n    booksRouteModule\n  ],\n\n  childrens: {\n    \"_rootChildRef\": { /** Children of RootLayout*/\n      parents: [\n        {\n          path: \"/\",\n          element: <Home />,\n        }\n      ],\n      childrens: { /** Children of RootLayout's children (if any)*/\n        /** Support modularization for childrens */\n        _accountChildRef: usersRouteModule\n      }\n    }\n  }\n}\n\nconst routerRoute = new RouterRoute(routeMap)\nconst routerRouteObject = routerRoute.routeObject()\n\nconst router = createBrowserRouter(routerRouteObject, options)\n```\n\n## API\n\n#### `RouterRoute(routeMap: RouteMap): RouterRoute`\nRouterRoute class. Accept `routeMap` argument, a custom route map containing `parents` and `childrens` arrays and\nreturns an instance of `RouterRoute` containing `routeObject` method.\n\n#### `routeObject(): RouteObject[]`\nConverts custom route map into a standard route object and returns a standard route object compatible with react-router's `createBrowserRouter` API/method.\n\n## License\n\nThis project is licensed under the MIT License.\n","readmeFilename":"readme.md"}