{"_id":"@mayajs/router","_rev":"33-4a88b8765e0e962f080f3b02678f55ee","name":"@mayajs/router","dist-tags":{"latest":"0.7.4","next":"0.6.0-rc2"},"versions":{"0.1.0":{"name":"@mayajs/router","version":"0.1.0","description":"Simple NodeJS routing library created using Typescript","main":"lib/index.js","scripts":{"start":"rimraf lib && tsc -w"},"keywords":["nodejs","server","router","typescript","mayajs"],"author":{"name":"Mark Anthony C. Ignacio"},"license":"MIT","devDependencies":{"@types/node":"^13.11.0","jest":"^25.2.7","rimraf":"^3.0.2","ts-node":"^8.8.2","typescript":"^3.8.3"},"engines":{"node":">= 0.10.0"},"gitHead":"8d48bd795a75e78605be2f88dddee23c59ab9e2b","_id":"@mayajs/router@0.1.0","_nodeVersion":"12.16.1","_npmVersion":"6.13.4","dist":{"integrity":"sha512-OsRleerlZMMGMpe1voYFLKzfYgl3V9Cr2YiBFRALdpyWEU4V5dcYFKacpv2DI5mmoE4eVOYEpzPGD03NB3JrNA==","shasum":"ba96ce12baad96d69ee9c0c3bbc4a3213977d0ca","tarball":"https://registry.npmjs.org/@mayajs/router/-/router-0.1.0.tgz","fileCount":3,"unpackedSize":5530,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe94r/CRA9TVsSAnZWagAAEpYP/2cLuSGzhNJpr7AWMCRN\niWmY2PhfgTGgmHPhvXFaZ7Cw/ce4bnhj2tTVfMMHCNoZOH45VfMYyHHDEiEx\nf0fDgwalCSuxwgTuFTOOkcPy1T4oyefsK6jS44kxg3REuIlWGCeUlM8qy07f\neXN7lzp3WfhNgQ8zD1jjdj5CR+LaNdr6fIbb6IUuHSe6tH8SySDDv+L/INVu\nC4Y+nKVUC4rnvL9ODGNR4i+DHo8ouVIBWl16CGh/XW8E4aByxpTD2RN0VKFX\nE2BlWpad5y3XGhD6KvLD27y/cCcanqBxqVVREb7uSzx/tQNvOJAS5V4Owkuh\nGksn1OatKJr9vFtKoylQHbOoJfazpvpqvtXHG4NzDWYIVYnGiBq8eyRlYkaG\nQ5hmk3VY4UCpvN6cbHHCJHOU7JJmEfLKHY81C07DkNzqotG70a35Z8U/3KCD\nwD2ScdBRmTP2Krl46jQFn7AQ3svyqRp1gDBT5+qkofzUAUBpF6+31rc7cRUr\nHSSnBRoiKBYTmOsUK2pH1BHhj6LP0Svx8zHmHZpN5Mi1AR+9SCJ7SuG6LPu0\nzaA1YQR2GR6vH88jNbLz/LTD6BV7jlov2hp6iNyRKKl0A39kqVEchMShbqTz\nAJjgfpdKps2tGWoh9BHdm9Af4CZ0inPQid/j7EKrfaw0iO6NSK3n97Zug6oe\nFEBg\r\n=pGWW\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC7AkFP04aNPFz8iMn65EsV7wIeM+UWc8pU77TKBU7dPAIgNxYLMRIUuMkbOqp17p8/jMhAQo9by60HenPqOWaTcFU="}]},"maintainers":[{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"}],"_npmUser":{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/router_0.1.0_1593281278415_0.5116727222991717"},"_hasShrinkwrap":false},"0.1.1":{"name":"@mayajs/router","version":"0.1.1","description":"Simple NodeJS routing library created using Typescript","main":"lib/index.js","scripts":{"start":"rimraf lib && tsc -w","prepack":"rimraf lib && tsc"},"keywords":["nodejs","server","router","typescript","mayajs"],"author":{"name":"Mark Anthony C. Ignacio"},"license":"MIT","devDependencies":{"@types/node":"^13.11.0","jest":"^25.2.7","rimraf":"^3.0.2","ts-node":"^8.8.2","typescript":"^3.8.3"},"engines":{"node":">= 0.10.0"},"gitHead":"9ab539a8bf0afbe9e0cc85de58fd1b4ce9052531","_id":"@mayajs/router@0.1.1","_nodeVersion":"12.16.1","_npmVersion":"6.13.4","dist":{"integrity":"sha512-dUmXZKVPoa6x4qg0yXUKr+Via7js+xpB8fb4Y0j8f7w9KnHTFNlFURMwDHLthAlO2vfNYqOyj2kMb38pwL2qYw==","shasum":"0d7487daffefbb459309ac2a6a6576c660be4028","tarball":"https://registry.npmjs.org/@mayajs/router/-/router-0.1.1.tgz","fileCount":17,"unpackedSize":18480,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe95RKCRA9TVsSAnZWagAAenIP/itXUI+pGp7C4yzp3Xgc\nnPpENHt4Kcf5No+XKWXJRwwikGhbjgSwhU86nkJZStjhJHTgcbEg1Rtt3ZVc\nx+84JbFsEZZvRTGsWrY44B7DvooGyjLcT91Z8POnZ9uBSMnYPCiSbWieBh7U\nUCxNi5zheFx+Pd4DzFEKF5pXbEVGlJ8bjzoklCDbZuQz723NpsUxbQRdf9Rx\nhttWVI2lxtLylsAfrEFGkEuna6kmAAlTzSHlm2ob/BQYSW2qfZxCkIU7uK6U\n4G/vtYYHuRf9x2jiWrTs1pkdP7DTjoJNwJrspEUC95/Mj4mB5+IrK0iJlG1S\nlqQ1GJxgm5JcSykElLAfnPhahfkkHyev7S4AkWk5HcvdoO3cApFw2fyFVJHz\nQtGYGIxca0EL9lyH2LGcSNMhZWzUF+8J+4JfssAaQYvEAU7elKr/5YHky8gO\nH9iOkE5jM16DZbHYhZsoSc5F/xBhA2jEmHiY+hvmPDa6B2nSBxTm+mLIOs73\nsTJaxOUVJNUIfVRa8EPRs4f/5XFqZY21r8Lz7oydldmFWsrl4CSJ2qJ/BOu0\nCJVgDeAP1sWG8L3B95wE46SSbPr+vsxJv5vdGYkxaNGdC3EXCLqbikxuXR4N\nE73eb3ddcf6j4mdQx/w9i1yUtHcTbv8DTxIyYYjqQBInnPHVEToTMNrLGoGB\nynjr\r\n=Ln3y\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCHqME3hRXIVP5J2KV1RfSxMCFO8QxjyGdypec27IsDPQIhAMcF9TJfbd4z5SWdJEkIV4b72AmJLNmYRjCGHIGgnX4x"}]},"maintainers":[{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"}],"_npmUser":{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/router_0.1.1_1593283657639_0.02329365411124984"},"_hasShrinkwrap":false},"0.2.0":{"name":"@mayajs/router","version":"0.2.0","description":"Simple NodeJS routing library created using Typescript","main":"lib/index.js","scripts":{"start":"rimraf lib && tsc -w","prepack":"rimraf lib && tsc"},"keywords":["nodejs","server","router","typescript","mayajs"],"author":{"name":"Mark Anthony C. Ignacio"},"license":"MIT","devDependencies":{"@types/node":"^13.11.0","jest":"^25.2.7","rimraf":"^3.0.2","ts-node":"^8.8.2","typescript":"^3.8.3"},"engines":{"node":">= 0.10.0"},"gitHead":"31606e91ceafa346aea84e0b345bb4aa0e2f3ab8","_id":"@mayajs/router@0.2.0","_nodeVersion":"12.16.1","_npmVersion":"6.13.4","dist":{"integrity":"sha512-uexRj0zpb3Csess/zMyBTOImTrWZFhac0U/VcrRBlYkahdmtnc7R9whjZn+KGpaif2uE7BWhXQRqswDyFQRtyQ==","shasum":"ef08e2c0e3eb8e60cfc27a376ebd6a5f488cf8bb","tarball":"https://registry.npmjs.org/@mayajs/router/-/router-0.2.0.tgz","fileCount":19,"unpackedSize":45420,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfE/wOCRA9TVsSAnZWagAAn+YP/iwHxqNMkPjfa4xjHAO+\nfSlFGPXYI773A+a5ykeXq+G0ZRiZzR7WYQ4ZEAQKThRWs7DUukc03BjH1fHz\ndMjTaczS835EwPw4d4x4AxL4ZiFqxN5RVuK0FFkxU8u0OgRhR4TZpUU0EWkq\nu5OSDQBRVYDZ4RdCc5P8zxxRMb2ONGwer45atKDdicE+E7vjg5lv3lvNdIFB\n5643wzGd65OZe5fORM6ZBIjzN2pQXMri2AqsE62i62mjJPp4eQ/+iIe/BpYq\nGYQ14czbvlr3qyqtFyWag8BC6afvWqquLiXgs28943cIZ25X1Rr3gR84uT6W\nYxdxKYLLfUvVG8u4K63yiGtdFqZ3cKRtsEefJwEatvuxiIXn6+9g0kSnZFUI\nDiil0e2vdJ2kOOA9DpqGpXF4X3Hn9bOCulnFpbiGT4ZV61sQTD29Z9zih5Y6\nMQgsSdDIEUXm0IsjohFandYN8rfYyYqvNhDWc4OaG4c97RtMbqF9kL87KFv8\ny2keuQaJbHXdbdoVc1h1vNK1kptySF60yfI0cqfmWl2LlGuJbJvRgRpr/aQa\nZtMcBKn6oWt2cFfVk8+F9r0AXiOH96QFYkyLsS04Xs62P+LrJW3DjS3Sqizf\n8aDdCwZeY16kONxBA8erwTkoZkx2kbsHfPshxdFJjYnHMkqSe/ToxbgsIPOY\n5Jhf\r\n=XQof\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC/atMaajaEDmWsQOD6pJ+Yd/D+AuLJTuTVB+HoQXzO9wIhAP3VoEIc3i+bBqKkEUwkfft24JtrNk8lJOHhCrRduUEE"}]},"maintainers":[{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"}],"_npmUser":{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/router_0.2.0_1595145229906_0.5582225948889297"},"_hasShrinkwrap":false},"0.3.0-rc1":{"name":"@mayajs/router","version":"0.3.0-rc1","description":"Simple NodeJS routing library created using Typescript","main":"index.js","scripts":{"clean":"rimraf interface && rimraf index.js && rimraf index.d.ts && rimraf utils && rimraf router && rimraf lib","postpack":"npm run clean && node ./scripts/restore-package.js"},"keywords":["nodejs","server","router","typescript","library","REST","API","mayajs"],"author":{"name":"Mark Anthony C. Ignacio"},"license":"MIT","engines":{"node":">= 0.10.0"},"_resolved":"","_integrity":"","_from":"file:mayajs-router-0.3.0-rc1.tgz","readme":"<h1 align=\"center\">MayaJS Router</h1>\r\n<p align=\"center\"><img src=\"https://github.com/mayajs/maya/blob/master/maya.svg\" ></p>\r\n<h2 align=\"center\">Lightweight, simple and fast NodeJS Router developed using Typescript.</h2>\r\n\r\n## Motivation\r\n\r\nWe know that this is another **Express JS** like project. We develop **@mayajs/router** not to compete but to have our own router for our other projects like [@mayajs/core](https://github.com/mayajs/maya#readme). As much as possible we don't want to rely on other framework/library to create our own projects. This is just for maintainability and ease of transition for future updates.\r\n\r\n## Roadmap\r\n\r\nYou can see the detail roadmap of the project [here.](https://github.com/mayajs/router/blob/master/ROADMAP.md)\r\n\r\n## Suggestions\r\n\r\nFor suggestions and features you want to see in the future you can visit our [issues section.](https://github.com/mayajs/router/issues)\r\n\r\n## Getting started\r\n\r\nBefore installing this package make sure to download and install Node.js 10 or higher.\r\n\r\n<sub>**To check your node version**</sub>\r\n\r\n```shell\r\nnpm -v\r\n```\r\n\r\nFor new project kindly initialize npm using the command below or see documentation [here](https://docs.npmjs.com/creating-a-package-json-file).\r\n\r\n```shell\r\nnpm init\r\n```\r\n\r\nInstallation via command-line\r\n\r\n```shell\r\nnpm i @mayajs/router\r\n```\r\n\r\n## Features\r\n\r\n- Simple interface\r\n- Uses native Nodejs API\r\n- Built in body parser\r\n- Support for [ExpressJS Middlewares](https://expressjs.com/en/resources/middleware.html)\r\n- Compatible with typescript\r\n- ES6 compatible\r\n- Super ligthweight\r\n- No dependencies\r\n- Fast execution\r\n- Easy to learn\r\n\r\n## Quick Start\r\n\r\nThe easiest way to get started is to create a simple route\r\n\r\n```ts\r\nimport Router from \"@mayajs/router\";\r\nimport http from \"http\";\r\n\r\nconst PORT = process.env.PORT || 3000; // This is not required\r\nconst router = new Router();\r\n\r\n// Define your routes method in this manner\r\nrouter.get(\"path\", ({ res, req, params, query, body }) => {\r\n  res.send({ message: \"Hello, World\" });\r\n});\r\n\r\n// Pass the router and initialize it for used\r\nhttp.createServer(router.init).listen(PORT, () => {\r\n  console.log(\"Server listening on port\", PORT, \"...\");\r\n});\r\n```\r\n\r\n## Chaining\r\n\r\nYou can also chain your methods like this for easy management of routes.\r\n\r\n```ts\r\nrouter\r\n  .get(\"path\", ({ res, req }) => {\r\n    // Do your thing here\r\n  })\r\n  .post(\"path\", ({ res, req }) => {\r\n    // Do your thing here\r\n  })\r\n  .put(\"path\", ({ res, req }) => {\r\n    // Do your thing here\r\n  })\r\n  .delete(\"path\", ({ res, req }) => {\r\n    // Do your thing here\r\n  });\r\n```\r\n\r\n## Params\r\n\r\nWe also support `request params` like what other routing library implemented. Just add **:** infront of your named route i.e. `/user/:id` and it will treat the `:id` as a params.\r\n\r\n```ts\r\nrouter.get(\"path/:id\", ({ res, req, params, query, body }) => {\r\n  // Access id using req.params object\r\n  req.params.id;\r\n\r\n  // or access it using params variable\r\n  params.id;\r\n});\r\n```\r\n\r\n## Query String\r\n\r\nTo get the query string you can call the `query` object inside the request object or via function parameters.\r\n\r\n```ts\r\nrouter.get(\"path\", ({ res, req, params, query, body }) => {\r\n  // Access query strings using req.query object\r\n  req.query.limit;\r\n\r\n  // or access it using query variable\r\n  query.limit;\r\n});\r\n```\r\n\r\n## Request Object\r\n\r\nIf you think there are alot of parameters on your callback function you can remove them.\r\nParams, query and body are optional variables. They are also accessible inside the `req` object.\r\n\r\n```ts\r\nrouter.get(\"path\", ({ res, req }) => {\r\n  req.params;\r\n  req.query;\r\n  req.body;\r\n});\r\n```\r\n\r\n#### NOTE:\r\n\r\n> The `req.body` object is already parsed for **Content-Type** of `application/json, application/x-www-form-urlencoded and multipart/form-data`.\r\n> For `multipart/form-data` with files we are not yet supporting it.\r\n\r\n## Middlewares\r\n\r\nWe treat a middleware as another callback function. MayaJS router supports **ExpressJS** middleware as well as our own middlewares.\r\nTo use a middleware see example below:\r\n\r\n```ts\r\nrouter.use((res, req, next, error) => {\r\n  // This `error` variable comes from the previous middleware\r\n  console.log(error);\r\n\r\n  // The `next` function will trigger the end of this callback function\r\n  // and execute the next middleware in the list\r\n  next();\r\n});\r\n```\r\n\r\n## Collaborating\r\n\r\nSee collaborating guides [here.](https://github.com/mayajs/maya/edit/master/COLLABORATOR_GUIDE.md)\r\n\r\n## People\r\n\r\nAuthor and maintainer [Mac Ignacio](https://github.com/Mackignacio)\r\n\r\n## License\r\n\r\n[MIT](https://github.com/mayajs/router/blob/develop/LICENSE)\r\n","readmeFilename":"README.md","_id":"@mayajs/router@0.3.0-rc1","_nodeVersion":"12.16.1","_npmVersion":"6.13.4","dist":{"integrity":"sha512-i5xWXklv8/GzP5lq3uGl368QmE2EamadRTOJLemSQPflHdmCvnw7DY/sUFLbjOexDyfAeSpjlqAUWFeOzRwbAQ==","shasum":"919ff691cfe74acc57dc4deab69af321d21835e1","tarball":"https://registry.npmjs.org/@mayajs/router/-/router-0.3.0-rc1.tgz","fileCount":25,"unpackedSize":44769,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgaYB0CRA9TVsSAnZWagAAMdEP/i7JgsKvc+JmF//ovLrh\nKHNgyHXasIV+Qgyl5t0uS2hR+x7IMAPHdPuW8YupfTg4W8bZfTBg3BcyTBIB\npGqzb5TgDxKvKvmqWTg3chW8aU2R03d2C1sDHoU4KmBJOoodujBODIcjh0wq\n5sJZ5dnqYkgWqtkol3uPUdbH4gVrq8gWbOBuPz1HScz4sEtD5NvTQWH6aCZ/\noMuwjndGS68J0gLFSTydUxK1cxBIZwPG4KZWxNTPN/cGHStKTZ+ccxVkYtV6\nMQZtW8nlAGfiHhhA69xfnpByb2ygJo9qN1tBDzHFCydIRQlSmjHa1hbj1CkS\nT6IvfXYQLMb75dRCrYOmv9GPu9/IVThuWgLJ3trIYHspPuqEwW1zsT54/2og\nMpZCzZecZMgE77TicjAh9XgnQ6ADgg3jIn1/+ddzO2UE0kVTAL4JX+oQVXZi\nx8VII8ZIdIdeYZZj3nUWQ3FguWudym57TYhUKR6im/YK5w/TByzMTsGgbWlH\nMndXhIlf8FpcvywfpfHAFpYn83NpZYBastU7q8iFs7XYQHa+AlYEVq6+77fq\nFSvokXibORuYPgOpcw1aA8qxaReWzuadA684Gl46Y/uBNS4x9UnNLiZ9/cw2\neIZ+HL5QRW+Jpl2biQH2AKB9zZ2mmU3xTAZYACPCTjqu32dtSsGDZ+0P584G\nha5f\r\n=/hfI\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCaqoSMtJAMIkvhC6CJLot8lpMs2ZuY3txd5CxQWq1QIgIhAJ3ljzuKpXqjtSoDppvmLXzgFRYRJLyTFx95nI7kNX/X"}]},"_npmUser":{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"},"directories":{},"maintainers":[{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/router_0.3.0-rc1_1617526899701_0.5882029358981611"},"_hasShrinkwrap":false},"0.3.0-rc2":{"name":"@mayajs/router","version":"0.3.0-rc2","description":"Simple NodeJS routing library created using Typescript","main":"index.js","scripts":{"clean":"rimraf interface && rimraf index.js && rimraf index.d.ts && rimraf utils && rimraf router && rimraf lib","postpack":"npm run clean && node ./scripts/restore-package.js"},"keywords":["nodejs","server","router","typescript","library","REST","API","mayajs"],"author":{"name":"Mark Anthony C. Ignacio"},"license":"MIT","engines":{"node":">= 0.10.0"},"_resolved":"","_integrity":"","_from":"file:mayajs-router-0.3.0-rc2.tgz","readme":"<h1 align=\"center\">MayaJS Router</h1>\r\n<p align=\"center\"><img src=\"https://github.com/mayajs/maya/blob/master/maya.svg\" ></p>\r\n<h2 align=\"center\">Lightweight, simple and fast NodeJS Router developed using Typescript.</h2>\r\n\r\n## Motivation\r\n\r\nWe know that this is another **Express JS** like project. We develop **@mayajs/router** not to compete but to have our own router for our other projects like [@mayajs/core](https://github.com/mayajs/maya#readme). As much as possible we don't want to rely on other framework/library to create our own projects. This is just for maintainability and ease of transition for future updates.\r\n\r\n## Roadmap\r\n\r\nYou can see the detail roadmap of the project [here.](https://github.com/mayajs/router/blob/master/ROADMAP.md)\r\n\r\n## Suggestions\r\n\r\nFor suggestions and features you want to see in the future you can visit our [issues section.](https://github.com/mayajs/router/issues)\r\n\r\n## Getting started\r\n\r\nBefore installing this package make sure to download and install Node.js 10 or higher.\r\n\r\n<sub>**To check your node version**</sub>\r\n\r\n```shell\r\nnpm -v\r\n```\r\n\r\nFor new project kindly initialize npm using the command below or see documentation [here](https://docs.npmjs.com/creating-a-package-json-file).\r\n\r\n```shell\r\nnpm init\r\n```\r\n\r\nInstallation via command-line\r\n\r\n```shell\r\nnpm i @mayajs/router\r\n```\r\n\r\n## Features\r\n\r\n- Simple interface\r\n- Built with TypeScript\r\n- Uses native Nodejs API\r\n- Supports beginners to advance syntaxes\r\n- Can be use both `Function` based and `Class` based coding style\r\n- Dependency Injection\r\n- Fast execution\r\n- Easy to learn\r\n- Modular code\r\n\r\n## Quick Start\r\n\r\nThe easiest way to get started is to create a simple route\r\n\r\n```ts\r\nimport maya from \"@mayajs/router\";\r\nimport http from \"http\";\r\n\r\nconst PORT = 3000;\r\nconst app = maya();\r\n\r\napp.add([\r\n  {\r\n    path: \"/\",\r\n    GET: () => \"Hello, World\",\r\n  },\r\n]);\r\n\r\nhttp.createServer(app).listen(PORT, () => console.log(`Server listening on port ${PORT}.`));\r\n```\r\n\r\n## ROUTE\r\n\r\nDefining routes in MayaJs is like creating a JSON object.\r\n\r\n```ts\r\nconst user = {\r\n  path: \"user\",\r\n  GET: () => {\r\n    //  ...\r\n  },\r\n  POST: () => {\r\n    //  ...\r\n  },\r\n  PUT: () => {\r\n    //  ...\r\n  },\r\n  PATCH: () => {\r\n    //  ...\r\n  },\r\n  DELETE: () => {\r\n    //  ...\r\n  },\r\n  OPTIONS: () => {\r\n    //  ...\r\n  },\r\n};\r\n```\r\n\r\nAs seen above each method name has a `callback` function. Mayajs will set the correct `content-type` based on what the method callback will return.\r\n\r\n```ts\r\nconst route = {\r\n  path: \"user\",\r\n  GET: () => {\r\n    // This will return `undefined`\r\n    // This will have a content-type of \"text/plain\"\r\n  },\r\n  POST: () => {\r\n    return \"Hello\"; // This will have a content-type of \"text/plain\"\r\n  },\r\n  PUT: () => {\r\n    return { message: \"Hello\" }; // This will have a content-type of \"application/json\"\r\n  },\r\n  PATCH: () => {\r\n    return \"<h1>Hello</h1>\"; // This will have a content-type of \"text/html\"\r\n  },\r\n};\r\n```\r\n\r\nIncase you need to use a middleware for an specific route method you need to create a route object instead.\r\n\r\n```ts\r\nconst route = {\r\n  path: \"user\",\r\n  GET: {\r\n    middlewares: [middleware],\r\n    callback: () => {\r\n      // ...\r\n    },\r\n  },\r\n};\r\n```\r\n\r\n## PARAMS\r\n\r\nMayaJs passes a context object on each route method. You can acces the route params by destructuring the context object on the callback method.\r\n\r\n```ts\r\nconst route = {\r\n  path: \"user/:id\",\r\n  GET: ({ params }) => {\r\n    // `params` object contains the value of `id` define on the path above e.g. `user/hello`\r\n    return params.id; // This has a value of \"hello\"\r\n  },\r\n};\r\n```\r\n\r\n## QUERY STRING\r\n\r\nYou can also access the query string using the context object provided by MayaJs on your route method callback function.\r\n\r\n```ts\r\nconst route = {\r\n  path: \"user\",\r\n  GET: ({ query }) => {\r\n    // `query` object contains all the value on your query string e.g. `user?id=1`\r\n    return query.id; // This has a value of 1\r\n  },\r\n};\r\n```\r\n\r\n## BODY\r\n\r\nRequest body is also accessible in the context but you need a middleware before you can actually uses. There is a popular middleware called [body-parser](https://www.npmjs.com/package/body-parser) that we can use to achieve this.\r\n\r\n```ts\r\nimport maya from \"@mayajs/router\";\r\n// Third party middleware you need to install\r\nimport bodyParser from \"body-parser\";\r\n\r\nconst app = maya();\r\n\r\n// Initialize body parser for mayajs to use it internally\r\napp.use(bodyParser.json());\r\napp.use(bodyParser.urlencoded({ extended: false }));\r\n\r\nconst route = {\r\n  path: \"user\",\r\n  POST: ({ body }) => {\r\n    // `body` object contains all the value from the request body\r\n    return body; // This has a value of req.body\r\n  },\r\n};\r\n\r\napp.add([route]);\r\n```\r\n\r\n## MIDDLEWARES\r\n\r\nAs seen above how we used third party middlewares to parse the request body. We can also create our own middlewares. Although MayaJs supports all [ExpressJs Middlewares](https://expressjs.com/en/resources/middleware.html), we also can create a `MayaJsMiddleware` of our own. The context is where you can access `params, query and body` objects.\r\n\r\n```ts\r\nrouter.use((context, next, error) => {\r\n  // This `error` variable comes from the previous middleware\r\n  console.log(error);\r\n\r\n  // The `next` function will trigger the end of this callback function\r\n  // and execute the next middleware in the list\r\n  next(\"Error message or any value that you want to pass to the next middleware\");\r\n});\r\n```\r\n\r\n## CHILD ROUTES\r\n\r\nA child route is a route that appended to its parent route. It can be added using the `children` property from the route object.\r\n\r\n```ts\r\nconst child = {\r\n  path: \"child\",\r\n  GET: () => \"This is from a child route\", // You can call this route by `users/child`\r\n};\r\n\r\nconst parent = {\r\n  path: \"user\",\r\n  children: [child], // This is a list of routes. Also a `child` route can also have its own `children` and so on.\r\n};\r\n\r\napp.add([parent]);\r\n```\r\n\r\n## CONTROLLER\r\n\r\nA controller is a class that act as a replacement for the route method objects. It can be used to make your code more modular and manageable when your code base get bigger.\r\n\r\n```ts\r\nclass UsersController extends Controller {\r\n  GET() {\r\n    return \"Hello form UsersController\";\r\n  }\r\n\r\n  // You can also add additional route method like this\r\n  POST() {\r\n    // ...\r\n  }\r\n\r\n  // Other routes available are PUT, PATCH, DELETE and OPTIONS\r\n}\r\n\r\napp.add([\r\n  {\r\n    path: \"user\",\r\n    controller: UsersController,\r\n  },\r\n]);\r\n```\r\n\r\nIf you want to add middleware a middleware to a specific method you can add the `middleware` property in a controller.\r\n\r\n```ts\r\nclass UsersController extends Controller {\r\n  middleware = {\r\n    GET: [middleware], // This middleware will be added to the `GET` method below\r\n  };\r\n\r\n  GET() {\r\n    //  ...\r\n  }\r\n}\r\n```\r\n\r\n```\r\nNOTE: A controller has no `children` property\r\n```\r\n\r\n## SERVICES\r\n\r\nA service is an injectable class that can be used inside of a controller or another service.\r\n\r\n```ts\r\nexport class UsersServices extends Services {\r\n  // Every function inside the service can be accessed by the class its injected\r\n  // All public properties are also accessible\r\n  // A service is instatiated once and making it a singleton\r\n\r\n  add() {\r\n    // ...\r\n  }\r\n}\r\n\r\nclass UsersController extends Controller {\r\n  constructor(userServices: UsersServices) {\r\n    super();\r\n  }\r\n\r\n  addUser() {\r\n    // This `add` function coming from the `UsersService`.\r\n    // It is accessible on this controller via dependency injection.\r\n    // MayaJs automatically instantiated it and created it singleton instance.\r\n    this.userServices.add();\r\n  }\r\n}\r\n```\r\n\r\n## MODULE\r\n\r\nA module is a like a container of routes, controller and services that act on its own. This will allow your code to modular and shareable accross all routes.\r\n\r\n```ts\r\nclass UsersModule extends MayaJsModule {\r\n  // List of `module` or `services` that this module will use for its controllers\r\n  imports = [];\r\n  // List of controllers that this module will use\r\n  declarations = [];\r\n  // List of services that can be use inside this module\r\n  providers = [];\r\n  // List of services that this module will exports that can be used by other modules\r\n  exports = [];\r\n  // List of dependencies that will be injected to this module\r\n  dependencies = [];\r\n}\r\n```\r\n\r\nAs you can see when we create a module we dont have any way to add routes on it. Below is an example of implementation of how to add a `RouterModule` for this module to add routes.\r\n\r\n```ts\r\nimport { UsersController, UsersIdController } from \"./controller\";\r\nimport { RouterModule } from \"@mayajs/router\";\r\nimport { UsersServices } from \"./services\";\r\n\r\n// Define the routes\r\nconst routes = [\r\n  {\r\n    path: \"/\",\r\n    controller: UsersController,\r\n  },\r\n  {\r\n    path: \":id\",\r\n    controller: UsersIdController,\r\n  },\r\n];\r\n\r\nexport class UsersModule extends MayaJsModule {\r\n  // User `RouterModule.forRoot` to inject the routes\r\n  imports = [RouterModule.forRoot(routes)];\r\n  // Declare the controllers that will be used inside the routes\r\n  declarations = [UsersIdController, UsersController];\r\n}\r\n```\r\n\r\n## CUSTOM MODULE\r\n\r\nUnlike the common mayajs module, custom modules provide other functionality aside from managing your controllers. One example of this the `RouterModule` that is reponsible for adding routes to your module. A key concept of a custom module is it has an `invoke` and `forRoot` function that provides additional functionalities.\r\n\r\n```ts\r\nexport class UsersModule extends CustomModule {\r\n  invoke() {\r\n    // This function will run after an instance of this module is created\r\n    // But the providers will stay singleton on each instance\r\n  }\r\n\r\n  static forRoot(options: any) {\r\n    return {\r\n      module: UsersModule, // Returns the current module reference\r\n      providers: [], // List of providers that this module will use on its controllers\r\n    };\r\n  }\r\n}\r\n```\r\n\r\nNow we know how to create a module but how we can call it on our routes. We are now introducing to `loadChildren` property of our route object. MayaJs will automatically resolve the module asynchronously when the path is added on the route list.\r\n\r\n```ts\r\nimport maya from \"@mayajs/router\";\r\nimport http from \"http\";\r\n\r\nconst app = maya();\r\n\r\napp.add([\r\n  {\r\n    path: \"users\",\r\n    // We are using dynamic importing so we don't need it to manually import the module in the file\r\n    // MayaJs will resolve the module asynchronously\r\n    loadChildren: () => import(\"./users.module\").then((m) => m.UsersModule),\r\n  },\r\n]);\r\n```\r\n\r\n## Collaborating\r\n\r\nSee collaborating guides [here.](https://github.com/mayajs/maya/edit/master/COLLABORATOR_GUIDE.md)\r\n\r\n## People\r\n\r\nAuthor and maintainer [Mac Ignacio](https://github.com/Mackignacio)\r\n\r\n## License\r\n\r\n[MIT](https://github.com/mayajs/router/blob/develop/LICENSE)\r\n","readmeFilename":"README.md","_id":"@mayajs/router@0.3.0-rc2","_nodeVersion":"12.16.1","_npmVersion":"6.13.4","dist":{"integrity":"sha512-I+oRLY4Sj1S38u+FWDoCaF1QrOmNJRI7K8AwsNNxQim7gcX8ssXFWGhD/GxYg01nNPOXahZSg+RmYHfATH4Nvw==","shasum":"34a08748676d52bc2e9b5783590c41eace5ae1b2","tarball":"https://registry.npmjs.org/@mayajs/router/-/router-0.3.0-rc2.tgz","fileCount":25,"unpackedSize":50936,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgagI1CRA9TVsSAnZWagAAoGoP/2hCzx8nQUzV4+8S/HLD\nqAg+5iT3G2/yqCRG+15n8DsPIVaO3QgAJa8vl4NaSi+Fd9hcc+dro1mjyZ4s\nzt/CG6BRD24doj2SAyAQc9j70lNvXJdcF04UWauzfHepXoYKARZma10HwxIA\nznb4AQhfimmcI2cMQ0nq5pLeGEGMX5Yo+KhNJdp8FJQPK9SBvj1XSZIais8c\nXh919uPrnHZbRL+Xa63yWVOxtlPlU99nPlpDRbDOAIoo0iYgpXyc7CEDsAaZ\nDZKAAiJt5DoecFpdqI8ocWDEkNWe3Cfrrv6BMNnVEz1bZAujaBpUAOXRTjhO\nUBy/7DD6yYW9/r7JVi7kYpUnbcVJdJtC5Brs3dZsQfKx47SwwptRgUT7MWeV\n0FaOojxUQFrrkh9MOfEetSubvwjUEsKnnNHNFmXBi7NgQqhOrEwxpEima6eK\no/74ZG4t5+aKwKbEf432TKBvaQNj1RAyMYT/1YkXUdSw40eNJfFgI8FBIf03\nXzqRR8EScNRxsP/UOXYtIZKgOGxPVF07HoxOeWZzWxnJrYhUjO2aAS4yCdQ7\nj1wehddHGXfkr/4hqVSdeJdfsukeLWn1FSVnOnq6Z1oPbwU0P/4TZdshbmiG\nVqK0AdN9VEDxe7+cGVzIjrSugpF/I9GQipYltImo4GnhenZHbF/qVvJQEHC/\nV8I8\r\n=vXQX\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCJXWtPSaS3auGoI0OhIvEfA0ET2PZCCmfXEwTz30O9lQIhAMyO4dBPcQ0FB59S2+dFmoKEeGEiEbqGDEzjx89078vi"}]},"_npmUser":{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"},"directories":{},"maintainers":[{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/router_0.3.0-rc2_1617560117265_0.040022670795700765"},"_hasShrinkwrap":false},"0.3.0":{"name":"@mayajs/router","version":"0.3.0","description":"Simple NodeJS routing library created using Typescript","main":"lib/index.js","scripts":{"clean":"rimraf interface && rimraf index.js && rimraf index.d.ts && rimraf utils && rimraf router && rimraf lib","tgz":"rimraf *.tgz","package":"node ./scripts/clean-package.js","start":"npm run clean && npm run tgz && tsc -w","prepack":"npm run clean && npm run package && tsc --outDir ."},"keywords":["nodejs","server","router","typescript","library","REST","API","mayajs"],"author":{"name":"Mark Anthony C. Ignacio"},"license":"MIT","devDependencies":{"@types/node":"^13.11.0","jest":"^25.2.7","rimraf":"^3.0.2","ts-node":"^8.8.2","typescript":"^3.8.3"},"engines":{"node":">= 0.10.0"},"gitHead":"dacf9ef40bbe37c797ca29cd784fa868afb7af4d","_id":"@mayajs/router@0.3.0","_nodeVersion":"12.16.1","_npmVersion":"6.13.4","dist":{"integrity":"sha512-TXFMy2/zHwZ7fu3lfgH4C8rOYnuJwubbWDvFCHE0zNOkXbzcJjmiR1toUwQR5obmpe5cJTrMpvKkkIKB5HLKag==","shasum":"e2a8f949f813d7902bd5d949d5fe20690886bbbc","tarball":"https://registry.npmjs.org/@mayajs/router/-/router-0.3.0.tgz","fileCount":25,"unpackedSize":52138,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgbi+GCRA9TVsSAnZWagAAX6UP/jGw1vSlapUBkyjI7wSB\nBzumJThY/s16xwYC30N1d8GcZG+MEKRJbTtwmIw+vVbd+1hGs2PT9M/262Rp\n+YD5mFZKG99qyo+Y1Je2X74VpeniTEYI/4w59batQkBJKgRQmB1Sb0kCAplx\nNAJbgkZ+rnGuFd47SKfO24nz8xxzom1qQ5+5a/f0CnlBxaKoX+ji5a/0Gb+s\naR6k3D2PFOurYMldVpGy6IKj1+13EUjPViOuyXKHxFPV3tXnUQzNTlcfr/Hk\nPO59xT4VMaiHyTLDfpHG3M/vUPY/zNF8UP+jjZZlh6/RnXT2jmHaXqqLxe2+\n3w3k4uNgVSv0Ta6Wd/1kDcXNxh2ISiHU2aeQuQDJNqepmArNUEa84Ekr5tkL\nnfKL9F5+ixxFiUB07NS5b25M6603mObIcEaRPmL7yV0/u/f6Ks4MjimVcAgb\nzwb0EU4vYOOGo8tODU9xvNdj7ysVjgFAj8Q7taG7/J3SBm80CsQtoIgc4teD\nZkBhWS77gHSqP1HQyhHvex3lIrJFyQMQgc71hK/j58U8i90YmyCi78TseiQ1\nAfqedcNyXfb5TrS3xg7pZNELiGV4c2sjDkRRieWSKxYRNY3Bhy2nTJoQmJyt\nnQdELv+yWLHb1RjmXlDSa3gzIFEzXKNrNpSjMQhWu7F/xN8YemWobbc8XOfu\n1Fbc\r\n=v/Ua\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDsxgswMlB9Day4oISgJ5C3cSR5vT65XjKnJ9zNb792bQIgc+FrNfqbDQ0V4FgNWmjyToBqjpy2SJARhj7bJErVZGI="}]},"_npmUser":{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"},"directories":{},"maintainers":[{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/router_0.3.0_1617833861847_0.5304558035237257"},"_hasShrinkwrap":false},"0.4.0-rc1":{"name":"@mayajs/router","version":"0.4.0-rc1","description":"Simple NodeJS routing library created using Typescript","main":"index.js","scripts":{"clean":"rimraf interface && rimraf index.js && rimraf index.d.ts && rimraf utils && rimraf router && rimraf lib && rimraf class && rimraf exceptions && rimraf types","postpack":"npm run clean && node ./scripts/restore-package.js"},"keywords":["nodejs","server","router","typescript","library","REST","API","mayajs"],"author":{"name":"Mark Anthony C. Ignacio"},"license":"MIT","engines":{"node":">= 0.10.0"},"_resolved":"","_integrity":"","_from":"file:mayajs-router-0.4.0-rc1.tgz","readme":"<h1 align=\"center\">MayaJS Router</h1>\r\n<p align=\"center\"><img src=\"https://github.com/mayajs/maya/blob/master/maya.svg\" ></p>\r\n<h2 align=\"center\">Lightweight, simple and fast NodeJS Router developed using Typescript.</h2>\r\n<p align=\"center\">\r\n  <a href=\"https://www.npmjs.com/package/@mayajs/router\"><img src=\"https://img.shields.io/npm/v/@mayajs/router.svg?style=for-the-badge&logo=appveyor\" alt=\"Version\"></a>\r\n  <a href=\"https://www.npmjs.com/package/@mayajs/router\"><img src=\"https://img.shields.io/npm/dm/@mayajs/router.svg?style=for-the-badge&logo=appveyor\" alt=\"Downloads\"></a>\r\n  <a href=\"https://www.npmjs.com/package/@mayajs/router\"><img src=\"https://img.shields.io/npm/l/@mayajs/router?style=for-the-badge&logo=appveyor\" alt=\"License\"></a>\r\n  <a href=\"https://github.com/microsoft/typescript-tslint-plugin\"><img src=\"https://img.shields.io/badge/code%20style-standard-blue.svg?style=for-the-badge&logo=appveyor\" alt=\"Code Style\"></a>\r\n</p>\r\n\r\n## Motivation\r\n\r\nYup another **ExpressJS** like library. We develop **@mayajs/router** not to compete but to have our own router for our other projects like [@mayajs/router](https://github.com/mayajs/maya#readme). As much as possible we don't want to rely on other framework/library to create our own projects. This is just for maintainability and ease of transition for future updates.\r\n\r\n## Roadmap\r\n\r\nYou can see the detail roadmap of the project [here.](https://github.com/mayajs/router/blob/master/ROADMAP.md)\r\n\r\n## Suggestions\r\n\r\nFor suggestions and features you want to see in the future you can visit our [issues section.](https://github.com/mayajs/router/issues)\r\n\r\n## Getting started\r\n\r\nBefore installing this package make sure to download and install Node.js 10 or higher.\r\n\r\n<sub>**To check your node version**</sub>\r\n\r\n```shell\r\nnpm -v\r\n```\r\n\r\nFor new project kindly initialize npm using the command below or see documentation [here](https://docs.npmjs.com/creating-a-package-json-file).\r\n\r\n```shell\r\nnpm init\r\n```\r\n\r\nInstallation via command-line\r\n\r\n```shell\r\nnpm i @mayajs/router\r\n```\r\n\r\n## Features\r\n\r\n- Simple interface\r\n- Built with TypeScript\r\n- Uses native Nodejs API\r\n- Supports beginners to advance syntaxes\r\n- Can be use both `Function` based and `Class` based coding style\r\n- Dependency Injection\r\n- Fast execution\r\n- Easy to learn\r\n- Modular code\r\n\r\n## Quick Start\r\n\r\nThe easiest way to get started is to create a simple route\r\n\r\n```ts\r\nimport maya from \"@mayajs/router\";\r\nimport http from \"http\";\r\n\r\nconst PORT = 3000;\r\nconst app = maya();\r\n\r\napp.add([\r\n  {\r\n    path: \"/\",\r\n    GET: () => \"Hello, World\",\r\n  },\r\n]);\r\n\r\nhttp.createServer(app).listen(PORT, () => console.log(`Server listening on port ${PORT}.`));\r\n```\r\n\r\n## ROUTE\r\n\r\nDefining routes in MayaJs is like creating a JSON object.\r\n\r\n```ts\r\nconst user = {\r\n  path: \"user\",\r\n  GET: () => {\r\n    //  ...\r\n  },\r\n  POST: () => {\r\n    //  ...\r\n  },\r\n  PUT: () => {\r\n    //  ...\r\n  },\r\n  PATCH: () => {\r\n    //  ...\r\n  },\r\n  DELETE: () => {\r\n    //  ...\r\n  },\r\n  OPTIONS: () => {\r\n    //  ...\r\n  },\r\n};\r\n```\r\n\r\nAs seen above each method name has a `callback` function. Mayajs will set the correct `content-type` based on what the method callback will return.\r\n\r\n```ts\r\nconst route = {\r\n  path: \"user\",\r\n  GET: () => {\r\n    // This will return `undefined`\r\n    // This will have a content-type of \"text/plain\"\r\n  },\r\n  POST: () => {\r\n    return \"Hello\"; // This will have a content-type of \"text/plain\"\r\n  },\r\n  PUT: () => {\r\n    return { message: \"Hello\" }; // This will have a content-type of \"application/json\"\r\n  },\r\n  PATCH: () => {\r\n    return \"<h1>Hello</h1>\"; // This will have a content-type of \"text/html\"\r\n  },\r\n};\r\n```\r\n\r\nIncase you need to use a middleware for an specific route method you need to create a route object instead.\r\n\r\n```ts\r\nconst route = {\r\n  path: \"user\",\r\n  GET: {\r\n    middlewares: [middleware],\r\n    callback: () => {\r\n      // ...\r\n    },\r\n  },\r\n};\r\n```\r\n\r\n## PARAMS\r\n\r\nMayaJs passes a context object on each route method. You can acces the route params by destructuring the context object on the callback method.\r\n\r\n```ts\r\nconst route = {\r\n  path: \"user/:id\",\r\n  GET: ({ params }) => {\r\n    // `params` object contains the value of `id` define on the path above e.g. `user/hello`\r\n    return params.id; // This has a value of \"hello\"\r\n  },\r\n};\r\n```\r\n\r\n## QUERY STRING\r\n\r\nYou can also access the query string using the context object provided by MayaJs on your route method callback function.\r\n\r\n```ts\r\nconst route = {\r\n  path: \"user\",\r\n  GET: ({ query }) => {\r\n    // `query` object contains all the value on your query string e.g. `user?id=1`\r\n    return query.id; // This has a value of 1\r\n  },\r\n};\r\n```\r\n\r\n## BODY\r\n\r\nRequest body is also accessible in the context but you need a middleware before you can actually uses. There is a popular middleware called [body-parser](https://www.npmjs.com/package/body-parser) that we can use to achieve this.\r\n\r\n```ts\r\nimport maya from \"@mayajs/router\";\r\n// Third party middleware you need to install\r\nimport bodyParser from \"body-parser\";\r\n\r\nconst app = maya();\r\n\r\n// Initialize body parser for mayajs to use it internally\r\napp.use(bodyParser.json());\r\napp.use(bodyParser.urlencoded({ extended: false }));\r\n\r\nconst route = {\r\n  path: \"user\",\r\n  POST: ({ body }) => {\r\n    // `body` object contains all the value from the request body\r\n    return body; // This has a value of req.body\r\n  },\r\n};\r\n\r\napp.add([route]);\r\n```\r\n\r\n## MIDDLEWARES\r\n\r\nAs seen above how we used third party middlewares to parse the request body. We can also create our own middlewares. Although MayaJs supports all [ExpressJs Middlewares](https://expressjs.com/en/resources/middleware.html), we also can create a `MayaJsMiddleware` of our own. The context is where you can access `params, query and body` objects.\r\n\r\n```ts\r\nrouter.use((context, next, error) => {\r\n  // This `error` variable comes from the previous middleware\r\n  console.log(error);\r\n\r\n  // The `next` function will trigger the end of this callback function\r\n  // and execute the next middleware in the list\r\n  next(\"Error message or any value that you want to pass to the next middleware\");\r\n});\r\n```\r\n\r\n## CHILD ROUTES\r\n\r\nA child route is a route that appended to its parent route. It can be added using the `children` property from the route object.\r\n\r\n```ts\r\nconst child = {\r\n  path: \"child\",\r\n  GET: () => \"This is from a child route\", // You can call this route by `users/child`\r\n};\r\n\r\nconst parent = {\r\n  path: \"user\",\r\n  children: [child], // This is a list of routes.\r\n};\r\n\r\napp.add([parent]);\r\n```\r\n\r\n## CONTROLLER\r\n\r\nA controller is a class that act as a replacement for the route method objects. It can be used to make your code more modular and manageable when your code base get bigger.\r\n\r\n```ts\r\nclass UsersController extends Controller {\r\n  GET() {\r\n    return \"Hello form UsersController\";\r\n  }\r\n\r\n  // You can also add additional route method like this\r\n  POST() {\r\n    // ...\r\n  }\r\n\r\n  // Other routes available are PUT, PATCH, DELETE and OPTIONS\r\n}\r\n\r\napp.add([\r\n  {\r\n    path: \"user\",\r\n    controller: UsersController,\r\n  },\r\n]);\r\n```\r\n\r\nIf you want to add middleware a middleware to a specific method you can add the `middleware` property in a controller.\r\n\r\n```ts\r\nclass UsersController extends Controller {\r\n  middleware = {\r\n    GET: [middleware], // This middleware will be added to the `GET` method below\r\n  };\r\n\r\n  GET() {\r\n    //  ...\r\n  }\r\n}\r\n```\r\n\r\n```\r\nNOTE: A controller has no `children` property\r\n```\r\n\r\n## SERVICES\r\n\r\nA service is an injectable class that can be used inside of a controller or another service.\r\n\r\n```ts\r\nexport class UsersServices extends Services {\r\n  // Every function inside the service can be accessed by the class its injected\r\n  // All public properties are also accessible\r\n  // A service is instatiated once and making it a singleton\r\n\r\n  add() {\r\n    // ...\r\n  }\r\n}\r\n\r\nclass UsersController extends Controller {\r\n  constructor(userServices: UsersServices) {\r\n    super();\r\n  }\r\n\r\n  addUser() {\r\n    // This `add` function coming from the `UsersService`.\r\n    // It is accessible on this controller via dependency injection.\r\n    // MayaJs automatically instantiated it and created it singleton instance.\r\n    this.userServices.add();\r\n  }\r\n}\r\n```\r\n\r\n```\r\nNOTE: A `child` route can also have its own `children`.\r\n```\r\n\r\n## MODULE\r\n\r\nA module is a like a container of routes, controller and services that act on its own. This will allow your code to modular and shareable accross all routes.\r\n\r\n```ts\r\nclass UsersModule extends MayaJsModule {\r\n  // List of `module` or `services` that this module will use for its controllers\r\n  imports = [];\r\n  // List of controllers that this module will use\r\n  declarations = [];\r\n  // List of services that can be use inside this module\r\n  providers = [];\r\n  // List of services that this module will exports that can be used by other modules\r\n  exports = [];\r\n  // List of dependencies that will be injected to this module\r\n  dependencies = [];\r\n}\r\n```\r\n\r\nAs you can see when we create a module we dont have any way to add routes on it. Below is an example of implementation of how to add a `RouterModule` for this module to add routes.\r\n\r\n```ts\r\nimport { UsersController, UsersIdController } from \"./controller\";\r\nimport { RouterModule } from \"@mayajs/router\";\r\nimport { UsersServices } from \"./services\";\r\n\r\n// Define the routes\r\nconst routes = [\r\n  {\r\n    path: \"/\",\r\n    controller: UsersController,\r\n  },\r\n  {\r\n    path: \":id\",\r\n    controller: UsersIdController,\r\n  },\r\n];\r\n\r\nexport class UsersModule extends MayaJsModule {\r\n  // User `RouterModule.forRoot` to inject the routes\r\n  imports = [RouterModule.forRoot(routes)];\r\n  // Declare the controllers that will be used inside the routes\r\n  declarations = [UsersIdController, UsersController];\r\n}\r\n```\r\n\r\n## CUSTOM MODULE\r\n\r\nUnlike the common mayajs module, custom modules provide other functionality aside from managing your controllers. One example of this the `RouterModule` that is reponsible for adding routes to your module. A key concept of a custom module is it has an `invoke` and `forRoot` function that provides additional functionalities.\r\n\r\n```ts\r\nexport class UsersModule extends CustomModule {\r\n  invoke() {\r\n    // This function will run after an instance of this module is created\r\n    // But the providers will stay singleton on each instance\r\n  }\r\n\r\n  static forRoot(options: any) {\r\n    return {\r\n      module: UsersModule, // Returns the current module reference\r\n      providers: [], // List of providers that this module will use on its controllers\r\n    };\r\n  }\r\n}\r\n```\r\n\r\nNow we know how to create a module but how we can call it on our routes. We are now introducing to `loadChildren` property of our route object. MayaJs will automatically resolve the module asynchronously when the path is added on the route list.\r\n\r\n```ts\r\nimport maya from \"@mayajs/router\";\r\nimport http from \"http\";\r\n\r\nconst app = maya();\r\n\r\napp.add([\r\n  {\r\n    path: \"users\",\r\n    // We are using dynamic importing so we don't need it to manually import the module in the file\r\n    // MayaJs will resolve the module asynchronously\r\n    loadChildren: () => import(\"./users.module\").then((m) => m.UsersModule),\r\n  },\r\n]);\r\n```\r\n\r\n## Collaborating\r\n\r\nSee collaborating guides [here.](https://github.com/mayajs/maya/edit/master/COLLABORATOR_GUIDE.md)\r\n\r\n## People\r\n\r\nAuthor and maintainer [Mac Ignacio](https://github.com/macign)\r\n\r\n## License\r\n\r\n[MIT](https://github.com/mayajs/router/blob/develop/LICENSE)\r\n","readmeFilename":"README.md","_id":"@mayajs/router@0.4.0-rc1","_nodeVersion":"12.16.1","_npmVersion":"6.13.4","dist":{"integrity":"sha512-vqJmSCNXINO1jBgqoFCirz4a4/BJJevlwR2A8FhJ2pHRjTDGERPwoxCFMT7UYzYBp98aAVdFu1THgA9hzU0H3A==","shasum":"64969725198bc5a9491e2ce1badc41f775736575","tarball":"https://registry.npmjs.org/@mayajs/router/-/router-0.4.0-rc1.tgz","fileCount":37,"unpackedSize":62546,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgeBAXCRA9TVsSAnZWagAAdBAP/2zdKGlP6Wkp5DyaSR52\nGdNjhrGW5MAqqUZDYzhsFkT0DedTEt8vIB6zlr16QW27QaGt7tXQQCaleOmO\nJBwuBsTVWBBQRt0+NNcNas2TzW5KZVEu6bNfRtGkeshxtdxXhs65nH3LROCl\nwCw8SBI4zxpX1QwSK+eMw8zWL1Yia4XeU4DVgu+4YXLccgk2j1iSb3k8svEq\nK1v9qfkXCLQkEXHUWFFF4MrbnigRiZUlb1JfAuz7fyrIBqbUuXFrKzBJV0+z\nVRVCU3fA7zvsUVpaoexUqSIdiPUIIsvUNHfikXvfYytCPKzNoTphclfka7Mr\nY5ZF9EdePm7uyhdovmg81ys9XCJ0WFs6gOgoOpP/YY7MTpHQLDEPRGLjLKB9\np+dnoET1PpbkhVPdTChLzHFZe0owhgXyBhRDRehlWbJTPIJvgdh6k+qIGjTU\nKE1j8DJwWGnUwYV5uorVsFnJnlRI2mr30y+CFahpgTJCiNZjrhTZeP9N3jZG\niXeahyTUjn4raijUhEgB1bQ6XuN4jvrz7svvfDi4gofySfxqWAdix5LZWUty\nviz8hRcILg14F0P8/xJw5i1Qf1zJGTlyyQnfP1RFZcmrE7yae5ga7peBQRY9\nEnn22qF5scwr8USqO6fH9XE2AUNf+yeVkE24AZqwNXlnGcDmaIcqrftNlMuG\nLTn3\r\n=HChk\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIB7UuYQpg5ZGWhRGAY2UWQHV/9kh4fOnYffmG7FeFJawAiBAnyTDXXnzzvsWN9WspsE7H1+Z3ZouqSqq8gdfXqSsSA=="}]},"_npmUser":{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"},"directories":{},"maintainers":[{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/router_0.4.0-rc1_1618481175449_0.13480726225510842"},"_hasShrinkwrap":false},"0.4.0-rc2":{"name":"@mayajs/router","version":"0.4.0-rc2","description":"Simple NodeJS routing library created using Typescript","main":"index.js","scripts":{"clean":"rimraf interface && rimraf index.js && rimraf index.d.ts && rimraf utils && rimraf router && rimraf lib && rimraf class && rimraf exceptions && rimraf types","postpack":"npm run clean && node ./scripts/restore-package.js"},"keywords":["nodejs","server","router","typescript","library","REST","API","mayajs"],"author":{"name":"Mark Anthony C. Ignacio"},"license":"MIT","engines":{"node":">= 0.10.0"},"_resolved":"","_integrity":"","_from":"file:mayajs-router-0.4.0-rc2.tgz","readme":"<h1 align=\"center\">MayaJS Router</h1>\r\n<p align=\"center\"><img src=\"https://github.com/mayajs/maya/blob/master/maya.svg\" ></p>\r\n<h2 align=\"center\">Lightweight, simple and fast NodeJS Router developed using Typescript.</h2>\r\n<p align=\"center\">\r\n  <a href=\"https://www.npmjs.com/package/@mayajs/router\"><img src=\"https://img.shields.io/npm/v/@mayajs/router.svg?style=for-the-badge&logo=appveyor\" alt=\"Version\"></a>\r\n  <a href=\"https://www.npmjs.com/package/@mayajs/router\"><img src=\"https://img.shields.io/npm/dm/@mayajs/router.svg?style=for-the-badge&logo=appveyor\" alt=\"Downloads\"></a>\r\n  <a href=\"https://www.npmjs.com/package/@mayajs/router\"><img src=\"https://img.shields.io/npm/l/@mayajs/router?style=for-the-badge&logo=appveyor\" alt=\"License\"></a>\r\n  <a href=\"https://github.com/microsoft/typescript-tslint-plugin\"><img src=\"https://img.shields.io/badge/code%20style-standard-blue.svg?style=for-the-badge&logo=appveyor\" alt=\"Code Style\"></a>\r\n</p>\r\n\r\n## Motivation\r\n\r\nYup another **ExpressJS** like library. We develop **@mayajs/router** not to compete but to have our own router for our other projects like [@mayajs/router](https://github.com/mayajs/maya#readme). As much as possible we don't want to rely on other framework/library to create our own projects. This is just for maintainability and ease of transition for future updates.\r\n\r\n## Roadmap\r\n\r\nYou can see the detail roadmap of the project [here.](https://github.com/mayajs/router/blob/master/ROADMAP.md)\r\n\r\n## Suggestions\r\n\r\nFor suggestions and features you want to see in the future you can visit our [issues section.](https://github.com/mayajs/router/issues)\r\n\r\n## Getting started\r\n\r\nBefore installing this package make sure to download and install Node.js 10 or higher.\r\n\r\n<sub>**To check your node version**</sub>\r\n\r\n```shell\r\nnpm -v\r\n```\r\n\r\nFor new project kindly initialize npm using the command below or see documentation [here](https://docs.npmjs.com/creating-a-package-json-file).\r\n\r\n```shell\r\nnpm init\r\n```\r\n\r\nInstallation via command-line\r\n\r\n```shell\r\nnpm i @mayajs/router\r\n```\r\n\r\n## Features\r\n\r\n- Simple interface\r\n- Built with TypeScript\r\n- Uses native Nodejs API\r\n- Supports beginners to advance syntaxes\r\n- Can be use both `Function` based and `Class` based coding style\r\n- Dependency Injection\r\n- Fast execution\r\n- Easy to learn\r\n- Modular code\r\n\r\n## Quick Start\r\n\r\nThe easiest way to get started is to create a simple route\r\n\r\n```ts\r\nimport maya from \"@mayajs/router\";\r\nimport http from \"http\";\r\n\r\nconst PORT = 3000;\r\nconst app = maya();\r\n\r\napp.add([\r\n  {\r\n    path: \"/\",\r\n    GET: () => \"Hello, World\",\r\n  },\r\n]);\r\n\r\nhttp.createServer(app).listen(PORT, () => console.log(`Server listening on port ${PORT}.`));\r\n```\r\n\r\n## ROUTE\r\n\r\nDefining routes in MayaJs is like creating a JSON object.\r\n\r\n```ts\r\nconst user = {\r\n  path: \"user\",\r\n  GET: () => {\r\n    //  ...\r\n  },\r\n  POST: () => {\r\n    //  ...\r\n  },\r\n  PUT: () => {\r\n    //  ...\r\n  },\r\n  PATCH: () => {\r\n    //  ...\r\n  },\r\n  DELETE: () => {\r\n    //  ...\r\n  },\r\n  OPTIONS: () => {\r\n    //  ...\r\n  },\r\n};\r\n```\r\n\r\nAs seen above each method name has a `callback` function. Mayajs will set the correct `content-type` based on what the method callback will return.\r\n\r\n```ts\r\nconst route = {\r\n  path: \"user\",\r\n  GET: () => {\r\n    // This will return `undefined`\r\n    // This will have a content-type of \"text/plain\"\r\n  },\r\n  POST: () => {\r\n    return \"Hello\"; // This will have a content-type of \"text/plain\"\r\n  },\r\n  PUT: () => {\r\n    return { message: \"Hello\" }; // This will have a content-type of \"application/json\"\r\n  },\r\n  PATCH: () => {\r\n    return \"<h1>Hello</h1>\"; // This will have a content-type of \"text/html\"\r\n  },\r\n};\r\n```\r\n\r\nIncase you need to use a middleware for an specific route method you need to create a route object instead.\r\n\r\n```ts\r\nconst route = {\r\n  path: \"user\",\r\n  GET: {\r\n    middlewares: [middleware],\r\n    callback: () => {\r\n      // ...\r\n    },\r\n  },\r\n};\r\n```\r\n\r\n## PARAMS\r\n\r\nMayaJs passes a context object on each route method. You can acces the route params by destructuring the context object on the callback method.\r\n\r\n```ts\r\nconst route = {\r\n  path: \"user/:id\",\r\n  GET: ({ params }) => {\r\n    // `params` object contains the value of `id` define on the path above e.g. `user/hello`\r\n    return params.id; // This has a value of \"hello\"\r\n  },\r\n};\r\n```\r\n\r\n## QUERY STRING\r\n\r\nYou can also access the query string using the context object provided by MayaJs on your route method callback function.\r\n\r\n```ts\r\nconst route = {\r\n  path: \"user\",\r\n  GET: ({ query }) => {\r\n    // `query` object contains all the value on your query string e.g. `user?id=1`\r\n    return query.id; // This has a value of 1\r\n  },\r\n};\r\n```\r\n\r\n## BODY\r\n\r\nRequest body is also accessible in the context but you need a middleware before you can actually uses. There is a popular middleware called [body-parser](https://www.npmjs.com/package/body-parser) that we can use to achieve this.\r\n\r\n```ts\r\nimport maya from \"@mayajs/router\";\r\n// Third party middleware you need to install\r\nimport bodyParser from \"body-parser\";\r\n\r\nconst app = maya();\r\n\r\n// Initialize body parser for mayajs to use it internally\r\napp.use(bodyParser.json());\r\napp.use(bodyParser.urlencoded({ extended: false }));\r\n\r\nconst route = {\r\n  path: \"user\",\r\n  POST: ({ body }) => {\r\n    // `body` object contains all the value from the request body\r\n    return body; // This has a value of req.body\r\n  },\r\n};\r\n\r\napp.add([route]);\r\n```\r\n\r\n## MIDDLEWARES\r\n\r\nAs seen above how we used third party middlewares to parse the request body. We can also create our own middlewares. Although MayaJs supports all [ExpressJs Middlewares](https://expressjs.com/en/resources/middleware.html), we also can create a `MayaJsMiddleware` of our own. The context is where you can access `params, query and body` objects.\r\n\r\n```ts\r\nrouter.use((context, next, error) => {\r\n  // This `error` variable comes from the previous middleware\r\n  console.log(error);\r\n\r\n  // The `next` function will trigger the end of this callback function\r\n  // and execute the next middleware in the list\r\n  next(\"Error message or any value that you want to pass to the next middleware\");\r\n});\r\n```\r\n\r\n## CHILD ROUTES\r\n\r\nA child route is a route that appended to its parent route. It can be added using the `children` property from the route object.\r\n\r\n```ts\r\nconst child = {\r\n  path: \"child\",\r\n  GET: () => \"This is from a child route\", // You can call this route by `users/child`\r\n};\r\n\r\nconst parent = {\r\n  path: \"user\",\r\n  children: [child], // This is a list of routes.\r\n};\r\n\r\napp.add([parent]);\r\n```\r\n\r\n## CONTROLLER\r\n\r\nA controller is a class that act as a replacement for the route method objects. It can be used to make your code more modular and manageable when your code base get bigger.\r\n\r\n```ts\r\nclass UsersController extends Controller {\r\n  GET() {\r\n    return \"Hello form UsersController\";\r\n  }\r\n\r\n  // You can also add additional route method like this\r\n  POST() {\r\n    // ...\r\n  }\r\n\r\n  // Other routes available are PUT, PATCH, DELETE and OPTIONS\r\n}\r\n\r\napp.add([\r\n  {\r\n    path: \"user\",\r\n    controller: UsersController,\r\n  },\r\n]);\r\n```\r\n\r\nIf you want to add middleware a middleware to a specific method you can add the `middleware` property in a controller.\r\n\r\n```ts\r\nclass UsersController extends Controller {\r\n  middleware = {\r\n    GET: [middleware], // This middleware will be added to the `GET` method below\r\n  };\r\n\r\n  GET() {\r\n    //  ...\r\n  }\r\n}\r\n```\r\n\r\n```\r\nNOTE: A controller has no `children` property\r\n```\r\n\r\n## SERVICES\r\n\r\nA service is an injectable class that can be used inside of a controller or another service.\r\n\r\n```ts\r\nexport class UsersServices extends Services {\r\n  // Every function inside the service can be accessed by the class its injected\r\n  // All public properties are also accessible\r\n  // A service is instatiated once and making it a singleton\r\n\r\n  add() {\r\n    // ...\r\n  }\r\n}\r\n\r\nclass UsersController extends Controller {\r\n  constructor(userServices: UsersServices) {\r\n    super();\r\n  }\r\n\r\n  addUser() {\r\n    // This `add` function coming from the `UsersService`.\r\n    // It is accessible on this controller via dependency injection.\r\n    // MayaJs automatically instantiated it and created it singleton instance.\r\n    this.userServices.add();\r\n  }\r\n}\r\n```\r\n\r\n```\r\nNOTE: A `child` route can also have its own `children`.\r\n```\r\n\r\n## MODULE\r\n\r\nA module is a like a container of routes, controller and services that act on its own. This will allow your code to modular and shareable accross all routes.\r\n\r\n```ts\r\nclass UsersModule extends MayaJsModule {\r\n  // List of `module` or `services` that this module will use for its controllers\r\n  imports = [];\r\n  // List of controllers that this module will use\r\n  declarations = [];\r\n  // List of services that can be use inside this module\r\n  providers = [];\r\n  // List of services that this module will exports that can be used by other modules\r\n  exports = [];\r\n  // List of dependencies that will be injected to this module\r\n  dependencies = [];\r\n}\r\n```\r\n\r\nAs you can see when we create a module we dont have any way to add routes on it. Below is an example of implementation of how to add a `RouterModule` for this module to add routes.\r\n\r\n```ts\r\nimport { UsersController, UsersIdController } from \"./controller\";\r\nimport { RouterModule } from \"@mayajs/router\";\r\nimport { UsersServices } from \"./services\";\r\n\r\n// Define the routes\r\nconst routes = [\r\n  {\r\n    path: \"/\",\r\n    controller: UsersController,\r\n  },\r\n  {\r\n    path: \":id\",\r\n    controller: UsersIdController,\r\n  },\r\n];\r\n\r\nexport class UsersModule extends MayaJsModule {\r\n  // User `RouterModule.forRoot` to inject the routes\r\n  imports = [RouterModule.forRoot(routes)];\r\n  // Declare the controllers that will be used inside the routes\r\n  declarations = [UsersIdController, UsersController];\r\n}\r\n```\r\n\r\n## CUSTOM MODULE\r\n\r\nUnlike the common mayajs module, custom modules provide other functionality aside from managing your controllers. One example of this the `RouterModule` that is reponsible for adding routes to your module. A key concept of a custom module is it has an `invoke` and `forRoot` function that provides additional functionalities.\r\n\r\n```ts\r\nexport class UsersModule extends CustomModule {\r\n  invoke() {\r\n    // This function will run after an instance of this module is created\r\n    // But the providers will stay singleton on each instance\r\n  }\r\n\r\n  static forRoot(options: any) {\r\n    return {\r\n      module: UsersModule, // Returns the current module reference\r\n      providers: [], // List of providers that this module will use on its controllers\r\n    };\r\n  }\r\n}\r\n```\r\n\r\nNow we know how to create a module but how we can call it on our routes. We are now introducing to `loadChildren` property of our route object. MayaJs will automatically resolve the module asynchronously when the path is added on the route list.\r\n\r\n```ts\r\nimport maya from \"@mayajs/router\";\r\nimport http from \"http\";\r\n\r\nconst app = maya();\r\n\r\napp.add([\r\n  {\r\n    path: \"users\",\r\n    // We are using dynamic importing so we don't need it to manually import the module in the file\r\n    // MayaJs will resolve the module asynchronously\r\n    loadChildren: () => import(\"./users.module\").then((m) => m.UsersModule),\r\n  },\r\n]);\r\n```\r\n\r\n## Collaborating\r\n\r\nSee collaborating guides [here.](https://github.com/mayajs/maya/edit/master/COLLABORATOR_GUIDE.md)\r\n\r\n## People\r\n\r\nAuthor and maintainer [Mac Ignacio](https://github.com/macign)\r\n\r\n## License\r\n\r\n[MIT](https://github.com/mayajs/router/blob/develop/LICENSE)\r\n","readmeFilename":"README.md","_id":"@mayajs/router@0.4.0-rc2","_nodeVersion":"12.16.1","_npmVersion":"6.13.4","dist":{"integrity":"sha512-DVINlm1xAUVWH33aCZetcLUuSit/zoHWmQeZPhNO6sqw3nx+/FTOeyZiuVFFM8lPZYgom1JLaECxwrTvIY3ICw==","shasum":"b238eabf625cdc53c56d1bc517b9c85fb120f170","tarball":"https://registry.npmjs.org/@mayajs/router/-/router-0.4.0-rc2.tgz","fileCount":37,"unpackedSize":62415,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgeCzMCRA9TVsSAnZWagAAQaUP/RQYI9Qcm+/Aq6yA45jt\n9BCSV3p4sUXpwuHSYVxmmJ0gvMnYdu/GsP+bOkgqWcOd8LgL4Sa+L8rX6fiV\nGjhN4q+qYdDTMN6yKHD/WK2M5aeRInV6vhp7GGnUs5Rop/EZJ8c84R3jE8dI\nFgyieMivc6ya132dOnRDC7kHejPfrfj+/bNgGDf1lIolsC3iSwY1plODQKbI\nP1DfZSsfFsq898nbTuI73JCrCsB2zfHfksNoj80TGRL7j8pt6IHTqvsjIUqW\nzU6OflVpc41x5KkWsQesKJL3G/Jycn0oLFWrfO5KHe34wcV+gahIcH1jFl02\ntDOFBE8QcH6bxGX/bzey8nfxnsfto71Wb/jMTf/rMS9pex9vwtq5uqYTvrFI\nIMA+bqiScTfCkRHJpz/aIxTZpnil8kuSOgiH9vJsO3QEW+3yTXIkrqLmgbkm\nyr23BkV9HtgeVtksr1N1XgGIzLlMK8dggQIVSPX/j/nsMCyu72T3EbwXhQLh\nm+fRQ7oGCPhlTWsIchyO2cLTymY5Eu0Do0Wse/P56W292QcDghhm+K3BlXTC\n+ebt+sgqQ83EB5wS6K30PdRQmrHDQMD/cWY2oRF4GGM72xLB8b3MQlvcbmVw\ncbNSkY0hdQaAMugTedq4uePU6oXX0JTuXF8Bx2S8RSURSqOaAUtE7K229AQu\nfjsi\r\n=NumZ\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEfFORWt+53o+KYPC4e8G7tY23pCcvKgbaJgkW7/jcdSAiEA602lPxGDmr77/XBgoW1q+B88HdEiWRXVx6oolAosqFE="}]},"_npmUser":{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"},"directories":{},"maintainers":[{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/router_0.4.0-rc2_1618488524372_0.6741066671765976"},"_hasShrinkwrap":false},"0.4.0-rc2.1":{"name":"@mayajs/router","version":"0.4.0-rc2.1","description":"Simple NodeJS routing library created using Typescript","main":"index.js","scripts":{"clean":"rimraf interface && rimraf index.js && rimraf index.d.ts && rimraf utils && rimraf router && rimraf lib && rimraf class && rimraf exceptions && rimraf types","postpack":"npm run clean && node ./scripts/restore-package.js"},"keywords":["nodejs","server","router","typescript","library","REST","API","mayajs"],"author":{"name":"Mark Anthony C. Ignacio"},"license":"MIT","engines":{"node":">= 0.10.0"},"_resolved":"","_integrity":"","_from":"file:mayajs-router-0.4.0-rc2.1.tgz","readme":"<h1 align=\"center\">MayaJS Router</h1>\r\n<p align=\"center\"><img src=\"https://github.com/mayajs/maya/blob/master/maya.svg\" ></p>\r\n<h2 align=\"center\">Lightweight, simple and fast NodeJS Router developed using Typescript.</h2>\r\n<p align=\"center\">\r\n  <a href=\"https://www.npmjs.com/package/@mayajs/router\"><img src=\"https://img.shields.io/npm/v/@mayajs/router.svg?style=for-the-badge&logo=appveyor\" alt=\"Version\"></a>\r\n  <a href=\"https://www.npmjs.com/package/@mayajs/router\"><img src=\"https://img.shields.io/npm/dm/@mayajs/router.svg?style=for-the-badge&logo=appveyor\" alt=\"Downloads\"></a>\r\n  <a href=\"https://www.npmjs.com/package/@mayajs/router\"><img src=\"https://img.shields.io/npm/l/@mayajs/router?style=for-the-badge&logo=appveyor\" alt=\"License\"></a>\r\n  <a href=\"https://github.com/microsoft/typescript-tslint-plugin\"><img src=\"https://img.shields.io/badge/code%20style-standard-blue.svg?style=for-the-badge&logo=appveyor\" alt=\"Code Style\"></a>\r\n</p>\r\n\r\n## Motivation\r\n\r\nYup another **ExpressJS** like library. We develop **@mayajs/router** not to compete but to have our own router for our other projects like [@mayajs/router](https://github.com/mayajs/maya#readme). As much as possible we don't want to rely on other framework/library to create our own projects. This is just for maintainability and ease of transition for future updates.\r\n\r\n## Roadmap\r\n\r\nYou can see the detail roadmap of the project [here.](https://github.com/mayajs/router/blob/master/ROADMAP.md)\r\n\r\n## Suggestions\r\n\r\nFor suggestions and features you want to see in the future you can visit our [issues section.](https://github.com/mayajs/router/issues)\r\n\r\n## Getting started\r\n\r\nBefore installing this package make sure to download and install Node.js 10 or higher.\r\n\r\n<sub>**To check your node version**</sub>\r\n\r\n```shell\r\nnpm -v\r\n```\r\n\r\nFor new project kindly initialize npm using the command below or see documentation [here](https://docs.npmjs.com/creating-a-package-json-file).\r\n\r\n```shell\r\nnpm init\r\n```\r\n\r\nInstallation via command-line\r\n\r\n```shell\r\nnpm i @mayajs/router\r\n```\r\n\r\n## Features\r\n\r\n- Simple interface\r\n- Built with TypeScript\r\n- Uses native Nodejs API\r\n- Supports beginners to advance syntaxes\r\n- Can be use both `Function` based and `Class` based coding style\r\n- Dependency Injection\r\n- Fast execution\r\n- Easy to learn\r\n- Modular code\r\n\r\n## Quick Start\r\n\r\nThe easiest way to get started is to create a simple route\r\n\r\n```ts\r\nimport maya from \"@mayajs/router\";\r\nimport http from \"http\";\r\n\r\nconst PORT = 3000;\r\nconst app = maya();\r\n\r\napp.add([\r\n  {\r\n    path: \"/\",\r\n    GET: () => \"Hello, World\",\r\n  },\r\n]);\r\n\r\nhttp.createServer(app).listen(PORT, () => console.log(`Server listening on port ${PORT}.`));\r\n```\r\n\r\n## ROUTE\r\n\r\nDefining routes in MayaJs is like creating a JSON object.\r\n\r\n```ts\r\nconst user = {\r\n  path: \"user\",\r\n  GET: () => {\r\n    //  ...\r\n  },\r\n  POST: () => {\r\n    //  ...\r\n  },\r\n  PUT: () => {\r\n    //  ...\r\n  },\r\n  PATCH: () => {\r\n    //  ...\r\n  },\r\n  DELETE: () => {\r\n    //  ...\r\n  },\r\n  OPTIONS: () => {\r\n    //  ...\r\n  },\r\n};\r\n```\r\n\r\nAs seen above each method name has a `callback` function. Mayajs will set the correct `content-type` based on what the method callback will return.\r\n\r\n```ts\r\nconst route = {\r\n  path: \"user\",\r\n  GET: () => {\r\n    // This will return `undefined`\r\n    // This will have a content-type of \"text/plain\"\r\n  },\r\n  POST: () => {\r\n    return \"Hello\"; // This will have a content-type of \"text/plain\"\r\n  },\r\n  PUT: () => {\r\n    return { message: \"Hello\" }; // This will have a content-type of \"application/json\"\r\n  },\r\n  PATCH: () => {\r\n    return \"<h1>Hello</h1>\"; // This will have a content-type of \"text/html\"\r\n  },\r\n};\r\n```\r\n\r\nIncase you need to use a middleware for an specific route method you need to create a route object instead.\r\n\r\n```ts\r\nconst route = {\r\n  path: \"user\",\r\n  GET: {\r\n    middlewares: [middleware],\r\n    callback: () => {\r\n      // ...\r\n    },\r\n  },\r\n};\r\n```\r\n\r\n## PARAMS\r\n\r\nMayaJs passes a context object on each route method. You can acces the route params by destructuring the context object on the callback method.\r\n\r\n```ts\r\nconst route = {\r\n  path: \"user/:id\",\r\n  GET: ({ params }) => {\r\n    // `params` object contains the value of `id` define on the path above e.g. `user/hello`\r\n    return params.id; // This has a value of \"hello\"\r\n  },\r\n};\r\n```\r\n\r\n## QUERY STRING\r\n\r\nYou can also access the query string using the context object provided by MayaJs on your route method callback function.\r\n\r\n```ts\r\nconst route = {\r\n  path: \"user\",\r\n  GET: ({ query }) => {\r\n    // `query` object contains all the value on your query string e.g. `user?id=1`\r\n    return query.id; // This has a value of 1\r\n  },\r\n};\r\n```\r\n\r\n## BODY\r\n\r\nRequest body is also accessible in the context but you need a middleware before you can actually uses. There is a popular middleware called [body-parser](https://www.npmjs.com/package/body-parser) that we can use to achieve this.\r\n\r\n```ts\r\nimport maya from \"@mayajs/router\";\r\n// Third party middleware you need to install\r\nimport bodyParser from \"body-parser\";\r\n\r\nconst app = maya();\r\n\r\n// Initialize body parser for mayajs to use it internally\r\napp.use(bodyParser.json());\r\napp.use(bodyParser.urlencoded({ extended: false }));\r\n\r\nconst route = {\r\n  path: \"user\",\r\n  POST: ({ body }) => {\r\n    // `body` object contains all the value from the request body\r\n    return body; // This has a value of req.body\r\n  },\r\n};\r\n\r\napp.add([route]);\r\n```\r\n\r\n## MIDDLEWARES\r\n\r\nAs seen above how we used third party middlewares to parse the request body. We can also create our own middlewares. Although MayaJs supports all [ExpressJs Middlewares](https://expressjs.com/en/resources/middleware.html), we also can create a `MayaJsMiddleware` of our own. The context is where you can access `params, query and body` objects.\r\n\r\n```ts\r\nrouter.use((context, next, error) => {\r\n  // This `error` variable comes from the previous middleware\r\n  console.log(error);\r\n\r\n  // The `next` function will trigger the end of this callback function\r\n  // and execute the next middleware in the list\r\n  next(\"Error message or any value that you want to pass to the next middleware\");\r\n});\r\n```\r\n\r\n## CHILD ROUTES\r\n\r\nA child route is a route that appended to its parent route. It can be added using the `children` property from the route object.\r\n\r\n```ts\r\nconst child = {\r\n  path: \"child\",\r\n  GET: () => \"This is from a child route\", // You can call this route by `users/child`\r\n};\r\n\r\nconst parent = {\r\n  path: \"user\",\r\n  children: [child], // This is a list of routes.\r\n};\r\n\r\napp.add([parent]);\r\n```\r\n\r\n## CONTROLLER\r\n\r\nA controller is a class that act as a replacement for the route method objects. It can be used to make your code more modular and manageable when your code base get bigger.\r\n\r\n```ts\r\nclass UsersController extends Controller {\r\n  GET() {\r\n    return \"Hello form UsersController\";\r\n  }\r\n\r\n  // You can also add additional route method like this\r\n  POST() {\r\n    // ...\r\n  }\r\n\r\n  // Other routes available are PUT, PATCH, DELETE and OPTIONS\r\n}\r\n\r\napp.add([\r\n  {\r\n    path: \"user\",\r\n    controller: UsersController,\r\n  },\r\n]);\r\n```\r\n\r\nIf you want to add middleware a middleware to a specific method you can add the `middleware` property in a controller.\r\n\r\n```ts\r\nclass UsersController extends Controller {\r\n  middleware = {\r\n    GET: [middleware], // This middleware will be added to the `GET` method below\r\n  };\r\n\r\n  GET() {\r\n    //  ...\r\n  }\r\n}\r\n```\r\n\r\n```\r\nNOTE: A controller has no `children` property\r\n```\r\n\r\n## SERVICES\r\n\r\nA service is an injectable class that can be used inside of a controller or another service.\r\n\r\n```ts\r\nexport class UsersServices extends Services {\r\n  // Every function inside the service can be accessed by the class its injected\r\n  // All public properties are also accessible\r\n  // A service is instatiated once and making it a singleton\r\n\r\n  add() {\r\n    // ...\r\n  }\r\n}\r\n\r\nclass UsersController extends Controller {\r\n  constructor(userServices: UsersServices) {\r\n    super();\r\n  }\r\n\r\n  addUser() {\r\n    // This `add` function coming from the `UsersService`.\r\n    // It is accessible on this controller via dependency injection.\r\n    // MayaJs automatically instantiated it and created it singleton instance.\r\n    this.userServices.add();\r\n  }\r\n}\r\n```\r\n\r\n```\r\nNOTE: A `child` route can also have its own `children`.\r\n```\r\n\r\n## MODULE\r\n\r\nA module is a like a container of routes, controller and services that act on its own. This will allow your code to modular and shareable accross all routes.\r\n\r\n```ts\r\nclass UsersModule extends MayaJsModule {\r\n  // List of `module` or `services` that this module will use for its controllers\r\n  imports = [];\r\n  // List of controllers that this module will use\r\n  declarations = [];\r\n  // List of services that can be use inside this module\r\n  providers = [];\r\n  // List of services that this module will exports that can be used by other modules\r\n  exports = [];\r\n  // List of dependencies that will be injected to this module\r\n  dependencies = [];\r\n}\r\n```\r\n\r\nAs you can see when we create a module we dont have any way to add routes on it. Below is an example of implementation of how to add a `RouterModule` for this module to add routes.\r\n\r\n```ts\r\nimport { UsersController, UsersIdController } from \"./controller\";\r\nimport { RouterModule } from \"@mayajs/router\";\r\nimport { UsersServices } from \"./services\";\r\n\r\n// Define the routes\r\nconst routes = [\r\n  {\r\n    path: \"/\",\r\n    controller: UsersController,\r\n  },\r\n  {\r\n    path: \":id\",\r\n    controller: UsersIdController,\r\n  },\r\n];\r\n\r\nexport class UsersModule extends MayaJsModule {\r\n  // User `RouterModule.forRoot` to inject the routes\r\n  imports = [RouterModule.forRoot(routes)];\r\n  // Declare the controllers that will be used inside the routes\r\n  declarations = [UsersIdController, UsersController];\r\n}\r\n```\r\n\r\n## CUSTOM MODULE\r\n\r\nUnlike the common mayajs module, custom modules provide other functionality aside from managing your controllers. One example of this the `RouterModule` that is reponsible for adding routes to your module. A key concept of a custom module is it has an `invoke` and `forRoot` function that provides additional functionalities.\r\n\r\n```ts\r\nexport class UsersModule extends CustomModule {\r\n  invoke() {\r\n    // This function will run after an instance of this module is created\r\n    // But the providers will stay singleton on each instance\r\n  }\r\n\r\n  static forRoot(options: any) {\r\n    return {\r\n      module: UsersModule, // Returns the current module reference\r\n      providers: [], // List of providers that this module will use on its controllers\r\n    };\r\n  }\r\n}\r\n```\r\n\r\nNow we know how to create a module but how we can call it on our routes. We are now introducing to `loadChildren` property of our route object. MayaJs will automatically resolve the module asynchronously when the path is added on the route list.\r\n\r\n```ts\r\nimport maya from \"@mayajs/router\";\r\nimport http from \"http\";\r\n\r\nconst app = maya();\r\n\r\napp.add([\r\n  {\r\n    path: \"users\",\r\n    // We are using dynamic importing so we don't need it to manually import the module in the file\r\n    // MayaJs will resolve the module asynchronously\r\n    loadChildren: () => import(\"./users.module\").then((m) => m.UsersModule),\r\n  },\r\n]);\r\n```\r\n\r\n## Collaborating\r\n\r\nSee collaborating guides [here.](https://github.com/mayajs/maya/edit/master/COLLABORATOR_GUIDE.md)\r\n\r\n## People\r\n\r\nAuthor and maintainer [Mac Ignacio](https://github.com/macign)\r\n\r\n## License\r\n\r\n[MIT](https://github.com/mayajs/router/blob/develop/LICENSE)\r\n","readmeFilename":"README.md","_id":"@mayajs/router@0.4.0-rc2.1","_nodeVersion":"12.16.1","_npmVersion":"6.13.4","dist":{"integrity":"sha512-U4GhUSxCc9rp7PNod+JMdo/KuZBxCrnT/ZB51V2qf90HytYu2Y4KiZgjl3nHDZ8od56pgJRP2Wn6FfMb8dgQxg==","shasum":"fcb77d0a0a38647da63204ea349d022bcc212216","tarball":"https://registry.npmjs.org/@mayajs/router/-/router-0.4.0-rc2.1.tgz","fileCount":37,"unpackedSize":62819,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgeEH8CRA9TVsSAnZWagAAYPgP/1cbIa95yMslBkWVLj7r\nJ5vpc8lu19SKktyNiIIxD4QrvoVjsjCB3cKQcW+Va4c8cuUZRRRBrE4vkM4C\nRTEauNCh3hJnoMX1TyWav/GQmNOGPByZoKi0BjyfhIu57SghEErtfN6NdboT\nFjzBgmwo1XhujCrlKd2vHVOOR1pX3ioj95jfcc9Pguqx7PGywrkIzU5Oyfof\nKnMC6DLaIyUTvZgzx/cjd16ilsG1xAYVw4FwDaMG/bFicO2WLFKkXpN8oIlU\n9WIYaYwqAOnN7h+evXY9V+Lu/w3NStU8sQ+PvoFMEeV6vC0L74vO8e7PYwvO\noPVqnMEBVFVt+VhDq+mlCVUawNfTU7Jfl4e/1+tnKmLhSEh/DYgSP9Az72W6\nKpY4h+/V3157Z+vbBGv2yuVulI1vM5Ecsqwfo9ombX3nvDvvqpHCUKvg+lBP\nnLSfdxxtFz141tBOz2wU8sBIy3MIEnM4RBW9TSLMBXcFNYG7BqIC+CSJ2+Po\nR42jHRtIyflXP+S2k70ds8iH1iLKTtAGMF/jg/ChrcJZT9IsFSQ/A+LXcAhZ\nidjJGcLihKYtKR6QmOJovwlTXkDiKWBZzVafEZvuCK307QF4jTNjW58qeO3N\nvg7Hxbr2Z22RKB2tl5UMNU1qhQWjEukeLEg/Jh/VjE51Sbo3oqsc1W1vL7a6\nnNnG\r\n=T4aC\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDWosgbU8MQSIUWb3kWtfhLUxbmHJckW+4YEg6SgIA3EwIgDyf11VChmy0Nm94ctRaz4S/P/vB04xpIjlinJ7UbIkQ="}]},"_npmUser":{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"},"directories":{},"maintainers":[{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/router_0.4.0-rc2.1_1618493947799_0.09644727347417281"},"_hasShrinkwrap":false},"0.4.0":{"name":"@mayajs/router","version":"0.4.0","description":"Simple NodeJS routing library created using Typescript","main":"lib/index.js","scripts":{"clean":"rimraf interface && rimraf index.js && rimraf index.d.ts && rimraf utils && rimraf router && rimraf lib && rimraf class && rimraf exceptions && rimraf types","tgz":"rimraf *.tgz","package":"node ./scripts/clean-package.js","start":"npm run clean && npm run tgz && tsc -w","prepack":"npm run clean && npm run package && tsc --outDir ."},"keywords":["nodejs","server","router","typescript","library","REST","API","mayajs"],"author":{"name":"Mark Anthony C. Ignacio"},"license":"MIT","devDependencies":{"@types/node":"^13.11.0","jest":"^25.2.7","rimraf":"^3.0.2","ts-node":"^8.8.2","typescript":"^3.8.3"},"engines":{"node":">= 0.10.0"},"gitHead":"dcef6da5e2f8a7d2b4facae7a652c6fd0d27a991","_id":"@mayajs/router@0.4.0","_nodeVersion":"12.16.1","_npmVersion":"6.13.4","dist":{"integrity":"sha512-ByZDb0NDg9r1HUWiU/3A4kB1k/ip+jw1kTM8tP3USz4jOdy3lwJgVWyJI/803NK/4bAb3HIKXeFtKWLnc7Qhwg==","shasum":"cd6b7dc4b9d7d3cb39f51779ba15a5a101a50af3","tarball":"https://registry.npmjs.org/@mayajs/router/-/router-0.4.0.tgz","fileCount":37,"unpackedSize":63282,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgeEmPCRA9TVsSAnZWagAAXRsQAJUFI6dmQMtIQ8Cs/LTD\niSQFwMiv5VMvumfCwTJYuXBqgiYzYflhfPsMS6WDaY7dDQPCMKw3Y87fY0Z1\n5brjcbJgN6+YElkWvbS0TLxEODm/UvKrSnWy73p6Z79qgpj9rM37PFLAEwyR\nAYuUXI74vx3hEn9oWnhNBZihklEzkYXym5lLnstTxasu1TYHhd2bQ4HRm9Pw\ny5ChDMsPoEDIcjkaXnwODktnLWQJxsYNSnBLbzw6GUr7ZKCuD9KZTVFJT0L0\nDqNhqle6amVXQwNitflxPQlX6vqJCOxdvU4kU9lduoj9oe6QRE8000owyyxB\ncnN/uPEReM+DiLKYmKBXWCFy6iIs4a9EWH4VUwkgU3bVx8Piuu6jhn+l1z3x\noPxxirBYb/vJzNgeYYCyEo40EVvyS2uuzFszSsmlb/TfNYHNSRODIFjW/+sv\nI5qZeFsajqw0rRrF6A74/c7KOsKu1yquR/yBt8ph2acuenGBqMkvGz9l/Vky\ngoSEhId9K4bZfRXH+pNpWj9C/dO9vvvirXIIO+HvqAp98ZxLVwOFSCL5qDcm\nCJ9TYaFdxToj5UWedxItfNEQRuGAM8H4pqBSfpY4mKSibW0Gv24tgBQyqUQn\nObMtTJtZKj3SYVNreA45PtdJRQQi83RMB/9f8skSKCYqjF3rN5SJWh1hO1lI\n/WGb\r\n=uMh/\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHryOALk2NDxG5XAd1gyBTSgq5wMOvuJTqmgCUfV3i2DAiBwB/RxKKv+RqMN4b+Bpq2uEZU85TwA8iA6TBCUpiRIFQ=="}]},"_npmUser":{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"},"directories":{},"maintainers":[{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/router_0.4.0_1618495886658_0.04733848042088473"},"_hasShrinkwrap":false},"0.4.1":{"name":"@mayajs/router","version":"0.4.1","description":"Simple NodeJS routing library created using Typescript","main":"lib/index.js","scripts":{"clean":"rimraf interface && rimraf index.js && rimraf index.d.ts && rimraf utils && rimraf router && rimraf lib && rimraf class && rimraf exceptions && rimraf types","tgz":"rimraf *.tgz","package":"node ./scripts/clean-package.js","start":"npm run clean && npm run tgz && tsc -w","prepack":"npm run clean && npm run package && tsc --outDir ."},"keywords":["nodejs","server","router","typescript","library","REST","API","mayajs"],"author":{"name":"Mark Anthony C. Ignacio"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/mayajs/router.git"},"bugs":{"url":"https://github.com/mayajs/router/issues"},"homepage":"https://github.com/mayajs/router#readme","devDependencies":{"@types/node":"^13.11.0","jest":"^25.2.7","rimraf":"^3.0.2","ts-node":"^8.8.2","typescript":"^3.8.3"},"engines":{"node":">= 0.10.0"},"gitHead":"52bcff823d1c86f6c420310a925971c21d85b131","_id":"@mayajs/router@0.4.1","_nodeVersion":"12.16.1","_npmVersion":"6.13.4","dist":{"integrity":"sha512-QB9Cw91Za1lcN1Fg6bWisG3FNlqBSFaHYbQUWln50heXlZXHj5nOkNhFi5IfKt++5GALnzLHUK0d3CMjyC4dcw==","shasum":"2826202cfa732cbafc8a81d09cb2f2c983c59000","tarball":"https://registry.npmjs.org/@mayajs/router/-/router-0.4.1.tgz","fileCount":37,"unpackedSize":63608,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgere9CRA9TVsSAnZWagAAOf0QAJnhe/LUVUKoAeuj1isX\n6SK/TtzWXEqeKWBtbuJjD6CybgIhlpInyKSw7JSv/H4py9K82sas0cwUfNNf\ngonOPzKk7eT1pNVn6kMCcZZgf/Ylsl4z6wT/zoxv0Rvvk10m56BfCLmc/xhg\n71yVlNouuimwrMikzc6EbHiT3eFyyBF9fl6cPCDBblWElX0G01J1H1kU+opm\nu6yTnmdPJBjwokrG5jxOcdYdwYtAQUmPYf6lGPoj4iDFGELPKIhcMfobpBmB\nYWhR9OAQd4TANjcXUwLCW54aZ5m6zePc5XZuSwgFfb4HWZInbd3BaGnQNF7T\nEk6jD0hSiQ+kvwUSXOKf/VW4L5VL1Zs5l7xqf/YAjLoEOGd/Y9LfhYdveHLu\nOZaZEqlZBA3YAn7HN4UB0jc6ljMkQ7o5Ay6azjW6IqrN25UlTBdRzDX59Udq\njPaoxkHRJJjTnM9nq32ZPQ8PQqYmFKxtZsaXzgON71YHpAtzEuL2jWd0C+QT\n1aTGkI41dzX3k79HZ//+xOO/E50cEDAHcUiIJi84seb4KtEwaGX857ypQckj\n//8NVUSKROCXK7lUqgqBleUiq/mYK0g1hdxQ1nbeV3weXZpk23WyknHtYxxv\nVohWhPHSOwjmSTO2EHfjn/ZKutIEgqITtQTIJ33UJ0A5U8YVx/rh3nkarENu\npkqJ\r\n=kNCz\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBJj/HFehzDN6Z1r42XJjVunI4QZOgZCi2qoD8a/tbiKAiEAuT8JyGEgFj1yvRAxSGz63/k0dX0oifWJ5937mW4IckY="}]},"_npmUser":{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"},"directories":{},"maintainers":[{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/router_0.4.1_1618655164528_0.6150599204471257"},"_hasShrinkwrap":false},"0.5.0-rc1":{"name":"@mayajs/router","version":"0.5.0-rc1","description":"Simple NodeJS routing library created using Typescript","main":"index.js","scripts":{"clean":"rimraf interface && rimraf index.js && rimraf index.d.ts && rimraf utils && rimraf router && rimraf lib && rimraf class && rimraf exceptions && rimraf types","postpack":"npm run clean && node ./scripts/restore-package.js"},"keywords":["nodejs","server","router","typescript","library","REST","API","mayajs"],"author":{"name":"Mark Anthony C. Ignacio"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/mayajs/router.git"},"bugs":{"url":"https://github.com/mayajs/router/issues"},"homepage":"https://github.com/mayajs/router#readme","engines":{"node":">= 0.10.0"},"_resolved":"","_integrity":"","_from":"file:mayajs-router-0.5.0-rc1.tgz","readme":"<p align=\"center\"><img src=\"https://github.com/mayajs/maya/blob/master/maya.svg\" ></p>\r\n<h1 align=\"center\">MayaJS Router</h1>\r\n<p align=\"center\">\r\n  <a href=\"https://www.npmjs.com/package/@mayajs/router\"><img src=\"https://img.shields.io/npm/v/@mayajs/router.svg?style=for-the-badge&logo=appveyor\" alt=\"Version\"></a>\r\n  <a href=\"https://www.npmjs.com/package/@mayajs/router\"><img src=\"https://img.shields.io/npm/dm/@mayajs/router.svg?style=for-the-badge&logo=appveyor\" alt=\"Downloads\"></a>\r\n  <a href=\"https://www.npmjs.com/package/@mayajs/router\"><img src=\"https://img.shields.io/npm/l/@mayajs/router?style=for-the-badge&logo=appveyor\" alt=\"License\"></a>\r\n  <a href=\"https://github.com/microsoft/typescript-tslint-plugin\"><img src=\"https://img.shields.io/badge/code%20style-standard-blue.svg?style=for-the-badge&logo=appveyor\" alt=\"Code Style\"></a>\r\n</p>\r\n<h2 align=\"center\">Lightweight, simple and fast NodeJS Router developed using Typescript.</h2>\r\n\r\n## Motivation\r\n\r\nWe develop this library to be used as the main router for [MayaJS](https://github.com/mayajs/maya#readme) RESTful API framework. As much as possible we want to have a full control of\r\nthe libraries we used in our main projects for maintainability and ease of transition for future updates.\r\n\r\n## Roadmap\r\n\r\nYou can see the detailed roadmap of the project [here.](https://github.com/mayajs/router/blob/master/ROADMAP.md)\r\n\r\n## Suggestions\r\n\r\nFor suggestions and features you want to see in the future you can visit our [issues section.](https://github.com/mayajs/router/issues)\r\n\r\n## Getting started\r\n\r\nBefore installing this package make sure to download and install Node.js 10 or higher.\r\n\r\n### Setup Node\r\n\r\nTo check your node version\r\n\r\n```shell\r\nnpm -v\r\n```\r\n\r\nFor new project kindly initialize npm using the command below or see documentation [here](https://docs.npmjs.com/creating-a-package-json-file).\r\n\r\n```shell\r\nnpm init\r\n```\r\n\r\n### Setup Typescript\r\n\r\nInstall typescript and typescript watcher\r\n\r\n```shell\r\nnpm i typescript ts-node-dev -D\r\n```\r\n\r\nInitialize typescript\r\n\r\n```shell\r\ntsc --init\r\n```\r\n\r\n### Setup Router\r\n\r\nInstall mayajs router\r\n\r\n```shell\r\nnpm i @mayajs/router\r\n```\r\n\r\nAdd `start` script on your `package.json`\r\n\r\n```js\r\n\"scripts\": {\r\n  \"start\": \"tsnd src\"\r\n}\r\n```\r\n\r\n## Features\r\n\r\n- Simple and easy\r\n- Lightweight library\r\n- Built with TypeScript\r\n- No third party library\r\n- Modules for shareable code\r\n- Dependency Injection and IOC\r\n- Fast execution with route caching\r\n- Supports beginners to advanced developers\r\n- `Function` and `Class` based coding style\r\n- Supports third party middlewares like `ExpressJS`\r\n\r\n## Quick Start\r\n\r\nThe easiest way to get started is to create a simple route. Create a `src` folder inside your project folder. Inside the `src` folder create an `index.ts` file. Copy the code below into `index.ts` file.\r\n\r\n```ts\r\nimport maya from \"@mayajs/router\";\r\nimport http from \"http\";\r\n\r\nconst PORT = 3000;\r\nconst app = maya();\r\n\r\napp.add([\r\n  {\r\n    path: \"/\",\r\n    GET: () => \"Hello, World\",\r\n  },\r\n]);\r\n\r\nhttp.createServer(app).listen(PORT, () => console.log(`Server listening on port ${PORT}.`));\r\n```\r\n\r\n## RUN\r\n\r\nTo run your mayajs project open a terminal inside your current project and run the command below.\r\n\r\n```shell\r\nnpm start\r\n```\r\n\r\n## ROUTE\r\n\r\nDefining routes in MayaJs is like creating a JSON object.\r\n\r\n```ts\r\nconst user = {\r\n  path: \"user\",\r\n  GET: () => {\r\n    //  ...\r\n  },\r\n  POST: () => {\r\n    //  ...\r\n  },\r\n  PUT: () => {\r\n    //  ...\r\n  },\r\n  PATCH: () => {\r\n    //  ...\r\n  },\r\n  DELETE: () => {\r\n    //  ...\r\n  },\r\n  OPTIONS: () => {\r\n    //  ...\r\n  },\r\n};\r\n```\r\n\r\nAs seen above each method name has a `callback` function. Mayajs will set the correct `content-type` based on what the method callback will return.\r\n\r\n```ts\r\nconst route = {\r\n  path: \"user\",\r\n  GET: () => {\r\n    // This will return `undefined`\r\n    // This will have a content-type of \"text/plain\"\r\n  },\r\n  POST: () => {\r\n    return \"Hello\"; // This will have a content-type of \"text/plain\"\r\n  },\r\n  PUT: () => {\r\n    return { message: \"Hello\" }; // This will have a content-type of \"application/json\"\r\n  },\r\n  PATCH: () => {\r\n    return \"<h1>Hello</h1>\"; // This will have a content-type of \"text/html\"\r\n  },\r\n};\r\n```\r\n\r\nIncase you need to use a middleware for an specific route method you need to create a route object instead.\r\n\r\n```ts\r\nconst route = {\r\n  path: \"user\",\r\n  GET: {\r\n    middlewares: [middleware],\r\n    callback: () => {\r\n      // ...\r\n    },\r\n  },\r\n};\r\n```\r\n\r\n## PARAMS\r\n\r\nMayaJs passes a context object on each route method. You can acces the route params by destructuring the context object on the callback method.\r\n\r\n```ts\r\nconst route = {\r\n  path: \"user/:id\",\r\n  GET: ({ params }) => {\r\n    // `params` object contains the value of `id` define on the path above e.g. `user/hello`\r\n    return params.id; // This has a value of \"hello\"\r\n  },\r\n};\r\n```\r\n\r\n## QUERY STRING\r\n\r\nYou can also access the query string using the context object provided by MayaJs on your route method callback function.\r\n\r\n```ts\r\nconst route = {\r\n  path: \"user\",\r\n  GET: ({ query }) => {\r\n    // `query` object contains all the value on your query string e.g. `user?id=1`\r\n    return query.id; // This has a value of 1\r\n  },\r\n};\r\n```\r\n\r\n## BODY\r\n\r\nRequest body is also accessible in the context but you need a middleware before you can actually uses. There is a popular middleware called [body-parser](https://www.npmjs.com/package/body-parser) that we can use to achieve this.\r\n\r\n```ts\r\nimport maya from \"@mayajs/router\";\r\n// Third party middleware you need to install\r\nimport bodyParser from \"body-parser\";\r\n\r\nconst app = maya();\r\n\r\n// Initialize body parser for mayajs to use it internally\r\napp.use(bodyParser.json());\r\napp.use(bodyParser.urlencoded({ extended: false }));\r\n\r\nconst route = {\r\n  path: \"user\",\r\n  POST: ({ body }) => {\r\n    // `body` object contains all the value from the request body\r\n    return body; // This has a value of req.body\r\n  },\r\n};\r\n\r\napp.add([route]);\r\n```\r\n\r\n## MIDDLEWARES\r\n\r\nAs seen above how we used third party middlewares to parse the request body. We can also create our own middlewares. Although MayaJs supports all [ExpressJs Middlewares](https://expressjs.com/en/resources/middleware.html), we also can create a `MayaJsMiddleware` of our own. The context is where you can access `params, query and body` objects.\r\n\r\n```ts\r\nrouter.use((context, next, error) => {\r\n  // This `error` variable comes from the previous middleware\r\n  console.log(error);\r\n\r\n  // The `next` function will trigger the end of this callback function\r\n  // and execute the next middleware in the list\r\n  next(\"Error message or any value that you want to pass to the next middleware\");\r\n});\r\n```\r\n\r\n## CHILD ROUTES\r\n\r\nA child route is a route that appended to its parent route. It can be added using the `children` property from the route object.\r\n\r\n```ts\r\nconst child = {\r\n  path: \"child\",\r\n  GET: () => \"This is from a child route\", // You can call this route by `users/child`\r\n};\r\n\r\nconst parent = {\r\n  path: \"user\",\r\n  children: [child], // This is a list of routes.\r\n};\r\n\r\napp.add([parent]);\r\n```\r\n\r\n## CONTROLLER\r\n\r\nA controller is a class that act as a replacement for the route method objects. It can be used to make your code more modular and manageable when your code base get bigger.\r\n\r\n```ts\r\nclass UsersController extends Controller {\r\n  GET() {\r\n    return \"Hello form UsersController\";\r\n  }\r\n\r\n  // You can also add additional route method like this\r\n  POST() {\r\n    // ...\r\n  }\r\n\r\n  // Other routes available are PUT, PATCH, DELETE and OPTIONS\r\n}\r\n\r\napp.add([\r\n  {\r\n    path: \"user\",\r\n    controller: UsersController,\r\n  },\r\n]);\r\n```\r\n\r\nIf you want to add middleware a middleware to a specific method you can add the `middleware` property in a controller.\r\n\r\n```ts\r\nclass UsersController extends Controller {\r\n  middleware = {\r\n    GET: [middleware], // This middleware will be added to the `GET` method below\r\n  };\r\n\r\n  GET() {\r\n    //  ...\r\n  }\r\n}\r\n```\r\n\r\n```\r\nNOTE: A controller has no `children` property\r\n```\r\n\r\n## SERVICES\r\n\r\nA service is an injectable class that can be used inside of a controller or another service.\r\n\r\n```ts\r\nexport class UsersServices extends Services {\r\n  // Every function inside the service can be accessed by the class its injected\r\n  // All public properties are also accessible\r\n  // A service is instatiated once and making it a singleton\r\n\r\n  add() {\r\n    // ...\r\n  }\r\n}\r\n\r\nclass UsersController extends Controller {\r\n  constructor(userServices: UsersServices) {\r\n    super();\r\n  }\r\n\r\n  addUser() {\r\n    // This `add` function coming from the `UsersService`.\r\n    // It is accessible on this controller via dependency injection.\r\n    // MayaJs automatically instantiated it and created it singleton instance.\r\n    this.userServices.add();\r\n  }\r\n}\r\n```\r\n\r\n```\r\nNOTE: A `child` route can also have its own `children`.\r\n```\r\n\r\n## MODULE\r\n\r\nA module is a like a container of routes, controller and services that act on its own. This will allow your code to modular and shareable accross all routes.\r\n\r\n```ts\r\nclass UsersModule extends MayaJsModule {\r\n  // List of `module` or `services` that this module will use for its controllers\r\n  imports = [];\r\n  // List of controllers that this module will use\r\n  declarations = [];\r\n  // List of services that can be use inside this module\r\n  providers = [];\r\n  // List of services that this module will exports that can be used by other modules\r\n  exports = [];\r\n  // List of dependencies that will be injected to this module\r\n  dependencies = [];\r\n}\r\n```\r\n\r\nAs you can see when we create a module we dont have any way to add routes on it. Below is an example of implementation of how to add a `RouterModule` for this module to add routes.\r\n\r\n```ts\r\nimport { UsersController, UsersIdController } from \"./controller\";\r\nimport { RouterModule } from \"@mayajs/router\";\r\nimport { UsersServices } from \"./services\";\r\n\r\n// Define the routes\r\nconst routes = [\r\n  {\r\n    path: \"/\",\r\n    controller: UsersController,\r\n  },\r\n  {\r\n    path: \":id\",\r\n    controller: UsersIdController,\r\n  },\r\n];\r\n\r\nexport class UsersModule extends MayaJsModule {\r\n  // User `RouterModule.forRoot` to inject the routes\r\n  imports = [RouterModule.forRoot(routes)];\r\n  // Declare the controllers that will be used inside the routes\r\n  declarations = [UsersIdController, UsersController];\r\n}\r\n```\r\n\r\n## CUSTOM MODULE\r\n\r\nUnlike the common mayajs module, custom modules provide other functionality aside from managing your controllers. One example of this the `RouterModule` that is reponsible for adding routes to your module. A key concept of a custom module is it has an `invoke` and `forRoot` function that provides additional functionalities.\r\n\r\n```ts\r\nexport class UsersModule extends CustomModule {\r\n  invoke() {\r\n    // This function will run after an instance of this module is created\r\n    // But the providers will stay singleton on each instance\r\n  }\r\n\r\n  static forRoot(options: any) {\r\n    return {\r\n      module: UsersModule, // Returns the current module reference\r\n      providers: [], // List of providers that this module will use on its controllers\r\n    };\r\n  }\r\n}\r\n```\r\n\r\nNow we know how to create a module but how we can call it on our routes. We are now introducing to `loadChildren` property of our route object. MayaJs will automatically resolve the module asynchronously when the path is added on the route list.\r\n\r\n```ts\r\nimport maya from \"@mayajs/router\";\r\nimport http from \"http\";\r\n\r\nconst app = maya();\r\n\r\napp.add([\r\n  {\r\n    path: \"users\",\r\n    // We are using dynamic importing so we don't need it to manually import the module in the file\r\n    // MayaJs will resolve the module asynchronously\r\n    loadChildren: () => import(\"./users.module\").then((m) => m.UsersModule),\r\n  },\r\n]);\r\n```\r\n\r\n## Collaborating\r\n\r\nSee collaborating guides [here.](https://github.com/mayajs/maya/edit/master/COLLABORATOR_GUIDE.md)\r\n\r\n## People\r\n\r\nAuthor and maintainer [Mac Ignacio](https://github.com/macign)\r\n\r\n## License\r\n\r\n[MIT](https://github.com/mayajs/router/blob/develop/LICENSE)\r\n","readmeFilename":"README.md","_id":"@mayajs/router@0.5.0-rc1","_nodeVersion":"12.16.1","_npmVersion":"6.13.4","dist":{"integrity":"sha512-234aqjNHt7bIqJWd2zvrDCUO8+yJoThroxktpod6WLUEdIPx/hMeazcTTtze1PMYefyxVPwgmIA0IIfnhBrgRw==","shasum":"79701f0fe719caf4c90544c699b1522297fe243c","tarball":"https://registry.npmjs.org/@mayajs/router/-/router-0.5.0-rc1.tgz","fileCount":37,"unpackedSize":63724,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJggnNICRA9TVsSAnZWagAAEpIP/2Jlybs/twzAJtt8ySkt\n5i/jjNPCaJkfWy5ms+XbO35PQW5bg5G1JbcW/xORpu4dy3JfLnsHQ7rhmj54\nU4q+I82ga4CPyLJJfuc2CUTkRFxk+bV0b8i4bXFBuivD/Et3DXvQsRmJxsN3\nQR0eG4Zo8pIbAh6ThkaTBXhlRt3xQxk6iL7rlKYsSVET21XRbzk2/PcB6TfH\n9V6SHc/K0pTh/mHT/UaTCAsOXqk+JEdoUTpHEBWeb7IkXIX1DB2uPH3OSYdD\nhG2wn+r7eKv1YlYEQuYR/u9iUpTmQsgD63xRsNR/YblylqGcRxW1vU9F3wGW\nltgBKmFPwzm3lfb7VEODJMPx7O3OX5V2soYcqTL6BULO8dJHqeMZy3G/PmWA\nPMQTUgJVrYsvr6/6EA63Q+ao+fDO2ZCUsnUm7FKjgfjc6NYcJg6RpSoWQayP\nDR3TsrvHOjLW3FS+ksK6QAl0oa4zOlec3ZToJ7on3A0v7eHpdpQeHsbqTPuD\ni2sLao+DKWjo7Xd9RzrV6aKlCUIdtGvOIpI8gEsQ2Khd/mM1Ytj+IS1Rbehl\nHbkJND9p2KT+Cw3i5VDt/6pnjStP6OZylkJEDc7M0UByx1QYjHIMKI9ZXYKI\n3ZLgyUiEG3TN1aMatTiMk6lY2pB9KBihiKXy6EMpvhRYk1QsW2fLEEjjR+yc\nUfBI\r\n=jtgO\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDjO+PeYS6+O6K+pk7e9QZWcBS3aCPIpr+8vfc5tAAi+QIgMxbYLeOBqR9HnxyvV/FowfekczibqaTcAcdQxbDwRFY="}]},"_npmUser":{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"},"directories":{},"maintainers":[{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/router_0.5.0-rc1_1619161928495_0.6192290140110301"},"_hasShrinkwrap":false},"0.5.0-rc2":{"name":"@mayajs/router","version":"0.5.0-rc2","description":"Simple NodeJS routing library created using Typescript","main":"index.js","scripts":{"clean":"rimraf interface && rimraf index.js && rimraf index.d.ts && rimraf utils && rimraf router && rimraf lib && rimraf class && rimraf exceptions && rimraf types","postpack":"npm run clean && node ./scripts/restore-package.js"},"keywords":["nodejs","server","router","typescript","library","REST","API","mayajs"],"author":{"name":"Mark Anthony C. Ignacio"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/mayajs/router.git"},"bugs":{"url":"https://github.com/mayajs/router/issues"},"homepage":"https://github.com/mayajs/router#readme","engines":{"node":">= 0.10.0"},"_resolved":"","_integrity":"","_from":"file:mayajs-router-0.5.0-rc2.tgz","readme":"<p align=\"center\"><img src=\"https://github.com/mayajs/maya/blob/master/maya.svg\" ></p>\r\n<h1 align=\"center\">MayaJS Router</h1>\r\n<p align=\"center\">\r\n  <a href=\"https://www.npmjs.com/package/@mayajs/router\"><img src=\"https://img.shields.io/npm/v/@mayajs/router.svg?style=for-the-badge&logo=appveyor\" alt=\"Version\"></a>\r\n  <a href=\"https://www.npmjs.com/package/@mayajs/router\"><img src=\"https://img.shields.io/npm/dm/@mayajs/router.svg?style=for-the-badge&logo=appveyor\" alt=\"Downloads\"></a>\r\n  <a href=\"https://www.npmjs.com/package/@mayajs/router\"><img src=\"https://img.shields.io/npm/l/@mayajs/router?style=for-the-badge&logo=appveyor\" alt=\"License\"></a>\r\n  <a href=\"https://github.com/microsoft/typescript-tslint-plugin\"><img src=\"https://img.shields.io/badge/code%20style-standard-blue.svg?style=for-the-badge&logo=appveyor\" alt=\"Code Style\"></a>\r\n</p>\r\n<h2 align=\"center\">Lightweight, simple and fast NodeJS Router developed using Typescript.</h2>\r\n\r\n## Motivation\r\n\r\nWe develop this library to be used as the main router for [MayaJS](https://github.com/mayajs/maya#readme) RESTful API framework. As much as possible we want to have a full control of\r\nthe libraries we used in our main projects for maintainability and ease of transition for future updates.\r\n\r\n## Roadmap\r\n\r\nYou can see the detailed roadmap of the project [here.](https://github.com/mayajs/router/blob/master/ROADMAP.md)\r\n\r\n## Suggestions\r\n\r\nFor suggestions and features you want to see in the future you can visit our [issues section.](https://github.com/mayajs/router/issues)\r\n\r\n## Getting started\r\n\r\nBefore installing this package make sure to download and install Node.js 10 or higher.\r\n\r\n### Setup Node\r\n\r\nTo check your node version\r\n\r\n```shell\r\nnpm -v\r\n```\r\n\r\nFor new project kindly initialize npm using the command below or see documentation [here](https://docs.npmjs.com/creating-a-package-json-file).\r\n\r\n```shell\r\nnpm init\r\n```\r\n\r\n### Setup Typescript\r\n\r\nInstall typescript and typescript watcher\r\n\r\n```shell\r\nnpm i typescript ts-node-dev -D\r\n```\r\n\r\nInitialize typescript\r\n\r\n```shell\r\ntsc --init\r\n```\r\n\r\n### Setup Router\r\n\r\nInstall mayajs router\r\n\r\n```shell\r\nnpm i @mayajs/router\r\n```\r\n\r\nAdd `start` script on your `package.json`\r\n\r\n```js\r\n\"scripts\": {\r\n  \"start\": \"tsnd src\"\r\n}\r\n```\r\n\r\n## Features\r\n\r\n- Simple and easy\r\n- Lightweight library\r\n- Built with TypeScript\r\n- No third party library\r\n- Modules for shareable code\r\n- Dependency Injection and IOC\r\n- Fast execution with route caching\r\n- Supports beginners to advanced developers\r\n- `Function` and `Class` based coding style\r\n- Supports third party middlewares like `ExpressJS`\r\n\r\n## Quick Start\r\n\r\nThe easiest way to get started is to create a simple route. Create a `src` folder inside your project folder. Inside the `src` folder create an `index.ts` file. Copy the code below into `index.ts` file.\r\n\r\n```ts\r\nimport maya from \"@mayajs/router\";\r\nimport http from \"http\";\r\n\r\nconst PORT = 3000;\r\nconst app = maya();\r\n\r\napp.add([\r\n  {\r\n    path: \"/\",\r\n    GET: () => \"Hello, World\",\r\n  },\r\n]);\r\n\r\nhttp.createServer(app).listen(PORT, () => console.log(`Server listening on port ${PORT}.`));\r\n```\r\n\r\n## RUN\r\n\r\nTo run your mayajs project open a terminal inside your current project and run the command below.\r\n\r\n```shell\r\nnpm start\r\n```\r\n\r\n## ROUTE\r\n\r\nDefining routes in MayaJs is like creating a JSON object.\r\n\r\n```ts\r\nconst user = {\r\n  path: \"user\",\r\n  GET: () => {\r\n    //  ...\r\n  },\r\n  POST: () => {\r\n    //  ...\r\n  },\r\n  PUT: () => {\r\n    //  ...\r\n  },\r\n  PATCH: () => {\r\n    //  ...\r\n  },\r\n  DELETE: () => {\r\n    //  ...\r\n  },\r\n  OPTIONS: () => {\r\n    //  ...\r\n  },\r\n};\r\n```\r\n\r\nAs seen above each method name has a `callback` function. Mayajs will set the correct `content-type` based on what the method callback will return.\r\n\r\n```ts\r\nconst route = {\r\n  path: \"user\",\r\n  GET: () => {\r\n    // This will return `undefined`\r\n    // This will have a content-type of \"text/plain\"\r\n  },\r\n  POST: () => {\r\n    return \"Hello\"; // This will have a content-type of \"text/plain\"\r\n  },\r\n  PUT: () => {\r\n    return { message: \"Hello\" }; // This will have a content-type of \"application/json\"\r\n  },\r\n  PATCH: () => {\r\n    return \"<h1>Hello</h1>\"; // This will have a content-type of \"text/html\"\r\n  },\r\n};\r\n```\r\n\r\nIncase you need to use a middleware for an specific route method you need to create a route object instead.\r\n\r\n```ts\r\nconst route = {\r\n  path: \"user\",\r\n  GET: {\r\n    middlewares: [middleware],\r\n    callback: () => {\r\n      // ...\r\n    },\r\n  },\r\n};\r\n```\r\n\r\n## PARAMS\r\n\r\nMayaJs passes a context object on each route method. You can acces the route params by destructuring the context object on the callback method.\r\n\r\n```ts\r\nconst route = {\r\n  path: \"user/:id\",\r\n  GET: ({ params }) => {\r\n    // `params` object contains the value of `id` define on the path above e.g. `user/hello`\r\n    return params.id; // This has a value of \"hello\"\r\n  },\r\n};\r\n```\r\n\r\n## QUERY STRING\r\n\r\nYou can also access the query string using the context object provided by MayaJs on your route method callback function.\r\n\r\n```ts\r\nconst route = {\r\n  path: \"user\",\r\n  GET: ({ query }) => {\r\n    // `query` object contains all the value on your query string e.g. `user?id=1`\r\n    return query.id; // This has a value of 1\r\n  },\r\n};\r\n```\r\n\r\n## BODY\r\n\r\nRequest body is also accessible in the context but you need a middleware before you can actually uses. There is a popular middleware called [body-parser](https://www.npmjs.com/package/body-parser) that we can use to achieve this.\r\n\r\n```ts\r\nimport maya from \"@mayajs/router\";\r\n// Third party middleware you need to install\r\nimport bodyParser from \"body-parser\";\r\n\r\nconst app = maya();\r\n\r\n// Initialize body parser for mayajs to use it internally\r\napp.use(bodyParser.json());\r\napp.use(bodyParser.urlencoded({ extended: false }));\r\n\r\nconst route = {\r\n  path: \"user\",\r\n  POST: ({ body }) => {\r\n    // `body` object contains all the value from the request body\r\n    return body; // This has a value of req.body\r\n  },\r\n};\r\n\r\napp.add([route]);\r\n```\r\n\r\n## MIDDLEWARES\r\n\r\nAs seen above how we used third party middlewares to parse the request body. We can also create our own middlewares. Although MayaJs supports all [ExpressJs Middlewares](https://expressjs.com/en/resources/middleware.html), we also can create a `MayaJsMiddleware` of our own. The context is where you can access `params, query and body` objects.\r\n\r\n```ts\r\nrouter.use((context, next, error) => {\r\n  // This `error` variable comes from the previous middleware\r\n  console.log(error);\r\n\r\n  // The `next` function will trigger the end of this callback function\r\n  // and execute the next middleware in the list\r\n  next(\"Error message or any value that you want to pass to the next middleware\");\r\n});\r\n```\r\n\r\n## CHILD ROUTES\r\n\r\nA child route is a route that appended to its parent route. It can be added using the `children` property from the route object.\r\n\r\n```ts\r\nconst child = {\r\n  path: \"child\",\r\n  GET: () => \"This is from a child route\", // You can call this route by `users/child`\r\n};\r\n\r\nconst parent = {\r\n  path: \"user\",\r\n  children: [child], // This is a list of routes.\r\n};\r\n\r\napp.add([parent]);\r\n```\r\n\r\n## CONTROLLER\r\n\r\nA controller is a class that act as a replacement for the route method objects. It can be used to make your code more modular and manageable when your code base get bigger.\r\n\r\n```ts\r\nclass UsersController extends Controller {\r\n  GET() {\r\n    return \"Hello form UsersController\";\r\n  }\r\n\r\n  // You can also add additional route method like this\r\n  POST() {\r\n    // ...\r\n  }\r\n\r\n  // Other routes available are PUT, PATCH, DELETE and OPTIONS\r\n}\r\n\r\napp.add([\r\n  {\r\n    path: \"user\",\r\n    controller: UsersController,\r\n  },\r\n]);\r\n```\r\n\r\nIf you want to add middleware a middleware to a specific method you can add the `middleware` property in a controller.\r\n\r\n```ts\r\nclass UsersController extends Controller {\r\n  middleware = {\r\n    GET: [middleware], // This middleware will be added to the `GET` method below\r\n  };\r\n\r\n  GET() {\r\n    //  ...\r\n  }\r\n}\r\n```\r\n\r\n```\r\nNOTE: A controller has no `children` property\r\n```\r\n\r\n## SERVICES\r\n\r\nA service is an injectable class that can be used inside of a controller or another service.\r\n\r\n```ts\r\nexport class UsersServices extends Services {\r\n  // Every function inside the service can be accessed by the class its injected\r\n  // All public properties are also accessible\r\n  // A service is instatiated once and making it a singleton\r\n\r\n  add() {\r\n    // ...\r\n  }\r\n}\r\n\r\nclass UsersController extends Controller {\r\n  constructor(userServices: UsersServices) {\r\n    super();\r\n  }\r\n\r\n  addUser() {\r\n    // This `add` function coming from the `UsersService`.\r\n    // It is accessible on this controller via dependency injection.\r\n    // MayaJs automatically instantiated it and created it singleton instance.\r\n    this.userServices.add();\r\n  }\r\n}\r\n```\r\n\r\n```\r\nNOTE: A `child` route can also have its own `children`.\r\n```\r\n\r\n## MODULE\r\n\r\nA module is a like a container of routes, controller and services that act on its own. This will allow your code to modular and shareable accross all routes.\r\n\r\n```ts\r\nclass UsersModule extends MayaJsModule {\r\n  // List of `module` or `services` that this module will use for its controllers\r\n  imports = [];\r\n  // List of controllers that this module will use\r\n  declarations = [];\r\n  // List of services that can be use inside this module\r\n  providers = [];\r\n  // List of services that this module will exports that can be used by other modules\r\n  exports = [];\r\n  // List of dependencies that will be injected to this module\r\n  dependencies = [];\r\n}\r\n```\r\n\r\nAs you can see when we create a module we dont have any way to add routes on it. Below is an example of implementation of how to add a `RouterModule` for this module to add routes.\r\n\r\n```ts\r\nimport { UsersController, UsersIdController } from \"./controller\";\r\nimport { RouterModule } from \"@mayajs/router\";\r\nimport { UsersServices } from \"./services\";\r\n\r\n// Define the routes\r\nconst routes = [\r\n  {\r\n    path: \"/\",\r\n    controller: UsersController,\r\n  },\r\n  {\r\n    path: \":id\",\r\n    controller: UsersIdController,\r\n  },\r\n];\r\n\r\nexport class UsersModule extends MayaJsModule {\r\n  // User `RouterModule.forRoot` to inject the routes\r\n  imports = [RouterModule.forRoot(routes)];\r\n  // Declare the controllers that will be used inside the routes\r\n  declarations = [UsersIdController, UsersController];\r\n}\r\n```\r\n\r\n## CUSTOM MODULE\r\n\r\nUnlike the common mayajs module, custom modules provide other functionality aside from managing your controllers. One example of this the `RouterModule` that is reponsible for adding routes to your module. A key concept of a custom module is it has an `invoke` and `forRoot` function that provides additional functionalities.\r\n\r\n```ts\r\nexport class UsersModule extends CustomModule {\r\n  invoke() {\r\n    // This function will run after an instance of this module is created\r\n    // But the providers will stay singleton on each instance\r\n  }\r\n\r\n  static forRoot(options: any) {\r\n    return {\r\n      module: UsersModule, // Returns the current module reference\r\n      providers: [], // List of providers that this module will use on its controllers\r\n    };\r\n  }\r\n}\r\n```\r\n\r\nNow we know how to create a module but how we can call it on our routes. We are now introducing to `loadChildren` property of our route object. MayaJs will automatically resolve the module asynchronously when the path is added on the route list.\r\n\r\n```ts\r\nimport maya from \"@mayajs/router\";\r\nimport http from \"http\";\r\n\r\nconst app = maya();\r\n\r\napp.add([\r\n  {\r\n    path: \"users\",\r\n    // We are using dynamic importing so we don't need it to manually import the module in the file\r\n    // MayaJs will resolve the module asynchronously\r\n    loadChildren: () => import(\"./users.module\").then((m) => m.UsersModule),\r\n  },\r\n]);\r\n```\r\n\r\n## Collaborating\r\n\r\nSee collaborating guides [here.](https://github.com/mayajs/maya/edit/master/COLLABORATOR_GUIDE.md)\r\n\r\n## People\r\n\r\nAuthor and maintainer [Mac Ignacio](https://github.com/macign)\r\n\r\n## License\r\n\r\n[MIT](https://github.com/mayajs/router/blob/develop/LICENSE)\r\n","readmeFilename":"README.md","_id":"@mayajs/router@0.5.0-rc2","_nodeVersion":"12.16.1","_npmVersion":"6.13.4","dist":{"integrity":"sha512-ylXg7ijqNkMXqToTqmfaWMANcTSCE50Bh/QuPUH09k/4cop81G9JXfz7Y1X6VAqFnBvnCL2XRcEJAcKW/k6OEQ==","shasum":"871764ceb6998af8d038a5ec29cb6fba84338387","tarball":"https://registry.npmjs.org/@mayajs/router/-/router-0.5.0-rc2.tgz","fileCount":37,"unpackedSize":64066,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgisGWCRA9TVsSAnZWagAAbwwP/0TpdZz43Xq8L2NLl83A\nTbb4m/AoMwglwkQQU0HgULy0n/Y7qUQc0/lQQlVMgPKsYKaOZn6INtagzqcv\nmALiZXIwRRYpgO5pbevQz2qdm8aOrF8KXqLqwvbVXYzUhsaXw3X/Yn/9rJhu\ndxcCUCuNNcevTEl4XNviGx7Rn0Vn8a+ghSxTqp8uh0Gs8E1Cq1PaMm5T4sux\nmbkG0/+FWPfXBKn7OJIzd2j6MKSJGx5kkhvbAnNMLqLf6V6GNuivMcN5MJjn\nmCP4RusLnZyYf7x4ntWU07gYfXpdMm5NiiJ6GKnkd5FQMFDXeS0dmjM59djv\nyi42xXz51i0NuucGi6BcSDOIFfSLmpsS0aGhRtkP5gEfBFs6pfZ2FSm81jis\nPKeYmvYvvAmov180mqwEE+vfRS1mvYWXCKNeU8qqqLOLHvdqM+FU0dGAEYFr\njm1mhqFpcCw5dQR75LA37jfAUPC1c45sMtH1Mb+7V+TS0KNDaDtldT+xjK3m\n8L9ogpNJgsed8/C4W+PY8kRs8BWhUazzcOkEDInjnodxdFCVHs8V+eDwKiad\niGViUwb0FjGAWjSTwMY0wGF+8sWJReJ2W7qXoWgtM1cf+639MxPHXCPN4jhp\nvIa45AGy8pvKVUpBxkQ5fnl1JpukPHwcVBnB9RSFxQo+6BDEkf8ytKppsewN\npL/Z\r\n=j1U5\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCSvSGfMjGie/iX9N1ulJj9rlqC1XqFdlmtivsmgBztxgIgaGDaWFO/gH1EionCHp6ZkXnTRnI69mQBmL9zRk3lq7E="}]},"_npmUser":{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"},"directories":{},"maintainers":[{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/router_0.5.0-rc2_1619706262090_0.24839488803215937"},"_hasShrinkwrap":false},"0.5.0-rc3":{"name":"@mayajs/router","version":"0.5.0-rc3","description":"Simple NodeJS routing library created using Typescript","main":"index.js","scripts":{"clean":"rimraf interface && rimraf index.js && rimraf index.d.ts && rimraf utils && rimraf router && rimraf lib && rimraf class && rimraf exceptions && rimraf types","postpack":"npm run clean && node ./scripts/restore-package.js"},"keywords":["nodejs","server","router","typescript","library","REST","API","mayajs"],"author":{"name":"Mark Anthony C. Ignacio"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/mayajs/router.git"},"bugs":{"url":"https://github.com/mayajs/router/issues"},"homepage":"https://github.com/mayajs/router#readme","engines":{"node":">= 0.10.0"},"_resolved":"","_integrity":"","_from":"file:mayajs-router-0.5.0-rc3.tgz","readme":"<p align=\"center\"><img src=\"https://github.com/mayajs/maya/blob/master/maya.svg\" ></p>\r\n<h1 align=\"center\">MayaJS Router</h1>\r\n<p align=\"center\">\r\n  <a href=\"https://www.npmjs.com/package/@mayajs/router\"><img src=\"https://img.shields.io/npm/v/@mayajs/router.svg?style=for-the-badge&logo=appveyor\" alt=\"Version\"></a>\r\n  <a href=\"https://www.npmjs.com/package/@mayajs/router\"><img src=\"https://img.shields.io/npm/dm/@mayajs/router.svg?style=for-the-badge&logo=appveyor\" alt=\"Downloads\"></a>\r\n  <a href=\"https://www.npmjs.com/package/@mayajs/router\"><img src=\"https://img.shields.io/npm/l/@mayajs/router?style=for-the-badge&logo=appveyor\" alt=\"License\"></a>\r\n  <a href=\"https://github.com/microsoft/typescript-tslint-plugin\"><img src=\"https://img.shields.io/badge/code%20style-standard-blue.svg?style=for-the-badge&logo=appveyor\" alt=\"Code Style\"></a>\r\n</p>\r\n<h2 align=\"center\">Lightweight, simple and fast NodeJS Router developed using Typescript.</h2>\r\n\r\n## Motivation\r\n\r\nWe develop this library to be used as the main router for [MayaJS](https://github.com/mayajs/maya#readme) RESTful API framework. As much as possible we want to have a full control of\r\nthe libraries we used in our main projects for maintainability and ease of transition for future updates.\r\n\r\n## Roadmap\r\n\r\nYou can see the detailed roadmap of the project [here.](https://github.com/mayajs/router/blob/master/ROADMAP.md)\r\n\r\n## Suggestions\r\n\r\nFor suggestions and features you want to see in the future you can visit our [issues section.](https://github.com/mayajs/router/issues)\r\n\r\n## Getting started\r\n\r\nBefore installing this package make sure to download and install Node.js 10 or higher.\r\n\r\n### Setup Node\r\n\r\nTo check your node version\r\n\r\n```shell\r\nnpm -v\r\n```\r\n\r\nFor new project kindly initialize npm using the command below or see documentation [here](https://docs.npmjs.com/creating-a-package-json-file).\r\n\r\n```shell\r\nnpm init\r\n```\r\n\r\n### Setup Typescript\r\n\r\nInstall typescript and typescript watcher\r\n\r\n```shell\r\nnpm i typescript ts-node-dev -D\r\n```\r\n\r\nInitialize typescript\r\n\r\n```shell\r\ntsc --init\r\n```\r\n\r\n### Setup Router\r\n\r\nInstall mayajs router\r\n\r\n```shell\r\nnpm i @mayajs/router\r\n```\r\n\r\nAdd `start` script on your `package.json`\r\n\r\n```js\r\n\"scripts\": {\r\n  \"start\": \"tsnd src\"\r\n}\r\n```\r\n\r\n## Features\r\n\r\n- Simple and easy\r\n- Lightweight library\r\n- Built with TypeScript\r\n- No third party library\r\n- Modules for shareable code\r\n- Dependency Injection and IOC\r\n- Fast execution with route caching\r\n- Supports beginners to advanced developers\r\n- `Function` and `Class` based coding style\r\n- Supports third party middlewares like `ExpressJS`\r\n\r\n## Quick Start\r\n\r\nThe easiest way to get started is to create a simple route. Create a `src` folder inside your project folder. Inside the `src` folder create an `index.ts` file. Copy the code below into `index.ts` file.\r\n\r\n```ts\r\nimport maya from \"@mayajs/router\";\r\nimport http from \"http\";\r\n\r\nconst PORT = 3000;\r\nconst app = maya();\r\n\r\napp.add([\r\n  {\r\n    path: \"/\",\r\n    GET: () => \"Hello, World\",\r\n  },\r\n]);\r\n\r\nhttp.createServer(app).listen(PORT, () => console.log(`Server listening on port ${PORT}.`));\r\n```\r\n\r\n## RUN\r\n\r\nTo run your mayajs project open a terminal inside your current project and run the command below.\r\n\r\n```shell\r\nnpm start\r\n```\r\n\r\n## ROUTE\r\n\r\nDefining routes in MayaJs is like creating a JSON object.\r\n\r\n```ts\r\nconst user = {\r\n  path: \"user\",\r\n  GET: () => {\r\n    //  ...\r\n  },\r\n  POST: () => {\r\n    //  ...\r\n  },\r\n  PUT: () => {\r\n    //  ...\r\n  },\r\n  PATCH: () => {\r\n    //  ...\r\n  },\r\n  DELETE: () => {\r\n    //  ...\r\n  },\r\n  OPTIONS: () => {\r\n    //  ...\r\n  },\r\n};\r\n```\r\n\r\nAs seen above each method name has a `callback` function. Mayajs will set the correct `content-type` based on what the method callback will return.\r\n\r\n```ts\r\nconst route = {\r\n  path: \"user\",\r\n  GET: () => {\r\n    // This will return `undefined`\r\n    // This will have a content-type of \"text/plain\"\r\n  },\r\n  POST: () => {\r\n    return \"Hello\"; // This will have a content-type of \"text/plain\"\r\n  },\r\n  PUT: () => {\r\n    return { message: \"Hello\" }; // This will have a content-type of \"application/json\"\r\n  },\r\n  PATCH: () => {\r\n    return \"<h1>Hello</h1>\"; // This will have a content-type of \"text/html\"\r\n  },\r\n};\r\n```\r\n\r\nIncase you need to use a middleware for an specific route method you need to create a route object instead.\r\n\r\n```ts\r\nconst route = {\r\n  path: \"user\",\r\n  GET: {\r\n    middlewares: [middleware],\r\n    callback: () => {\r\n      // ...\r\n    },\r\n  },\r\n};\r\n```\r\n\r\n## PARAMS\r\n\r\nMayaJs passes a context object on each route method. You can acces the route params by destructuring the context object on the callback method.\r\n\r\n```ts\r\nconst route = {\r\n  path: \"user/:id\",\r\n  GET: ({ params }) => {\r\n    // `params` object contains the value of `id` define on the path above e.g. `user/hello`\r\n    return params.id; // This has a value of \"hello\"\r\n  },\r\n};\r\n```\r\n\r\n## QUERY STRING\r\n\r\nYou can also access the query string using the context object provided by MayaJs on your route method callback function.\r\n\r\n```ts\r\nconst route = {\r\n  path: \"user\",\r\n  GET: ({ query }) => {\r\n    // `query` object contains all the value on your query string e.g. `user?id=1`\r\n    return query.id; // This has a value of 1\r\n  },\r\n};\r\n```\r\n\r\n## BODY\r\n\r\nRequest body is also accessible in the context but you need a middleware before you can actually uses. There is a popular middleware called [body-parser](https://www.npmjs.com/package/body-parser) that we can use to achieve this.\r\n\r\n```ts\r\nimport maya from \"@mayajs/router\";\r\n// Third party middleware you need to install\r\nimport bodyParser from \"body-parser\";\r\n\r\nconst app = maya();\r\n\r\n// Initialize body parser for mayajs to use it internally\r\napp.use(bodyParser.json());\r\napp.use(bodyParser.urlencoded({ extended: false }));\r\n\r\nconst route = {\r\n  path: \"user\",\r\n  POST: ({ body }) => {\r\n    // `body` object contains all the value from the request body\r\n    return body; // This has a value of req.body\r\n  },\r\n};\r\n\r\napp.add([route]);\r\n```\r\n\r\n## MIDDLEWARES\r\n\r\nAs seen above how we used third party middlewares to parse the request body. We can also create our own middlewares. Although MayaJs supports all [ExpressJs Middlewares](https://expressjs.com/en/resources/middleware.html), we also can create a `MayaJsMiddleware` of our own. The context is where you can access `params, query and body` objects.\r\n\r\n```ts\r\nrouter.use((context, next, error) => {\r\n  // This `error` variable comes from the previous middleware\r\n  console.log(error);\r\n\r\n  // The `next` function will trigger the end of this callback function\r\n  // and execute the next middleware in the list\r\n  next(\"Error message or any value that you want to pass to the next middleware\");\r\n});\r\n```\r\n\r\n## CHILD ROUTES\r\n\r\nA child route is a route that appended to its parent route. It can be added using the `children` property from the route object.\r\n\r\n```ts\r\nconst child = {\r\n  path: \"child\",\r\n  GET: () => \"This is from a child route\", // You can call this route by `users/child`\r\n};\r\n\r\nconst parent = {\r\n  path: \"user\",\r\n  children: [child], // This is a list of routes.\r\n};\r\n\r\napp.add([parent]);\r\n```\r\n\r\n## CONTROLLER\r\n\r\nA controller is a class that act as a replacement for the route method objects. It can be used to make your code more modular and manageable when your code base get bigger.\r\n\r\n```ts\r\nclass UsersController extends Controller {\r\n  GET() {\r\n    return \"Hello form UsersController\";\r\n  }\r\n\r\n  // You can also add additional route method like this\r\n  POST() {\r\n    // ...\r\n  }\r\n\r\n  // Other routes available are PUT, PATCH, DELETE and OPTIONS\r\n}\r\n\r\napp.add([\r\n  {\r\n    path: \"user\",\r\n    controller: UsersController,\r\n  },\r\n]);\r\n```\r\n\r\nIf you want to add middleware a middleware to a specific method you can add the `middleware` property in a controller.\r\n\r\n```ts\r\nclass UsersController extends Controller {\r\n  middleware = {\r\n    GET: [middleware], // This middleware will be added to the `GET` method below\r\n  };\r\n\r\n  GET() {\r\n    //  ...\r\n  }\r\n}\r\n```\r\n\r\n```\r\nNOTE: A controller has no `children` property\r\n```\r\n\r\n## SERVICES\r\n\r\nA service is an injectable class that can be used inside of a controller or another service.\r\n\r\n```ts\r\nexport class UsersServices extends Services {\r\n  // Every function inside the service can be accessed by the class its injected\r\n  // All public properties are also accessible\r\n  // A service is instatiated once and making it a singleton\r\n\r\n  add() {\r\n    // ...\r\n  }\r\n}\r\n\r\nclass UsersController extends Controller {\r\n  constructor(userServices: UsersServices) {\r\n    super();\r\n  }\r\n\r\n  addUser() {\r\n    // This `add` function coming from the `UsersService`.\r\n    // It is accessible on this controller via dependency injection.\r\n    // MayaJs automatically instantiated it and created it singleton instance.\r\n    this.userServices.add();\r\n  }\r\n}\r\n```\r\n\r\n```\r\nNOTE: A `child` route can also have its own `children`.\r\n```\r\n\r\n## MODULE\r\n\r\nA module is a like a container of routes, controller and services that act on its own. This will allow your code to modular and shareable accross all routes.\r\n\r\n```ts\r\nclass UsersModule extends MayaJsModule {\r\n  // List of `module` or `services` that this module will use for its controllers\r\n  imports = [];\r\n  // List of controllers that this module will use\r\n  declarations = [];\r\n  // List of services that can be use inside this module\r\n  providers = [];\r\n  // List of services that this module will exports that can be used by other modules\r\n  exports = [];\r\n  // List of dependencies that will be injected to this module\r\n  dependencies = [];\r\n}\r\n```\r\n\r\nAs you can see when we create a module we dont have any way to add routes on it. Below is an example of implementation of how to add a `RouterModule` for this module to add routes.\r\n\r\n```ts\r\nimport { UsersController, UsersIdController } from \"./controller\";\r\nimport { RouterModule } from \"@mayajs/router\";\r\nimport { UsersServices } from \"./services\";\r\n\r\n// Define the routes\r\nconst routes = [\r\n  {\r\n    path: \"/\",\r\n    controller: UsersController,\r\n  },\r\n  {\r\n    path: \":id\",\r\n    controller: UsersIdController,\r\n  },\r\n];\r\n\r\nexport class UsersModule extends MayaJsModule {\r\n  // User `RouterModule.forRoot` to inject the routes\r\n  imports = [RouterModule.forRoot(routes)];\r\n  // Declare the controllers that will be used inside the routes\r\n  declarations = [UsersIdController, UsersController];\r\n}\r\n```\r\n\r\n## CUSTOM MODULE\r\n\r\nUnlike the common mayajs module, custom modules provide other functionality aside from managing your controllers. One example of this the `RouterModule` that is reponsible for adding routes to your module. A key concept of a custom module is it has an `invoke` and `forRoot` function that provides additional functionalities.\r\n\r\n```ts\r\nexport class UsersModule extends CustomModule {\r\n  invoke() {\r\n    // This function will run after an instance of this module is created\r\n    // But the providers will stay singleton on each instance\r\n  }\r\n\r\n  static forRoot(options: any) {\r\n    return {\r\n      module: UsersModule, // Returns the current module reference\r\n      providers: [], // List of providers that this module will use on its controllers\r\n    };\r\n  }\r\n}\r\n```\r\n\r\nNow we know how to create a module but how we can call it on our routes. We are now introducing to `loadChildren` property of our route object. MayaJs will automatically resolve the module asynchronously when the path is added on the route list.\r\n\r\n```ts\r\nimport maya from \"@mayajs/router\";\r\nimport http from \"http\";\r\n\r\nconst app = maya();\r\n\r\napp.add([\r\n  {\r\n    path: \"users\",\r\n    // We are using dynamic importing so we don't need it to manually import the module in the file\r\n    // MayaJs will resolve the module asynchronously\r\n    loadChildren: () => import(\"./users.module\").then((m) => m.UsersModule),\r\n  },\r\n]);\r\n```\r\n\r\n## Collaborating\r\n\r\nSee collaborating guides [here.](https://github.com/mayajs/maya/edit/master/COLLABORATOR_GUIDE.md)\r\n\r\n## People\r\n\r\nAuthor and maintainer [Mac Ignacio](https://github.com/macign)\r\n\r\n## License\r\n\r\n[MIT](https://github.com/mayajs/router/blob/develop/LICENSE)\r\n","readmeFilename":"README.md","_id":"@mayajs/router@0.5.0-rc3","_nodeVersion":"12.16.1","_npmVersion":"6.13.4","dist":{"integrity":"sha512-WpXfmpzY3oRYODB7UaSA9yLgyAT9IbJhRB81CmV3TX7PoUUxIVPsxA2xAyOJUGEu+ZPLid/xDmPIWApVAuYuiw==","shasum":"9118070b787f419075dbbc16d12b706800812048","tarball":"https://registry.npmjs.org/@mayajs/router/-/router-0.5.0-rc3.tgz","fileCount":37,"unpackedSize":65975,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgkv1OCRA9TVsSAnZWagAAupoQAIxVf43BfEF0nYl2zn0n\n0EqG4vbqU3sNHRkVE8oS+HHJ6jWdIcjcsO0BYznc0Z2tUeQrb8U6CrpSfRoZ\nBv42LjaQmLErS66Tz6mCn2SDPaGMcWnaVbI73uX5N7W+BjFI/be2gYxnhg0e\ngcwQRVqly3N6L8QzAn9W23W8y9x1ZHGH1p0lI4PR+20OEB8Qq6j6ZOVlnobS\nH0O2NSLfI2nFgMPjTYNkE8nDPNUfOm/OVcW7FXmGsArQr5tL8/qnJlYCASm4\niTDY0BvSvHwhiRRDyKzEqDPN4VezVsBqPDmExl2EMDfv/8i5Wsa5uR5UiYZu\nQlAibi+kuczpxSfhZ4f4l5vYYCiWReQlqlT2G9dkxI5tTP8CW+T3BKm8b+6E\n+gzhM7a0H/VAF8LbGiFJoFK09ETfZayOzo6ZWxl/F2lEgoRxVSFYJhTE9+MB\nV3no/FDdjuLCTm84OIFZU9JFZ/KUlruSZaa1BQVdcUx9sl7DOo+GPS4zGayc\ncR05OEhvSBm4CdIyfGyj431g/9e2q//EV5ZooueGLNKLLpbETvI7fZn/F5ku\nLMzVGms+yM3gM+OmcUdKEjReUW+6BOewLB3D+vcWqcV2VM+r4+934V7PCtVH\nvcdnKswrXgZZG97g9KkwylhbPZac1l9n16KPmsleKY4G6tQPqM/EsJp0fz3/\nKqMW\r\n=l0hU\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEMCIGrU5Q/XsZCFJ7Rmtv8QLYkpvIadC7TKg3p9iQoDvWDqAh9dnqORyHV7NG38WR97mPAHgZqhDC/aXskdd02blG+M"}]},"_npmUser":{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"},"directories":{},"maintainers":[{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/router_0.5.0-rc3_1620245838155_0.09698271962489735"},"_hasShrinkwrap":false},"0.5.0":{"name":"@mayajs/router","version":"0.5.0","description":"Simple NodeJS routing library created using Typescript","main":"lib/index.js","scripts":{"clean":"rimraf interface && rimraf index.js && rimraf index.d.ts && rimraf utils && rimraf router && rimraf lib && rimraf class && rimraf exceptions && rimraf types","tgz":"rimraf *.tgz","package":"node ./scripts/clean-package.js","start":"npm run clean && npm run tgz && tsc -w","prepack":"npm run clean && npm run package && tsc --outDir ."},"keywords":["nodejs","server","router","typescript","library","REST","API","mayajs"],"author":{"name":"Mark Anthony C. Ignacio"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/mayajs/router.git"},"bugs":{"url":"https://github.com/mayajs/router/issues"},"homepage":"https://github.com/mayajs/router#readme","devDependencies":{"@types/node":"^13.11.0","jest":"^25.2.7","rimraf":"^3.0.2","ts-node":"^8.8.2","typescript":"^3.8.3"},"engines":{"node":">= 0.10.0"},"gitHead":"e09c16da6ced082af2f3347f7d6b52747c05cf3b","_id":"@mayajs/router@0.5.0","_nodeVersion":"12.16.1","_npmVersion":"6.13.4","dist":{"integrity":"sha512-Matt8zkLuWY4FyR+2GylINUUTz24zFy3LEl42l3oaoqHw4ZnBaShXRysLD+5nYMTpiBymkN6fG1dUul2Uzsqdg==","shasum":"566c00117195f37f34985e6cd6004740c33b227d","tarball":"https://registry.npmjs.org/@mayajs/router/-/router-0.5.0.tgz","fileCount":37,"unpackedSize":65971,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgkv7sCRA9TVsSAnZWagAADIcP/3kv5M0qrz/I3QZiDRCh\n6cJ/OPAIq3/q8R7XZI//asAoYyGVMsFrEBGKlYCMRIsCq+Sw1Q/7Pwdx79Ie\nyoSNj5Bh4dd89BHjswSpyMcNcNPEcepsnA580LhZST+xxjDHSuEVEiurl10d\nb0NnlLBzhSIp+e/A5BGeZiXjESap2AgY1OACt25qBJqwXew8y6Jjbu9n2NlF\nleOZHoFqabL71l68ZXKu7AKBWy8Pq46Nsw17Etj+E43/PxfcnDsFffj1qdeX\n62NsYRtiS86uXVFUrc0R9+rxThLBL+UVhjlcSfhAEreht7rTfe19XjSi7Vcz\nwJUnbaIiU8wehWA8nGxFw9jr7vrqV105uZxzHDK0daimReEuhq686ESiYm59\n8i4KiPBE2SSXll8VIMUaI0sFqLyOl45tU/iphgPRnS1IwAb+B3y1PcGPkkAC\nbXojk+XgQPgkblHyiXjJkjf9fTB70GFCCl8xQrjNR4es+ZYTyD+AkKcS96wa\niXUgnpTIAIL7j380VLL97+c2eIyuX5rRT7EMeqdmIGKiGWhLKY4nZqrSV7rY\nxY73MKFY8ItAIRMsam8RTIndhm76UGup1eFWg0nZNA5YQks+Wln9MuLCw/FP\ndbKrR64LfVB5n7+5sz3pBaf3WvTtbPECr5no2XljdiS8nXhYrXPakC0gf7Zy\np/9q\r\n=4Qu0\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCFk7KQw24YvIe2krlnsglu39xaFm1wa0zeBilXwyIcsQIhALZ+uXDFcxB+pbama6r8SwZV9KBDKqf7LmHCKBzX6Cn1"}]},"_npmUser":{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"},"directories":{},"maintainers":[{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/router_0.5.0_1620246251713_0.8945854803323612"},"_hasShrinkwrap":false},"0.5.1":{"name":"@mayajs/router","version":"0.5.1","description":"Simple NodeJS routing library created using Typescript","main":"lib/index.js","scripts":{"clean":"rimraf interface && rimraf index.js && rimraf index.d.ts && rimraf utils && rimraf router && rimraf lib && rimraf class && rimraf exceptions && rimraf types","tgz":"rimraf *.tgz","package":"node ./scripts/clean-package.js","start":"npm run clean && npm run tgz && tsc -w","prepack":"npm run clean && npm run package && tsc --outDir ."},"keywords":["nodejs","server","router","typescript","library","REST","API","mayajs"],"author":{"name":"Mark Anthony C. Ignacio"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/mayajs/router.git"},"bugs":{"url":"https://github.com/mayajs/router/issues"},"homepage":"https://github.com/mayajs/router#readme","devDependencies":{"@types/node":"^13.11.0","jest":"^25.2.7","rimraf":"^3.0.2","ts-node":"^8.8.2","typescript":"^3.8.3"},"engines":{"node":">= 0.10.0"},"gitHead":"9cb8863dc3bf622f488fa52384702787213ec373","_id":"@mayajs/router@0.5.1","_nodeVersion":"12.16.1","_npmVersion":"6.13.4","dist":{"integrity":"sha512-W2k9Z6Yl5mW+oU1g68wa19ncOCBl/WtofFqYtfARMtoSW8YKxJ2ZnaXXxi23US9X6F2uRNUo8MFYdSWFasqDqw==","shasum":"352a7d67199c3657f48aea873d5be629fd5d3016","tarball":"https://registry.npmjs.org/@mayajs/router/-/router-0.5.1.tgz","fileCount":37,"unpackedSize":66451,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgnpr3CRA9TVsSAnZWagAAqd0P/19xsyXa98psDoPEqvHY\nPQ8avC0g3M1XVe2id7HMcC4VH9gGczLmvusbJjiAItuRWapS1mrnywCqix/W\nJMyXlfwn66wsPCYT81lNbZGLjXdswz7zD8mm9p3k7lqvp6HLwzgJmtSRIyYZ\nHQRbITpaL4VuwzUykJstaxhVsGf2gkiZmuNIGCidUMOY0m5gwcwql7i0u1TV\nmZ7AhkKXMiqw3OCiyWHwYHAKc6DDuDzI+zAPV0CwdruR8iujzJcMChOjfEMZ\npozWW6rBZgy3zkAY0MYb0Ot9GGP4Y/Mm8tW+uBFyQhayR+PkJEUCsIWAVgWU\naMVDHmajhfxGRiBGBUT7shxK5n+K/gNpIxRpCW8w5kCwxxIM9I9wsarYeHrL\nUtgt+zgiq6xq+gMVEzUMIM7+URBIh4rrCGdgPrcD7XaOQuCnI0qZdZuWODrM\nZdfa8ri3QWNLenCJ6cwwn+Na3PzhzPVj/Jrt3dDKbY9oXVsMs3MwJHMiamqe\nOMp+FiTqOEss7VVPbUw4HaHCPaEjqEngySf4Px8hVz0dyeEs9kJ7tndocc4f\n2tbr0TPIHgwoJsGVKHCMsH2PDw7ArWBA9worDMfVhfZWBirEOCZkn4xgAiGG\nNuytJnKQSRBrjOCW0nXnt5LTbKsQnuqDaXU9GTetrLVHXAiW8NSXcbpa8BcW\n5gWT\r\n=l1Nu\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGXPJhUi2Moy76SOtjuoyehiNa53Caw7cxX8QQuzgxyBAiEA/CelPpASzsVUArTj6yjoAfbXDrFGOVQZvCPNyvYZ4V0="}]},"_npmUser":{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"},"directories":{},"maintainers":[{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/router_0.5.1_1621007095104_0.9501356391572562"},"_hasShrinkwrap":false},"0.5.2":{"name":"@mayajs/router","version":"0.5.2","description":"Simple NodeJS routing library created using Typescript","main":"lib/index.js","scripts":{"clean":"rimraf interface && rimraf index.js && rimraf index.d.ts && rimraf utils && rimraf router && rimraf lib && rimraf class && rimraf exceptions && rimraf types","tgz":"rimraf *.tgz","package":"node ./scripts/clean-package.js","start":"npm run clean && npm run tgz && tsc -w","prepack":"npm run clean && npm run package && tsc --outDir ."},"keywords":["nodejs","server","router","typescript","library","REST","API","mayajs"],"author":{"name":"Mark Anthony C. Ignacio"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/mayajs/router.git"},"bugs":{"url":"https://github.com/mayajs/router/issues"},"homepage":"https://github.com/mayajs/router#readme","devDependencies":{"@types/node":"^13.11.0","jest":"^25.2.7","rimraf":"^3.0.2","ts-node":"^8.8.2","typescript":"^3.8.3"},"engines":{"node":">= 0.10.0"},"gitHead":"847fcb2a4dbeee219b6aa360f2c4d694e4bd807e","_id":"@mayajs/router@0.5.2","_nodeVersion":"12.16.1","_npmVersion":"6.13.4","dist":{"integrity":"sha512-vBmG6tSiQ1eEPj9jt0+aomRS3ppXEqbTbog/blbgpL+UdeEzxH27EBN5a1uCqaje7ImHF/AoEGwBm4wtTXPoqQ==","shasum":"0ea0a406dc591b138da88194852a15b014bfcd28","tarball":"https://registry.npmjs.org/@mayajs/router/-/router-0.5.2.tgz","fileCount":37,"unpackedSize":67194,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgnqguCRA9TVsSAnZWagAAM0QP+gIzlXcFq3STqLz+kHE8\nFXXqld/p4jaO1jLyz17tdCnxPo5wgX2lahQ1beMvEqawxCntU/X8rC7MrATj\nZuG5rTSCbyoO/pyNTWuVFdmxbkiKR2D+ackcknU7Iy61/zeTxyKXHq+n82Rq\nu68yr0droYsviB8Y/Mm8S6VDNPdwHIo0Thg1wfFGImng7r/LzoKZ6aOPe5nr\n7b2Sx+TRexiJXHktxNEm+OXauJArBwxeenn9CXDf5tJ3YvQecqab2NwyzgYP\nvpX93MFN9ZbSWXKp5PV3l5O7qJtmyJnvDxrrLSyEuV0tzj5PWYxPuPn2XpfI\nQH8rNxqq6x9Clgv/Y5lVJ2ZMjEuxaZWWvlsMmNfa8mOdDWKxKb3Pd5cZKeYW\n4mGb94Cr13aHqnqgiCWuuRMeH09s2mJqck7zlPjtxzxowx55SJwIpKN8r3YY\nK0US6SN4gEjLWeBtoV7E8tj1IOVsOOWbNy09ix924OuPPHJND3QeQbVBaW1K\nxjUw6E1ADs3kzMtWYq+dLWa71M9Kcs/8MznTcoi/OcsmuVKNdSB6SUXljHnt\nDcDHBgs9JdPHgz1SNvvdNzKXyY18W+rkkrLqJOAF/XrhYvd6aZPsz1DspARe\n6kJ+fR7E9z67pqfAbi5vpYcGZjtck7zU3L62Plt5eCBWVrHWjThFI2YfqSAx\nR9pU\r\n=8q2P\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBWZu48HBJBTW6XJWlBwGW39BQucoiEkT0azpL8weIQxAiB5nqbbJWr90LsdfvqLriOO5oXRRkzEr3t+gxKYTZ+sIA=="}]},"_npmUser":{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"},"directories":{},"maintainers":[{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/router_0.5.2_1621010477591_0.19344055222026246"},"_hasShrinkwrap":false},"0.5.3":{"name":"@mayajs/router","version":"0.5.3","description":"Simple NodeJS routing library created using Typescript","main":"lib/index.js","scripts":{"clean":"rimraf interface && rimraf index.js && rimraf index.d.ts && rimraf utils && rimraf router && rimraf lib && rimraf class && rimraf exceptions && rimraf types","tgz":"rimraf *.tgz","package":"node ./scripts/clean-package.js","start":"npm run clean && npm run tgz && tsc -w","prepack":"npm run clean && npm run package && tsc --outDir ."},"keywords":["nodejs","server","router","typescript","library","REST","API","mayajs"],"author":{"name":"Mark Anthony C. Ignacio"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/mayajs/router.git"},"bugs":{"url":"https://github.com/mayajs/router/issues"},"homepage":"https://github.com/mayajs/router#readme","devDependencies":{"@types/node":"^13.11.0","jest":"^25.2.7","rimraf":"^3.0.2","ts-node":"^8.8.2","typescript":"^3.8.3"},"engines":{"node":">= 0.10.0"},"gitHead":"c18907fe7ce731c9001553bef6c86d8dba81a893","_id":"@mayajs/router@0.5.3","_nodeVersion":"12.16.1","_npmVersion":"6.13.4","dist":{"integrity":"sha512-0elCHjsvK+Tu8eNIXOmoaiPmWqNz8inxqpzX1Bs6Zc2mw5dMSkX+tOVtG3/nOcrlfMjMizMCPiZwIxjZ/HXWOg==","shasum":"714fff1ab73f3eaac58db813050b5816dc8dad75","tarball":"https://registry.npmjs.org/@mayajs/router/-/router-0.5.3.tgz","fileCount":37,"unpackedSize":67203,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgn+1LCRA9TVsSAnZWagAAUK0P+gLQEaJE4iKNmF6Ei+mL\nUDgoRh09v3p/J5XOeX1ZHX+hL8E99PDUD+bILdnhAXoarY0tcmDUE5yamGES\nCKS7HyMD2UtC9+Db6mw2Bm+gTi4Z6a1l1APfjRZxcEzOLEjdzGyg7lC7cHET\nZAB9zwr20ekAXI/BsPZicJ2Ya0YKfhE5xBUtFPOShPxGNJHwTgO5z5ce3iL/\njsnfmOcqf4vo1LZw80M+ZuYlDx9D67BIlLonn1Wd4OQTW7rq+AzdXMRPvVec\nmzB0C+oPqFdqe+wnu29rmJyjWEukDmcQLAxfhZG5VwU5Ff7Hd7KJfDuJGSyY\nwaRW/CrCjs712DIQhfJIbLBimuCyXPgs6ceILbJVfTegezLElqAlQK5KLEyE\nUVqLHIaKROUUD60Dj/dpG6agU6+O4FawTdHKEhXmgN0ouY7TaLzy0Dgol73b\nHAH1/+0ZkCK4U4lXq3pXQZOF2QZTNjQ0oIM1e/ctUDEt/GJBxbT4Kv1C6V3y\nO2KRCkeXohFQ3/+yaC0qyjWpUIR8bcnryIZTKpuA54tEx5PVpwrKfjmet0EJ\nk3T+BBiyvedFF6PocEcV0KpklDgtFtbDnbXwxF8fMslCWYQEz9KEqRJYydWc\n5YEaVT4ajQA9DaH4Zy5pPzIshFpRnT8Fpvph0lNAXD24odLLoOkcmlj+8gb+\nw4wS\r\n=YfVn\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC25L6R2+DqC+2euMJpm6+bEzIAILYKKsoaHrTGYsuH3wIhAIYmr2b6H76JO3/PM2k0Xlcvrd/l8TTXsx8ZyIE825oJ"}]},"_npmUser":{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"},"directories":{},"maintainers":[{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/router_0.5.3_1621093706450_0.7879355981472611"},"_hasShrinkwrap":false},"0.5.4":{"name":"@mayajs/router","version":"0.5.4","description":"Simple NodeJS routing library created using Typescript","main":"lib/index.js","scripts":{"clean":"rimraf interface && rimraf index.js && rimraf index.d.ts && rimraf utils && rimraf router && rimraf lib && rimraf class && rimraf exceptions && rimraf types","tgz":"rimraf *.tgz","package":"node ./scripts/clean-package.js","start":"npm run clean && npm run tgz && tsc -w","prepack":"npm run clean && npm run package && tsc --outDir ."},"keywords":["nodejs","server","router","typescript","library","REST","API","mayajs"],"author":{"name":"Mark Anthony C. Ignacio"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/mayajs/router.git"},"bugs":{"url":"https://github.com/mayajs/router/issues"},"homepage":"https://github.com/mayajs/router#readme","devDependencies":{"@types/node":"^13.11.0","jest":"^25.2.7","rimraf":"^3.0.2","ts-node":"^8.8.2","typescript":"^3.8.3"},"engines":{"node":">= 0.10.0"},"gitHead":"6d5e241ab3211ab5b0b33b6b80f1fbf6bf8e9781","_id":"@mayajs/router@0.5.4","_nodeVersion":"12.16.1","_npmVersion":"6.13.4","dist":{"integrity":"sha512-eyizlXj+O1Ks3vXET9FOaA5n4fk6gFDkO+6guYkugSh0Tyh1lcu3xkh1CJ5Z7Myon79mH25mKwmnRktN2vUdMQ==","shasum":"a96bf5195bc5e248c21799c09956eb491abcf83f","tarball":"https://registry.npmjs.org/@mayajs/router/-/router-0.5.4.tgz","fileCount":37,"unpackedSize":68179,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgoPB3CRA9TVsSAnZWagAAZOEQAJZAW6L/JsU1dQ0sCv96\ndRH4MOcTCXcjipZ/hU6RlV+zRwXpuYMHKZ+89VkcZ2jGkltIL1WcjRdvnlvI\nQA30HJK1MthwgdzF4ZFvvfkemHa3HrBWPjy3TjzGxxVqDdr3LN25JqbmiFDg\n8z0FJRANGW8kwE8M8atFUEIRCnzU+DY3c+2U/ZM3WtJ24kSEwG0SPZghvjkx\njBtlsXwPIwPh2lEuCTKXADGk8QAlS9P1QKjPJm0Wf7PLOkoCLAmIdgbC//72\nW0l/ArZLfZaU27CADZB3Lti9hxzwACKnzesZ1xs1Swhl4RlAk1IHBKI5ukhJ\nJZ+pkGZXyoKvEjDtyQ3R/+oi1v0GUQFZQwz93/1+7YeSNjUp6AL06+oQ4PFn\nXiEDBihgpJr0d4GFSg0Y9VxnEyheoXSgMiHfzzpIwWMHCp1YQUrVy5F5zeyI\nVW7U194CpFSXbShKz70MEJHGnSAN1pU5Vw8jad2facG+iTnlkfjLeFGYtB0b\nQ5OrPqPrjmUMYCMV83K+jOMJZVud6RsiX01I6+GEKxYSnpdaYMKXNHzmvCnP\nQdeVCE+oZB6JrbQcUMjA3kwVeuFQv620pPyKtU85l4wEFcrngnSPYt4c58Fm\nUMhfkBmecml9lrj4bStS/up5BJrf7KA2daw6QJlgEF283SdHYbxsOX+Ndk6d\nvDj5\r\n=If/P\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDJs1bookJB9YTVTI8rVXsdukpcQv3UOcTfzkq79vmwGgIgHtM47mExdhkIbZ9oMm/eQmCR7sUJsdBQ53W+VGSJkSI="}]},"_npmUser":{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"},"directories":{},"maintainers":[{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/router_0.5.4_1621160055039_0.7441082556887897"},"_hasShrinkwrap":false},"0.5.5":{"name":"@mayajs/router","version":"0.5.5","description":"Simple NodeJS routing library created using Typescript","main":"lib/index.js","scripts":{"clean":"rimraf interface && rimraf index.js && rimraf index.d.ts && rimraf utils && rimraf router && rimraf lib && rimraf class && rimraf exceptions && rimraf types","tgz":"rimraf *.tgz","package":"node ./scripts/clean-package.js","start":"npm run clean && npm run tgz && tsc -w","prepack":"npm run clean && npm run package && tsc --outDir ."},"keywords":["nodejs","server","router","typescript","library","REST","API","mayajs"],"author":{"name":"Mark Anthony C. Ignacio"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/mayajs/router.git"},"bugs":{"url":"https://github.com/mayajs/router/issues"},"homepage":"https://github.com/mayajs/router#readme","devDependencies":{"@types/node":"^13.11.0","jest":"^25.2.7","rimraf":"^3.0.2","ts-node":"^8.8.2","typescript":"^3.8.3"},"engines":{"node":">= 0.10.0"},"gitHead":"fb6e5d05739c3b71e879f7ca34983479f22c7b07","_id":"@mayajs/router@0.5.5","_nodeVersion":"12.16.1","_npmVersion":"6.13.4","dist":{"integrity":"sha512-u34tx7JTexJXI1bJ6gvphZNHVlITFLB5+ZJ5/B9HMpMQKqrwIhMubZ1of/K8lBk2meMLcHFfTJxI1MSMBzVqsw==","shasum":"a9ee56b0bfa7893986d95bf41083e475eaf8315e","tarball":"https://registry.npmjs.org/@mayajs/router/-/router-0.5.5.tgz","fileCount":37,"unpackedSize":68169,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgoQIFCRA9TVsSAnZWagAAgRgQAJrkC265Z303De9oa3XO\naeWyF5jRkXnebX+Y/g6unySQNPePgjjC2DAcoOeTH34Z11/QtC0Wc+9aIQTe\nrrQjTN8FO1HU4CW+2Y4iqNdWaKHK9o0EgvpQMCJAJP51G9+6rgbSp1BkYLdz\nVLSl6uKcbsd4t1gulaAw1hgPlOd3d/hdHKDBHrwR64PshxqAJ5x/USe352qN\nZQibwPJIrVHVf4F4NtKaNtML9o8uakSFaXJJ1xgs76LCzix2tuhiy3KvTipc\nX5sweYor6o5yrzq5GBAhAB2j2AI/gSjcSMQfD1hKvaglDM3ivnGeL0YySYra\n8UDY1SF86GfA07QoSZUv01ikXM6vldZ6IOyuaR8SBYBGdi65U+QEtRRwidfS\nRtxt57/SJo9vzbZztm/Yxdk57R2T4R79I4UGmMjmqVA6E3DSRPuUoS/bzrGR\njsYFRytTioNl1oGxG0PwXNFsq6N0ZIUAyy4cz1bBlj8+isOUGrQDrHXuZyxW\n7hluW8BPhRp35SS4KIMvgn0HJ34Xye8PgJdzPoc25Fle9jC9J0iHOLul8U+i\nyzBt7D++3vakEk02DlumCkF59mCb1ay0Ex/jbe8DuQGoCx35p46NVJL/I9Fh\n70/0QUyYLBbAqAyzQb6FhlukncVq2/RUTFrQdV/fBglnmwyQiEI+5hf/qdNA\nV4/G\r\n=7RQu\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGMGLGbCex5ufDZ5g1AlRwbAECDsNxevr/aZyR/2YGNhAiEAvjxp7lQ/Q+rcoKN60nJH0SUG3E3DXx0MPfQdQBxYZxQ="}]},"_npmUser":{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"},"directories":{},"maintainers":[{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/router_0.5.5_1621164549198_0.42773473472120926"},"_hasShrinkwrap":false},"0.5.6":{"name":"@mayajs/router","version":"0.5.6","description":"Simple NodeJS routing library created using Typescript","main":"lib/index.js","scripts":{"clean":"rimraf interface && rimraf index.js && rimraf index.d.ts && rimraf utils && rimraf router && rimraf lib && rimraf class && rimraf exceptions && rimraf types","tgz":"rimraf *.tgz","package":"node ./scripts/clean-package.js","start":"npm run clean && npm run tgz && tsc -w","prepack":"npm run clean && npm run package && tsc --outDir ."},"keywords":["nodejs","server","router","typescript","library","REST","API","mayajs"],"author":{"name":"Mark Anthony C. Ignacio"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/mayajs/router.git"},"bugs":{"url":"https://github.com/mayajs/router/issues"},"homepage":"https://github.com/mayajs/router#readme","devDependencies":{"@types/node":"^13.11.0","jest":"^25.2.7","rimraf":"^3.0.2","ts-node":"^8.8.2","typescript":"^3.8.3"},"engines":{"node":">= 0.10.0"},"gitHead":"53369fed77a00d8dc0d498466836b7c950e8cec8","_id":"@mayajs/router@0.5.6","_nodeVersion":"12.16.1","_npmVersion":"6.13.4","dist":{"integrity":"sha512-f3NKtOgN4Hk2Vw5VlpN7x2B+hNKORI8KjDECXkmICiZ1UPvEkc1vg9tvF718F/V6UtopZivG/8fiT4zt1xgaMA==","shasum":"b592961546058c02819e9e95d3b05c31cb38425e","tarball":"https://registry.npmjs.org/@mayajs/router/-/router-0.5.6.tgz","fileCount":37,"unpackedSize":68796,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgoUrvCRA9TVsSAnZWagAAxA4P/2fP7Cb1EjwF6F14qKSB\nRAx0B7AtHtQyJpcnnO/5nUWGVs1VBAhXXTJr3US6qqHGWqOWYZOMJ6SPQbwq\nTYqK1yuRHp7uin//6Nwkr0H5MjieRBDrCXb1WOtUNni44ucvskS86zJ94uK8\nSOLdqbkeJ26l8T4juh6+UKGXoCeCBB3bve0LLtaK2Tv+bOCMhcBTPkWAhMhA\n6Xq38OB4Hlt2TDZSsp9DYFFdkMozqsxjs1+5Rx4GJZ7mZHtKRY9PB3ladblC\nOSD0ZjgD6/zFBq7ZECUTtmthDzZZkhod2hSlQCuBnXFbskT6XpX1aUpFyhCR\niwpK6dClX/U0v8rvhBgBl/RuCx3epmE3TgVYPfxAYeAGby1SXAO93MAMDxFy\nkA9kR4ROebgbt7mHJiFoVPtdczov7wkmvrOewoGJI1+GXkADp/qSkvfAqOn/\ntyWtnZM77TRSgETJZP5gJu2BfA9DzoPcnECqd8tzlkNtoVohuAHgXjtsTRiD\n5epfyG3AZ+87jETK6J5wo8tNKmVu4uS3ZiJZMJJdbauNPZDW5B1F5rtUzqNT\n8lfbsrdBp/caC8SLJBXkpwfoLW7f4Mh+nwWpdqHsHZYvAfa6x733jiNyDVYc\nvxa4KgXmz/khJjEiXvLhow6pVumzpOfRUYqPiUwvywBmIfw0guk5UatD/YwU\nwKds\r\n=bG15\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDz2SzSb+JCj2ZAkQvqPwRugHSA/Ud4HSFBvVo2Tj80sQIhAJSWG8V5+h+eoQyg6/zuKW+iNWSUJPtH9Ct4s8AxrQ34"}]},"_npmUser":{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"},"directories":{},"maintainers":[{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/router_0.5.6_1621183215336_0.8952038569340521"},"_hasShrinkwrap":false},"0.6.0-rc":{"name":"@mayajs/router","version":"0.6.0-rc","description":"Simple NodeJS routing library created using Typescript","main":"lib/index.js","scripts":{"clean":"rimraf interface && rimraf index.js && rimraf index.d.ts && rimraf utils && rimraf router && rimraf lib && rimraf class && rimraf exceptions && rimraf types","tgz":"rimraf *.tgz","package":"node ./scripts/clean-package.js","start":"npm run clean && npm run tgz && tsc -w","prepack":"npm run clean && npm run package && tsc --outDir ."},"keywords":["nodejs","server","router","typescript","library","REST","API","mayajs"],"author":{"name":"Mark Anthony C. Ignacio"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/mayajs/router.git"},"bugs":{"url":"https://github.com/mayajs/router/issues"},"homepage":"https://github.com/mayajs/router#readme","devDependencies":{"@types/node":"^13.11.0","jest":"^25.2.7","rimraf":"^3.0.2","ts-node":"^8.8.2","typescript":"^3.8.3"},"engines":{"node":">= 0.10.0"},"readme":"<p align=\"center\"><img src=\"https://github.com/mayajs/maya/blob/master/maya.svg\" ></p>\r\n<h1 align=\"center\">MayaJS Router</h1>\r\n<p align=\"center\">\r\n  <a href=\"https://www.npmjs.com/package/@mayajs/router\"><img src=\"https://img.shields.io/npm/v/@mayajs/router.svg?style=for-the-badge&logo=appveyor\" alt=\"Version\"></a>\r\n  <a href=\"https://www.npmjs.com/package/@mayajs/router\"><img src=\"https://img.shields.io/npm/dm/@mayajs/router.svg?style=for-the-badge&logo=appveyor\" alt=\"Downloads\"></a>\r\n  <a href=\"https://www.npmjs.com/package/@mayajs/router\"><img src=\"https://img.shields.io/npm/l/@mayajs/router?style=for-the-badge&logo=appveyor\" alt=\"License\"></a>\r\n  <a href=\"https://github.com/microsoft/typescript-tslint-plugin\"><img src=\"https://img.shields.io/badge/code%20style-standard-blue.svg?style=for-the-badge&logo=appveyor\" alt=\"Code Style\"></a>\r\n</p>\r\n<h2 align=\"center\">Lightweight, simple and fast NodeJS Router developed using Typescript.</h2>\r\n\r\n## Motivation\r\n\r\nWe develop this library to be used as the main router for [MayaJS](https://github.com/mayajs/maya#readme) RESTful API framework. As much as possible we want to have a full control of\r\nthe libraries we used in our main projects for maintainability and ease of transition for future updates.\r\n\r\n## Roadmap\r\n\r\nYou can see the detailed roadmap of the project [here.](https://github.com/mayajs/router/blob/master/ROADMAP.md)\r\n\r\n## Suggestions\r\n\r\nFor suggestions and features you want to see in the future you can visit our [issues section.](https://github.com/mayajs/router/issues)\r\n\r\n## Getting started\r\n\r\nBefore installing this package make sure to download and install Node.js 10 or higher.\r\n\r\n### Setup Node\r\n\r\nTo check your node version\r\n\r\n```shell\r\nnpm -v\r\n```\r\n\r\nFor new project kindly initialize npm using the command below or see documentation [here](https://docs.npmjs.com/creating-a-package-json-file).\r\n\r\n```shell\r\nnpm init\r\n```\r\n\r\n### Setup Typescript\r\n\r\nInstall typescript and typescript watcher\r\n\r\n```shell\r\nnpm i typescript ts-node-dev -D\r\n```\r\n\r\nInitialize typescript\r\n\r\n```shell\r\ntsc --init\r\n```\r\n\r\n### Setup Router\r\n\r\nInstall mayajs router\r\n\r\n```shell\r\nnpm i @mayajs/router\r\n```\r\n\r\nAdd `start` script on your `package.json`\r\n\r\n```js\r\n\"scripts\": {\r\n  \"start\": \"tsnd src\"\r\n}\r\n```\r\n\r\n## Features\r\n\r\n- Simple and easy\r\n- Lightweight library\r\n- Built with TypeScript\r\n- No third party library\r\n- Modules for shareable code\r\n- Dependency Injection and IOC\r\n- Fast execution with route caching\r\n- Supports beginners to advanced developers\r\n- `Function` and `Class` based coding style\r\n- Supports third party middlewares like `ExpressJS`\r\n\r\n## Quick Start\r\n\r\nThe easiest way to get started is to create a simple route. Create a `src` folder inside your project folder. Inside the `src` folder create an `index.ts` file. Copy the code below into `index.ts` file.\r\n\r\n```ts\r\nimport maya from \"@mayajs/router\";\r\nimport http from \"http\";\r\n\r\nconst PORT = 3000;\r\nconst app = maya();\r\n\r\napp.add([\r\n  {\r\n    path: \"/\",\r\n    GET: () => \"Hello, World\",\r\n  },\r\n]);\r\n\r\nhttp.createServer(app).listen(PORT, () => console.log(`Server listening on port ${PORT}.`));\r\n```\r\n\r\n## RUN\r\n\r\nTo run your mayajs project open a terminal inside your current project and run the command below.\r\n\r\n```shell\r\nnpm start\r\n```\r\n\r\n## ROUTE\r\n\r\nDefining routes in MayaJs is like creating a JSON object.\r\n\r\n```ts\r\nconst user = {\r\n  path: \"user\",\r\n  GET: () => {\r\n    //  ...\r\n  },\r\n  POST: () => {\r\n    //  ...\r\n  },\r\n  PUT: () => {\r\n    //  ...\r\n  },\r\n  PATCH: () => {\r\n    //  ...\r\n  },\r\n  DELETE: () => {\r\n    //  ...\r\n  },\r\n  OPTIONS: () => {\r\n    //  ...\r\n  },\r\n};\r\n```\r\n\r\nAs seen above each method name has a `callback` function. Mayajs will set the correct `content-type` based on what the method callback will return.\r\n\r\n```ts\r\nconst route = {\r\n  path: \"user\",\r\n  GET: () => {\r\n    // This will return `undefined`\r\n    // This will have a content-type of \"text/plain\"\r\n  },\r\n  POST: () => {\r\n    return \"Hello\"; // This will have a content-type of \"text/plain\"\r\n  },\r\n  PUT: () => {\r\n    return { message: \"Hello\" }; // This will have a content-type of \"application/json\"\r\n  },\r\n  PATCH: () => {\r\n    return \"<h1>Hello</h1>\"; // This will have a content-type of \"text/html\"\r\n  },\r\n};\r\n```\r\n\r\nIncase you need to use a middleware for an specific route method you need to create a route object instead.\r\n\r\n```ts\r\nconst route = {\r\n  path: \"user\",\r\n  GET: {\r\n    middlewares: [middleware],\r\n    callback: () => {\r\n      // ...\r\n    },\r\n  },\r\n};\r\n```\r\n\r\n## PARAMS\r\n\r\nMayaJs passes a context object on each route method. You can acces the route params by destructuring the context object on the callback method.\r\n\r\n```ts\r\nconst route = {\r\n  path: \"user/:id\",\r\n  GET: ({ params }) => {\r\n    // `params` object contains the value of `id` define on the path above e.g. `user/hello`\r\n    return params.id; // This has a value of \"hello\"\r\n  },\r\n};\r\n```\r\n\r\n## QUERY STRING\r\n\r\nYou can also access the query string using the context object provided by MayaJs on your route method callback function.\r\n\r\n```ts\r\nconst route = {\r\n  path: \"user\",\r\n  GET: ({ query }) => {\r\n    // `query` object contains all the value on your query string e.g. `user?id=1`\r\n    return query.id; // This has a value of 1\r\n  },\r\n};\r\n```\r\n\r\n## BODY\r\n\r\nRequest body is also accessible in the context but you need a middleware before you can actually uses. There is a popular middleware called [body-parser](https://www.npmjs.com/package/body-parser) that we can use to achieve this.\r\n\r\n```ts\r\nimport maya from \"@mayajs/router\";\r\n// Third party middleware you need to install\r\nimport bodyParser from \"body-parser\";\r\n\r\nconst app = maya();\r\n\r\n// Initialize body parser for mayajs to use it internally\r\napp.use(bodyParser.json());\r\napp.use(bodyParser.urlencoded({ extended: false }));\r\n\r\nconst route = {\r\n  path: \"user\",\r\n  POST: ({ body }) => {\r\n    // `body` object contains all the value from the request body\r\n    return body; // This has a value of req.body\r\n  },\r\n};\r\n\r\napp.add([route]);\r\n```\r\n\r\n## MIDDLEWARES\r\n\r\nAs seen above how we used third party middlewares to parse the request body. We can also create our own middlewares. Although MayaJs supports all [ExpressJs Middlewares](https://expressjs.com/en/resources/middleware.html), we also can create a `MayaJsMiddleware` of our own. The context is where you can access `params, query and body` objects.\r\n\r\n```ts\r\nrouter.use((context, next, error) => {\r\n  // This `error` variable comes from the previous middleware\r\n  console.log(error);\r\n\r\n  // The `next` function will trigger the end of this callback function\r\n  // and execute the next middleware in the list\r\n  next(\"Error message or any value that you want to pass to the next middleware\");\r\n});\r\n```\r\n\r\n## CHILD ROUTES\r\n\r\nA child route is a route that appended to its parent route. It can be added using the `children` property from the route object.\r\n\r\n```ts\r\napp.add([\r\n  {\r\n    path: \"parent\", // This is the `parent` route\r\n    children: [\r\n      {\r\n        path: \"child\", // You can call this child route by `parent/child`\r\n        GET: () => \"This is from a child route\",\r\n      },\r\n    ],\r\n  },\r\n]);\r\n```\r\n\r\n```\r\nNOTE: A `child` route can also have its own `children`.\r\n```\r\n\r\n```ts\r\napp.add([\r\n  {\r\n    path: \"parent\", // This is the `parent` route\r\n    GET: () => \"This is a parent route\",\r\n    children: [\r\n      {\r\n        path: \"child\", // You can call this child route by `users/child`\r\n        GET: () => \"This is a child route\",\r\n        children: [\r\n          {\r\n            path: \"grandchild\", // You can call this child route by `parent/child/grandchild`\r\n            GET: () => \"This is a grandchild route\",\r\n          },\r\n        ],\r\n      },\r\n    ],\r\n  },\r\n]);\r\n```\r\n\r\n## CONTROLLER\r\n\r\nA controller is a class that act as a replacement for the route method objects. It can be used to make your code more modular and manageable when your code base get bigger.\r\n\r\n```ts\r\nclass UsersController extends Controller {\r\n  GET() {\r\n    return \"Hello form UsersController\";\r\n  }\r\n\r\n  // You can also add additional route method like this\r\n  POST() {\r\n    // ...\r\n  }\r\n\r\n  // Other routes available are PUT, PATCH, DELETE and OPTIONS\r\n}\r\n\r\napp.add([\r\n  {\r\n    path: \"user\",\r\n    controller: UsersController,\r\n  },\r\n]);\r\n```\r\n\r\nIf you want to add middleware a middleware to a specific method you can add the `middleware` property in a controller.\r\n\r\n```ts\r\nclass UsersController extends Controller {\r\n  middleware = {\r\n    GET: [middleware], // This middleware will be added to the `GET` method below\r\n  };\r\n\r\n  GET() {\r\n    //  ...\r\n  }\r\n}\r\n```\r\n\r\n```\r\nNOTE: A controller has no `children` property\r\n```\r\n\r\n## SERVICES\r\n\r\nA service is an injectable class that can be used inside of a controller or another service.\r\n\r\n```ts\r\nexport class UsersServices extends Services {\r\n  // Every function inside the service can be accessed by the class its injected\r\n  // All public properties are also accessible\r\n  // A service is instatiated once and making it a singleton\r\n\r\n  add() {\r\n    // ...\r\n  }\r\n}\r\n\r\nclass UsersController extends Controller {\r\n  constructor(userServices: UsersServices) {\r\n    super();\r\n  }\r\n\r\n  addUser() {\r\n    // This `add` function coming from the `UsersService`.\r\n    // It is accessible on this controller via dependency injection.\r\n    // MayaJs automatically instantiated it and created it singleton instance.\r\n    this.userServices.add();\r\n  }\r\n}\r\n```\r\n\r\n## MODULE\r\n\r\nA module is a like a container of routes, controller and services that act on its own. This will allow your code to modular and shareable accross all routes.\r\n\r\n```ts\r\nclass UsersModule extends MayaJsModule {\r\n  // List of `module` or `services` that this module will use for its controllers\r\n  imports = [];\r\n  // List of controllers that this module will use\r\n  declarations = [];\r\n  // List of services that can be use inside this module\r\n  providers = [];\r\n  // List of services that this module will exports that can be used by other modules\r\n  exports = [];\r\n  // List of dependencies that will be injected to this module\r\n  dependencies = [];\r\n}\r\n```\r\n\r\nAs you can see when we create a module we dont have any way to add routes on it. Below is an example of implementation of how to add a `RouterModule` for this module to add routes.\r\n\r\n```ts\r\nimport { UsersController, UsersIdController } from \"./controller\";\r\nimport { RouterModule } from \"@mayajs/router\";\r\nimport { UsersServices } from \"./services\";\r\n\r\n// Define the routes\r\nconst routes = [\r\n  {\r\n    path: \"/\",\r\n    controller: UsersController,\r\n  },\r\n  {\r\n    path: \":id\",\r\n    controller: UsersIdController,\r\n  },\r\n];\r\n\r\nexport class UsersModule extends MayaJsModule {\r\n  // User `RouterModule.forRoot` to inject the routes\r\n  imports = [RouterModule.forRoot(routes)];\r\n  // Declare the controllers that will be used inside the routes\r\n  declarations = [UsersIdController, UsersController];\r\n}\r\n```\r\n\r\n## CUSTOM MODULE\r\n\r\nUnlike the common mayajs module, custom modules provide other functionality aside from managing your controllers. One example of this the `RouterModule` that is reponsible for adding routes to your module. A key concept of a custom module is it has an `invoke` and `forRoot` function that provides additional functionalities.\r\n\r\n```ts\r\nexport class UsersModule extends CustomModule {\r\n  invoke() {\r\n    // This function will run after an instance of this module is created\r\n    // But the providers will stay singleton on each instance\r\n  }\r\n\r\n  static forRoot(options: any) {\r\n    return {\r\n      module: UsersModule, // Returns the current module reference\r\n      providers: [], // List of providers that this module will use on its controllers\r\n    };\r\n  }\r\n}\r\n```\r\n\r\nNow we know how to create a module but how we can call it on our routes. We are now introducing to `loadChildren` property of our route object. MayaJs will automatically resolve the module asynchronously when the path is added on the route list.\r\n\r\n```ts\r\nimport maya from \"@mayajs/router\";\r\nimport http from \"http\";\r\n\r\nconst app = maya();\r\n\r\napp.add([\r\n  {\r\n    path: \"users\",\r\n    // We are using dynamic importing so we don't need it to manually import the module in the file\r\n    // MayaJs will resolve the module asynchronously\r\n    loadChildren: () => import(\"./users.module\").then((m) => m.UsersModule),\r\n  },\r\n]);\r\n```\r\n\r\n## Collaborating\r\n\r\nSee collaborating guides [here.](https://github.com/mayajs/maya/edit/master/COLLABORATOR_GUIDE.md)\r\n\r\n## People\r\n\r\nAuthor and maintainer [Mac Ignacio](https://github.com/macign)\r\n\r\n## License\r\n\r\n[MIT](https://github.com/mayajs/router/blob/develop/LICENSE)\r\n","readmeFilename":"README.md","gitHead":"053b42c9372bec6250b1216d4ec8d3961a032d3a","_id":"@mayajs/router@0.6.0-rc","_nodeVersion":"16.9.0","_npmVersion":"7.21.1","dist":{"integrity":"sha512-nKNv0Ss13lF7GDlHPYY0hKfGg68XsaTrRX4QdH7jvAiC+nJn5w1TRCzxDh4ZqmvWDVvH+1fY7N11GZN02msbuQ==","shasum":"32a4b71664e6e3b64bed37912fd2fa802828f263","tarball":"https://registry.npmjs.org/@mayajs/router/-/router-0.6.0-rc.tgz","fileCount":37,"unpackedSize":70376,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhyIG5CRA9TVsSAnZWagAA9BQP/2fYaJNJ/fbkNLd+x/ja\n2gQ6lJBm+ezGGFc1Sx75w0p2nz70u8GSb0Vodv38/HLYYsOICDR++puc4nqK\n6N8DRx5vrJ1D1M/wTdNKHBwAhBz7C4RWMAeoVWKXHzvFJgURdwsDiO7RFfnL\nUsUFfkbz7aFvFkqxMvjP8gGUuVaWMU3YPA2R8V2Bq0BZIDciJAkAHNb6c6F3\n7cRbkxFnLgqMiRJmZx2BkA8X1/hfkQfGnE41Em4L3Kzt+mguNRiPqhakHHGQ\nkhTt/8q/RkHs4whnpmhEaDJF2qmLXo1E0E1M9ZakxXiYb8i/60/LtZx+CdUk\nMfVie74HOdChmXTIIdLpqCSz6JOJOntJW2oYHupB2idkumZZC+9tKUeGW/M9\nc91ZTwLgXUuwtfrNQcix+ahKfYVIUeciVmOE0BmagYD4n5E+k8Kj6sDW5By/\nb7so/m+jFlKDb0hFsy0X1DgW0Eext0oQ1MUoJURbjr+u+WCwJBAMxFhU+iKu\nFm2kLCj48bKD5/FQrvyLsGzwdG4gF8Zp8Cenk9EcTgSEfl3t9e4ttHvVQTSD\nw9mwulKE/1vWzEzM9ziTMRfIEkmxmVwPwoY5MryrBWIUgriq6Zsx0VkKUq2p\nS4HrUp6MhAdfDq5PFhMeP2TI9L8R3CPyKuN20k/0PW2GvXGo4uanlc+byigb\nOeOJ\r\n=+cBl\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC9Ej2wECFRO7P8+X8ix+1Yws7abjuMCmezdr0QzC80QAIhALkMSjXFSEHEuGyeQsH4CY0QdgOilH7okxozVtxZfUun"}]},"_npmUser":{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"},"directories":{},"maintainers":[{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/router_0.6.0-rc_1640530360933_0.5381455249543852"},"_hasShrinkwrap":false},"0.6.0-rc2":{"name":"@mayajs/router","version":"0.6.0-rc2","description":"Simple NodeJS routing library created using Typescript","main":"index.js","scripts":{"clean":"rimraf interface && rimraf index.js && rimraf index.d.ts && rimraf utils && rimraf router && rimraf lib && rimraf class && rimraf exceptions && rimraf types","postpack":"npm run clean && node ./scripts/restore-package.js"},"keywords":["nodejs","server","router","typescript","library","REST","API","mayajs"],"author":{"name":"Mark Anthony C. Ignacio"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/mayajs/router.git"},"bugs":{"url":"https://github.com/mayajs/router/issues"},"homepage":"https://github.com/mayajs/router#readme","engines":{"node":">= 0.10.0"},"readme":"<p align=\"center\"><img src=\"https://github.com/mayajs/maya/blob/master/maya.svg\" ></p>\r\n<h1 align=\"center\">MayaJS Router</h1>\r\n<p align=\"center\">\r\n  <a href=\"https://www.npmjs.com/package/@mayajs/router\"><img src=\"https://img.shields.io/npm/v/@mayajs/router.svg?style=for-the-badge&logo=appveyor\" alt=\"Version\"></a>\r\n  <a href=\"https://www.npmjs.com/package/@mayajs/router\"><img src=\"https://img.shields.io/npm/dm/@mayajs/router.svg?style=for-the-badge&logo=appveyor\" alt=\"Downloads\"></a>\r\n  <a href=\"https://www.npmjs.com/package/@mayajs/router\"><img src=\"https://img.shields.io/npm/l/@mayajs/router?style=for-the-badge&logo=appveyor\" alt=\"License\"></a>\r\n  <a href=\"https://github.com/microsoft/typescript-tslint-plugin\"><img src=\"https://img.shields.io/badge/code%20style-standard-blue.svg?style=for-the-badge&logo=appveyor\" alt=\"Code Style\"></a>\r\n</p>\r\n<h2 align=\"center\">Lightweight, simple and fast NodeJS Router developed using Typescript.</h2>\r\n\r\n## Motivation\r\n\r\nWe develop this library to be used as the main router for [MayaJS](https://github.com/mayajs/maya#readme) RESTful API framework. As much as possible we want to have a full control of\r\nthe libraries we used in our main projects for maintainability and ease of transition for future updates.\r\n\r\n## Roadmap\r\n\r\nYou can see the detailed roadmap of the project [here.](https://github.com/mayajs/router/blob/master/ROADMAP.md)\r\n\r\n## Suggestions\r\n\r\nFor suggestions and features you want to see in the future you can visit our [issues section.](https://github.com/mayajs/router/issues)\r\n\r\n## Getting started\r\n\r\nBefore installing this package make sure to download and install Node.js 10 or higher.\r\n\r\n### Setup Node\r\n\r\nTo check your node version\r\n\r\n```shell\r\nnpm -v\r\n```\r\n\r\nFor new project kindly initialize npm using the command below or see documentation [here](https://docs.npmjs.com/creating-a-package-json-file).\r\n\r\n```shell\r\nnpm init\r\n```\r\n\r\n### Setup Typescript\r\n\r\nInstall typescript and typescript watcher\r\n\r\n```shell\r\nnpm i typescript ts-node-dev -D\r\n```\r\n\r\nInitialize typescript\r\n\r\n```shell\r\ntsc --init\r\n```\r\n\r\n### Setup Router\r\n\r\nInstall mayajs router\r\n\r\n```shell\r\nnpm i @mayajs/router\r\n```\r\n\r\nAdd `start` script on your `package.json`\r\n\r\n```js\r\n\"scripts\": {\r\n  \"start\": \"tsnd src\"\r\n}\r\n```\r\n\r\n## Features\r\n\r\n- Simple and easy\r\n- Lightweight library\r\n- Built with TypeScript\r\n- No third party library\r\n- Modules for shareable code\r\n- Dependency Injection and IOC\r\n- Fast execution with route caching\r\n- Supports beginners to advanced developers\r\n- `Function` and `Class` based coding style\r\n- Supports third party middlewares like `ExpressJS`\r\n\r\n## Quick Start\r\n\r\nThe easiest way to get started is to create a simple route. Create a `src` folder inside your project folder. Inside the `src` folder create an `index.ts` file. Copy the code below into `index.ts` file.\r\n\r\n```ts\r\nimport maya from \"@mayajs/router\";\r\nimport http from \"http\";\r\n\r\nconst PORT = 3000;\r\nconst app = maya();\r\n\r\napp.add([\r\n  {\r\n    path: \"/\",\r\n    GET: () => \"Hello, World\",\r\n  },\r\n]);\r\n\r\nhttp.createServer(app).listen(PORT, () => console.log(`Server listening on port ${PORT}.`));\r\n```\r\n\r\n## RUN\r\n\r\nTo run your mayajs project open a terminal inside your current project and run the command below.\r\n\r\n```shell\r\nnpm start\r\n```\r\n\r\n## ROUTE\r\n\r\nDefining routes in MayaJs is like creating a JSON object.\r\n\r\n```ts\r\nconst user = {\r\n  path: \"user\",\r\n  GET: () => {\r\n    //  ...\r\n  },\r\n  POST: () => {\r\n    //  ...\r\n  },\r\n  PUT: () => {\r\n    //  ...\r\n  },\r\n  PATCH: () => {\r\n    //  ...\r\n  },\r\n  DELETE: () => {\r\n    //  ...\r\n  },\r\n  OPTIONS: () => {\r\n    //  ...\r\n  },\r\n};\r\n```\r\n\r\nAs seen above each method name has a `callback` function. Mayajs will set the correct `content-type` based on what the method callback will return.\r\n\r\n```ts\r\nconst route = {\r\n  path: \"user\",\r\n  GET: () => {\r\n    // This will return `undefined`\r\n    // This will have a content-type of \"text/plain\"\r\n  },\r\n  POST: () => {\r\n    return \"Hello\"; // This will have a content-type of \"text/plain\"\r\n  },\r\n  PUT: () => {\r\n    return { message: \"Hello\" }; // This will have a content-type of \"application/json\"\r\n  },\r\n  PATCH: () => {\r\n    return \"<h1>Hello</h1>\"; // This will have a content-type of \"text/html\"\r\n  },\r\n};\r\n```\r\n\r\nIncase you need to use a middleware for an specific route method you need to create a route object instead.\r\n\r\n```ts\r\nconst route = {\r\n  path: \"user\",\r\n  GET: {\r\n    middlewares: [middleware],\r\n    callback: () => {\r\n      // ...\r\n    },\r\n  },\r\n};\r\n```\r\n\r\n## PARAMS\r\n\r\nMayaJs passes a context object on each route method. You can acces the route params by destructuring the context object on the callback method.\r\n\r\n```ts\r\nconst route = {\r\n  path: \"user/:id\",\r\n  GET: ({ params }) => {\r\n    // `params` object contains the value of `id` define on the path above e.g. `user/hello`\r\n    return params.id; // This has a value of \"hello\"\r\n  },\r\n};\r\n```\r\n\r\n## QUERY STRING\r\n\r\nYou can also access the query string using the context object provided by MayaJs on your route method callback function.\r\n\r\n```ts\r\nconst route = {\r\n  path: \"user\",\r\n  GET: ({ query }) => {\r\n    // `query` object contains all the value on your query string e.g. `user?id=1`\r\n    return query.id; // This has a value of 1\r\n  },\r\n};\r\n```\r\n\r\n## BODY\r\n\r\nRequest body is also accessible in the context but you need a middleware before you can actually uses. There is a popular middleware called [body-parser](https://www.npmjs.com/package/body-parser) that we can use to achieve this.\r\n\r\n```ts\r\nimport maya from \"@mayajs/router\";\r\n// Third party middleware you need to install\r\nimport bodyParser from \"body-parser\";\r\n\r\nconst app = maya();\r\n\r\n// Initialize body parser for mayajs to use it internally\r\napp.use(bodyParser.json());\r\napp.use(bodyParser.urlencoded({ extended: false }));\r\n\r\nconst route = {\r\n  path: \"user\",\r\n  POST: ({ body }) => {\r\n    // `body` object contains all the value from the request body\r\n    return body; // This has a value of req.body\r\n  },\r\n};\r\n\r\napp.add([route]);\r\n```\r\n\r\n## MIDDLEWARES\r\n\r\nAs seen above how we used third party middlewares to parse the request body. We can also create our own middlewares. Although MayaJs supports all [ExpressJs Middlewares](https://expressjs.com/en/resources/middleware.html), we also can create a `MayaJsMiddleware` of our own. The context is where you can access `params, query and body` objects.\r\n\r\n```ts\r\nrouter.use((context, next, error) => {\r\n  // This `error` variable comes from the previous middleware\r\n  console.log(error);\r\n\r\n  // The `next` function will trigger the end of this callback function\r\n  // and execute the next middleware in the list\r\n  next(\"Error message or any value that you want to pass to the next middleware\");\r\n});\r\n```\r\n\r\n## CHILD ROUTES\r\n\r\nA child route is a route that appended to its parent route. It can be added using the `children` property from the route object.\r\n\r\n```ts\r\napp.add([\r\n  {\r\n    path: \"parent\", // This is the `parent` route\r\n    children: [\r\n      {\r\n        path: \"child\", // You can call this child route by `parent/child`\r\n        GET: () => \"This is from a child route\",\r\n      },\r\n    ],\r\n  },\r\n]);\r\n```\r\n\r\n```\r\nNOTE: A `child` route can also have its own `children`.\r\n```\r\n\r\n```ts\r\napp.add([\r\n  {\r\n    path: \"parent\", // This is the `parent` route\r\n    GET: () => \"This is a parent route\",\r\n    children: [\r\n      {\r\n        path: \"child\", // You can call this child route by `users/child`\r\n        GET: () => \"This is a child route\",\r\n        children: [\r\n          {\r\n            path: \"grandchild\", // You can call this child route by `parent/child/grandchild`\r\n            GET: () => \"This is a grandchild route\",\r\n          },\r\n        ],\r\n      },\r\n    ],\r\n  },\r\n]);\r\n```\r\n\r\n## CONTROLLER\r\n\r\nA controller is a class that act as a replacement for the route method objects. It can be used to make your code more modular and manageable when your code base get bigger.\r\n\r\n```ts\r\nclass UsersController extends Controller {\r\n  GET() {\r\n    return \"Hello form UsersController\";\r\n  }\r\n\r\n  // You can also add additional route method like this\r\n  POST() {\r\n    // ...\r\n  }\r\n\r\n  // Other routes available are PUT, PATCH, DELETE and OPTIONS\r\n}\r\n\r\napp.add([\r\n  {\r\n    path: \"user\",\r\n    controller: UsersController,\r\n  },\r\n]);\r\n```\r\n\r\nIf you want to add middleware a middleware to a specific method you can add the `middleware` property in a controller.\r\n\r\n```ts\r\nclass UsersController extends Controller {\r\n  middleware = {\r\n    GET: [middleware], // This middleware will be added to the `GET` method below\r\n  };\r\n\r\n  GET() {\r\n    //  ...\r\n  }\r\n}\r\n```\r\n\r\n```\r\nNOTE: A controller has no `children` property\r\n```\r\n\r\n## SERVICES\r\n\r\nA service is an injectable class that can be used inside of a controller or another service.\r\n\r\n```ts\r\nexport class UsersServices extends Services {\r\n  // Every function inside the service can be accessed by the class its injected\r\n  // All public properties are also accessible\r\n  // A service is instatiated once and making it a singleton\r\n\r\n  add() {\r\n    // ...\r\n  }\r\n}\r\n\r\nclass UsersController extends Controller {\r\n  constructor(userServices: UsersServices) {\r\n    super();\r\n  }\r\n\r\n  addUser() {\r\n    // This `add` function coming from the `UsersService`.\r\n    // It is accessible on this controller via dependency injection.\r\n    // MayaJs automatically instantiated it and created it singleton instance.\r\n    this.userServices.add();\r\n  }\r\n}\r\n```\r\n\r\n## MODULE\r\n\r\nA module is a like a container of routes, controller and services that act on its own. This will allow your code to modular and shareable accross all routes.\r\n\r\n```ts\r\nclass UsersModule extends MayaJsModule {\r\n  // List of `module` or `services` that this module will use for its controllers\r\n  imports = [];\r\n  // List of controllers that this module will use\r\n  declarations = [];\r\n  // List of services that can be use inside this module\r\n  providers = [];\r\n  // List of services that this module will exports that can be used by other modules\r\n  exports = [];\r\n  // List of dependencies that will be injected to this module\r\n  dependencies = [];\r\n}\r\n```\r\n\r\nAs you can see when we create a module we dont have any way to add routes on it. Below is an example of implementation of how to add a `RouterModule` for this module to add routes.\r\n\r\n```ts\r\nimport { UsersController, UsersIdController } from \"./controller\";\r\nimport { RouterModule } from \"@mayajs/router\";\r\nimport { UsersServices } from \"./services\";\r\n\r\n// Define the routes\r\nconst routes = [\r\n  {\r\n    path: \"/\",\r\n    controller: UsersController,\r\n  },\r\n  {\r\n    path: \":id\",\r\n    controller: UsersIdController,\r\n  },\r\n];\r\n\r\nexport class UsersModule extends MayaJsModule {\r\n  // User `RouterModule.forRoot` to inject the routes\r\n  imports = [RouterModule.forRoot(routes)];\r\n  // Declare the controllers that will be used inside the routes\r\n  declarations = [UsersIdController, UsersController];\r\n}\r\n```\r\n\r\n## CUSTOM MODULE\r\n\r\nUnlike the common mayajs module, custom modules provide other functionality aside from managing your controllers. One example of this the `RouterModule` that is reponsible for adding routes to your module. A key concept of a custom module is it has an `invoke` and `forRoot` function that provides additional functionalities.\r\n\r\n```ts\r\nexport class UsersModule extends CustomModule {\r\n  invoke() {\r\n    // This function will run after an instance of this module is created\r\n    // But the providers will stay singleton on each instance\r\n  }\r\n\r\n  static forRoot(options: any) {\r\n    return {\r\n      module: UsersModule, // Returns the current module reference\r\n      providers: [], // List of providers that this module will use on its controllers\r\n    };\r\n  }\r\n}\r\n```\r\n\r\nNow we know how to create a module but how we can call it on our routes. We are now introducing to `loadChildren` property of our route object. MayaJs will automatically resolve the module asynchronously when the path is added on the route list.\r\n\r\n```ts\r\nimport maya from \"@mayajs/router\";\r\nimport http from \"http\";\r\n\r\nconst app = maya();\r\n\r\napp.add([\r\n  {\r\n    path: \"users\",\r\n    // We are using dynamic importing so we don't need it to manually import the module in the file\r\n    // MayaJs will resolve the module asynchronously\r\n    loadChildren: () => import(\"./users.module\").then((m) => m.UsersModule),\r\n  },\r\n]);\r\n```\r\n\r\n## Collaborating\r\n\r\nSee collaborating guides [here.](https://github.com/mayajs/maya/edit/master/COLLABORATOR_GUIDE.md)\r\n\r\n## People\r\n\r\nAuthor and maintainer [Mac Ignacio](https://github.com/macign)\r\n\r\n## License\r\n\r\n[MIT](https://github.com/mayajs/router/blob/develop/LICENSE)\r\n","readmeFilename":"README.md","gitHead":"3ba8e46fc69cbb2f8a01ae70d4e4f4eb90e7446d","_id":"@mayajs/router@0.6.0-rc2","_nodeVersion":"16.9.0","_npmVersion":"7.21.1","dist":{"integrity":"sha512-MH5/WOH3yI2GmItkJ/cOMtpj2keYsoyV/g3D2npIQvLQK8hwwq73WOmYy0Kw/LmaY5JklrW5GTiM34zlrRDk/A==","shasum":"64a1bb809e115a7601e9188e2c01f1a37b64689f","tarball":"https://registry.npmjs.org/@mayajs/router/-/router-0.6.0-rc2.tgz","fileCount":37,"unpackedSize":70657,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhyRE5CRA9TVsSAnZWagAA9bAP/3jcZbQRDIbvtRTKQp5N\nzk4xYTbMDYNCVJYg09QJ689rgxnlFL3wyiB/U8svlXi2AOMxOs++xdAEJDlM\nmuBI2oDNjZxKsO6z9k9OD6q0dT1JQQP/n6KCy8pcroNSU78UXVQLmyoUTYCg\nsKYVHwfNLPabAZG+ze3m3tC/BWfeokXMIuKGsDyKoT88X5jQWiUJKMgH2s9W\nd3uaLu9v8O8BSELzEqdID9/A6eK14WLl+ulor2tvPU00MY0++fo3fnbfGWB5\nS4cObHW9OjTpEGHpeIWBOduPXbq5m0ig+hIkasotuh5SG7zMaAhKoAv/VuYN\n491WKf+jLC8CKckTRXJV2rSVdJh4idu9bX+nsL008J90wD3nqt4HQom87BoO\n89NdDlvtzhwF4tRfoQOSeOMPlBPKI4RmC+6UQCU7MiMrQHompYTe0YGZl3xn\nlwsmYVKRbsLfJNXfdER2rJIpaDijgZMrDfuxcZcN8npI3ZEfOx+gPNjuVDLs\ntDE2I7i4AZCOgHhVv/+DxzC7IJHgGKDQ6LzjI0Fa51wZFnYIH1aNFST6NfK6\ntDM3UR93H0T0qMQR5JHUhOVGl0f3RrTEehpurujbS8zwSS2Y5YjoGoiu7pDt\nYVzp5Q5JGJBNt5BoTeKcMTr5P+2SzQy04dQodarXISVFGYwfIA8SHBVjol7/\nMzaB\r\n=h7vM\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDHhhghoNKFQoHJzQHTuxH3PLbnpiAgYF3L7m6IB1xZpAIgQR3eE6YcQ/jUjtOdLulFh4FXPf4fy/QKuiMMa4xS2XE="}]},"_npmUser":{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"},"directories":{},"maintainers":[{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/router_0.6.0-rc2_1640567097255_0.2170518889059525"},"_hasShrinkwrap":false},"0.6.0":{"name":"@mayajs/router","version":"0.6.0","description":"Simple NodeJS routing library created using Typescript","main":"index.js","scripts":{"clean":"rimraf interface && rimraf index.js && rimraf index.d.ts && rimraf utils && rimraf router && rimraf lib && rimraf class && rimraf exceptions && rimraf types","postpack":"npm run clean && node ./scripts/restore-package.js"},"keywords":["nodejs","server","router","typescript","library","REST","API","mayajs"],"author":{"name":"Mark Anthony C. Ignacio"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/mayajs/router.git"},"bugs":{"url":"https://github.com/mayajs/router/issues"},"homepage":"https://github.com/mayajs/router#readme","engines":{"node":">= 0.10.0"},"gitHead":"b53fbd0d55e1f8ccc7b5525e4a1a08ff79a6ad17","_id":"@mayajs/router@0.6.0","_nodeVersion":"16.9.0","_npmVersion":"7.21.1","dist":{"integrity":"sha512-hLR7xig+0K75yPWhgvZm8pHQK53Ye/SlZGis9j+OGLvjNMjtm/oxnzD9zNjOSWEJa3hn/sRs4yFcJZCfd/WLFg==","shasum":"3dc96693ae2c9f06b7e77cd25c5c8b11c5536297","tarball":"https://registry.npmjs.org/@mayajs/router/-/router-0.6.0.tgz","fileCount":37,"unpackedSize":70653,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhyRecCRA9TVsSAnZWagAAWPAP/i8waJZXdKvouxnLDvwl\nK4TdH7nxxKoGGKVXv+j4aMok0s4SO7Liyb27oeMPYDyjUzJgdaD4cCqhVNKh\noFQNPqc1PIx8o49dJn4QtR2viyeVjJUmX9BqpJUS7St3j4OmlP8TbW4vKl+8\nJAodOqe4s0Rf7jbXdT2/GdkbyQ8da+Azakxd3rs7vX9fRDTiUHrmzRm0Ussj\nqz9iKGkXOJbN+XLOTo8hXNraLR2Yti+YM79GK1oJ/KkAt4VNbyXWuTZBSqbF\nyYn5LdcFZvPOmeu/W6ix6FWJFJSo5LAL7ovJu9AU+N6V56UbH9wwY9MlryXM\nVQYXccnkZRyZbX7zB0NCs35c37N86Twwww1Kb3yyanJTkja0UQttuFc9Jjqz\nlO1oQc9S7T3nPtilaCoGWkaQF/yZEFYOv92MRRLV1P3GVohxm6V4p9fqy+JR\n/PSgl/AlFCbky159jXxdgcf7AAYjeJDuH7pH2vWjyiHc4+AMrMT18DCCySun\nmEyDPZtTKUQFTctvv/0n+3kATfy4SSY/ybPHqEh5BbOprcf3YI2NuxSm52B8\nKBYQh/ust4NnuQR2R7/2nMF2LttTumZCi6+4ryM5nL5kgX6kZUKMjbnld8cI\n+sQbWPEhZ9YjD3c/FMlFUVvyW9oR4e1pkTz1V550p+Xfj5NtI4Pd5P1JOwlp\n215K\r\n=j5a9\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCN23bWGM8XPLKpogjI+Wu/cZTe3eHYtW1KHJvjeAPrFwIgQkVm32mrRxs5F/ZULDUGj+ypImY8Tcqqz/nSqFUwAGE="}]},"_npmUser":{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"},"directories":{},"maintainers":[{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/router_0.6.0_1640568731987_0.20788900065638827"},"_hasShrinkwrap":false},"0.6.1":{"name":"@mayajs/router","version":"0.6.1","description":"Simple NodeJS routing library created using Typescript","main":"lib/index.js","scripts":{"clean":"rimraf interface && rimraf index.js && rimraf index.d.ts && rimraf utils && rimraf router && rimraf lib && rimraf class && rimraf exceptions && rimraf types","tgz":"rimraf *.tgz","package":"node ./scripts/clean-package.js","start":"npm run clean && npm run tgz && tsc -w","prepack":"npm run clean && npm run package && tsc --outDir .","postpublish":"node ./scripts/restore-package.js"},"keywords":["nodejs","server","router","typescript","library","REST","API","mayajs"],"author":{"name":"Mark Anthony C. Ignacio"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/mayajs/router.git"},"bugs":{"url":"https://github.com/mayajs/router/issues"},"homepage":"https://github.com/mayajs/router#readme","devDependencies":{"@types/node":"^13.11.0","jest":"^25.2.7","rimraf":"^3.0.2","ts-node":"^8.8.2","typescript":"^3.8.3"},"engines":{"node":">= 0.10.0"},"gitHead":"67347e24eb09e6de3e5e113a091e9e691c8289c1","_id":"@mayajs/router@0.6.1","_nodeVersion":"14.18.2","_npmVersion":"6.14.15","dist":{"integrity":"sha512-csHth1CyHcAOKaz1yfIyWCddH5GDPStgEKVgsol/mGEyaGoINu0ysx93//y/D42f+7tHpB4YElQsmdG2z+5Ccg==","shasum":"2634877872a1d3f466619c868c024fba85aa4b97","tarball":"https://registry.npmjs.org/@mayajs/router/-/router-0.6.1.tgz","fileCount":37,"unpackedSize":70649,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhy+qQCRA9TVsSAnZWagAAA7sP/2Le1f3Iqu5cXTlfyv50\ncCCSiTAoosqS0l+FUX4vkx1OYHY5p84zO70AwhsUFLcZhRx7AU3WZs7XUA2W\nmLDDUYHhcEPnFRdmI3N9ZlchJau8WRSBIXq2QqP+HCOgcKBcvw4ZMicSZdsg\nZ2SsMhX0/XBUBUAkddyRklPMstpPRvFnef9BrcElsDk5HRvjl9ifId+XADzS\nfO0GHLSwZvmwURr8NR6xxf2WrkGersJM36g9GqFv9wDqDebDoZJ3EugQSy7J\nojuHko7imJnIqt72EBJu6Qw+qfmb1w1lLk3Btc8UWl/lcr8EdeCmuINlx2om\ncoKT/U/nK8LFA7emz7ZNLj74IpUJ5uIoyoWikUzcHe7ehvgqoQjJqgS/z8wB\ncChtbG2Kq5AJFJ/oN9oVBh760molAL+fWSj+Q13JJchPEPpWwUoLovJ8v09M\nzppLeOMqQPiE4JwWLHepv63XfrudHR7lgcnrdY4z7N5UGpW5aOU7uT5AdeGc\nHromHDvjkP1ICkRwCF28GELeUzNA0ZRhfFCV+kbNWLa467sims2PTFNrgbqX\npL5/IQ05gnNDixS/Dxhp8wxloaCVYptzFsnDkMs2IDtZTcP9OkyFpECTYjWO\nWPH+b5wZnTAbGQWvVByNVg07C1rPLSvluk48TZeZH2YvdhljIPhfzGA7EfNW\n3675\r\n=2Y0z\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCUZ7XjlchXjvl7EOlftEp5br3wqPNQAq5eIekdOGFIVgIhAO4vv+mBRQVeHIB5NMpX9mcM8RghSiPIn8jzBY1s1A8P"}]},"_npmUser":{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"},"directories":{},"maintainers":[{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/router_0.6.1_1640753808749_0.9965771706276412"},"_hasShrinkwrap":false},"0.6.2":{"name":"@mayajs/router","version":"0.6.2","description":"Simple NodeJS routing library created using Typescript","main":"lib/index.js","scripts":{"clean":"rimraf interface && rimraf index.js && rimraf index.d.ts && rimraf utils && rimraf router && rimraf lib && rimraf class && rimraf exceptions && rimraf types","tgz":"rimraf *.tgz","package":"node ./scripts/clean-package.js","start":"npm run clean && npm run tgz && tsc -w","prepack":"npm run clean && npm run package && tsc --outDir ."},"keywords":["nodejs","server","router","typescript","library","REST","API","mayajs"],"author":{"name":"Mark Anthony C. Ignacio"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/mayajs/router.git"},"bugs":{"url":"https://github.com/mayajs/router/issues"},"homepage":"https://github.com/mayajs/router#readme","devDependencies":{"@types/node":"^13.11.0","jest":"^25.2.7","rimraf":"^3.0.2","ts-node":"^8.8.2","typescript":"^3.8.3"},"engines":{"node":">= 0.10.0"},"gitHead":"1e18904d2e75f18cd05c72bd7ec0f853297a6474","_id":"@mayajs/router@0.6.2","_nodeVersion":"14.18.2","_npmVersion":"6.14.15","dist":{"integrity":"sha512-UVQ5xPSv4dld55iy1zCrBCHZ6iKVvuz4SCjkuk/TNWS8Q8PkYmd5G2lNTcdTq/RB3HKkoDtm0rAfEc43iKj6pw==","shasum":"c22440afd5d54e258a15c800d6cbc675cc7a7b34","tarball":"https://registry.npmjs.org/@mayajs/router/-/router-0.6.2.tgz","fileCount":37,"unpackedSize":70915,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhzGtjCRA9TVsSAnZWagAALp8P+gJZAAtzPYFUcxvR1yYS\nXj0Dok/NTL/bBnK/gOwM1jZSWWVdkbofLYiSjPL2wWCOGcucYv9LyOsTFb5X\neb0LXs70XUwDqyKhyZTgPxsZExeDCev6h1ExwxnZsnzuvHqfpxj8O1NGB69G\ncgjfKs7CTnzvzaFe43JgvohE59FB9xMlNUfE7+C63aNhccpAC7Hy5knbRLzr\n/V6S7sBK37mB36o35mCeEZ/3hDb6R4Bq5v8UILsTyhftWAHM6QbqnSB4ipJu\nEOjh8dugThcThGjT+loNdLmfLKno6Vs58EJwEEgFLJsPh1C5G9sykp0t3ivi\nICXoAebyim5XoAlMP2tDbygI8TrbtKwDveLLNGFfuNLaYnLyvmpSy+uIQ7Wh\ncfzCrWlKfOLeb6412YmnUp2y3EPnOfzuaXwqyq95w+q7K/9EBui33BCdnmeL\nRjBwOLtEICZ726lVHIVvKlVGJ7JkhlrtZSywtpi3iXmAFsjbV6uDxVN31Qtw\n+YCkEEPo1Il50NXn1+8UTSv+7F76JhRYSUE4uBilJwQk1SJ3iICQvMaz2ujH\n/0B+wIxzPvHzLcxEwwdH77nxfeJNboMq7lGjo1uNaiKiTKpgKY2O2OpxdLmc\nbavZrMLyoGr9Rd9EgsgYTgnS4iRJlW+MlSPBXsJO/mzFhA+vwmhR4VasKtZV\nWBXX\r\n=R/Gn\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCN6HRtUToUJMNFhL6GT3vaLmpBoc4LPji+5z8oPj4BOgIhAPa24oWsTrRlZ/plYEbu9Lb0dqvr30L1O15VAkPKgSy4"}]},"_npmUser":{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"},"directories":{},"maintainers":[{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/router_0.6.2_1640786787017_0.33921153481453814"},"_hasShrinkwrap":false},"0.6.3":{"name":"@mayajs/router","version":"0.6.3","description":"Simple NodeJS routing library created using Typescript","main":"lib/index.js","scripts":{"clean":"rimraf interface && rimraf index.js && rimraf index.d.ts && rimraf utils && rimraf router && rimraf lib && rimraf class && rimraf exceptions && rimraf types","tgz":"rimraf *.tgz","package":"node ./scripts/clean-package.js","start":"npm run clean && npm run tgz && tsc -w","prepack":"npm run clean && npm run package && tsc --outDir ."},"keywords":["nodejs","server","router","typescript","library","REST","API","mayajs"],"author":{"name":"Mark Anthony C. Ignacio"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/mayajs/router.git"},"bugs":{"url":"https://github.com/mayajs/router/issues"},"homepage":"https://github.com/mayajs/router#readme","devDependencies":{"@types/node":"^13.11.0","jest":"^25.2.7","rimraf":"^3.0.2","ts-node":"^8.8.2","typescript":"^3.8.3"},"engines":{"node":">= 0.10.0"},"gitHead":"c6caae9ebbd8c574b2a283be9462de264e77699a","_id":"@mayajs/router@0.6.3","_nodeVersion":"14.18.2","_npmVersion":"6.14.15","dist":{"integrity":"sha512-hea51Lvscb34N5CHiZXXwaKom47p703NUPmDs87FQVdAdd+b2wksj/3XNgfKymnfY8qyId44r6p5OQtREDiWNQ==","shasum":"1eb9659a835da6f19d6e63de72612cc283d8576c","tarball":"https://registry.npmjs.org/@mayajs/router/-/router-0.6.3.tgz","fileCount":37,"unpackedSize":71702,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhzdxnCRA9TVsSAnZWagAAMHIP/jC5dxKqNSNAsc3ZIgpV\n0mYQH6AdO0jLg2zXW82MI3nK+n5nLZ09OUPfXyr4yBx4nU6RRjVV6gq/ux4n\nmRoXnTgOV/jRQ1MZwlVD92YRSbS+jX+jUg953kvg9NQozLMAwLbxXXkWIqld\nafiRDDfTA5ybS2iFde/B1DFir/GTqeHL889xA4BM08aewFvbldF7Rorywx0z\nstctRyCM3tY5K5SoGBkVzjL1ym7s9Dbsh7iUpWIxEQkn0A2ckxC8QmX70xtK\ng51T9RtivVfzeOwflA11XlCO6qM/9AI8ERkgH1yz2QL7j7YTk8/22On8SMM/\nVHiQm3sxEqMoLnxVK/sCGURk4DVPkkFXVCD2xo/aqBer+twgARjlb1qqUgNZ\n+2TuBnMnBA8g2vepo4Y921tUg9wGEOqhzzhLmDTwoEtr5W/V9EkefuSajohh\nkLmTEqk1v5FVF+TY4pliqo/kEYKxAF6IDcujS1iZ9zd9aGFuEplDMMhPUhnP\na5QXy7Ut1VbbL/xm8FjP3vFtDE0BF2gLZuMpVW+mt1W1Zyh6CcWf6PxF5V4E\nLG9BYdYvNn6pJxNXd2hrr1d7KPxEpyjU4D5tzejA/frGfb1G0bhSsH0/f2Wz\ntSRvzfT7OXs7hF8xtn6N1/hlFKmHnnWtjpwHTIaJd1zhW59Rjp/qzSLqcIxe\nWuIk\r\n=9Te0\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDV2D6x0cXcAyiBBlaOUHal6cU1RTB2HoK3XTRjdmYMjwIgYJnyGakpakstuUJ3T+9OUwWfO5WI+UZXS8glwUHbkgU="}]},"_npmUser":{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"},"directories":{},"maintainers":[{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/router_0.6.3_1640881255597_0.07020150541787418"},"_hasShrinkwrap":false},"0.6.4":{"name":"@mayajs/router","version":"0.6.4","description":"Simple NodeJS routing library created using Typescript","main":"lib/index.js","scripts":{"clean":"rimraf interface && rimraf index.js && rimraf index.d.ts && rimraf utils && rimraf router && rimraf lib && rimraf class && rimraf exceptions && rimraf types","tgz":"rimraf *.tgz","package":"node ./scripts/clean-package.js","start":"npm run clean && npm run tgz && tsc -w","prepack":"npm run clean && npm run package && tsc --outDir ."},"keywords":["nodejs","server","router","typescript","library","REST","API","mayajs"],"author":{"name":"Mark Anthony C. Ignacio"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/mayajs/router.git"},"bugs":{"url":"https://github.com/mayajs/router/issues"},"homepage":"https://github.com/mayajs/router#readme","devDependencies":{"@types/node":"^13.11.0","jest":"^25.2.7","rimraf":"^3.0.2","ts-node":"^8.8.2","typescript":"^3.8.3"},"engines":{"node":">= 0.10.0"},"gitHead":"dcf2eb152dbe7d74a45839fe7f6da3568afd227c","_id":"@mayajs/router@0.6.4","_nodeVersion":"14.18.2","_npmVersion":"6.14.15","dist":{"integrity":"sha512-zLHZXKmOrh0pEh71iV/MNmBMsfTzQ8nN2foVjib85JKpRvDhOxv8XihGgGAMbthJsdLpum7zkuTQ4BIK/LPCmQ==","shasum":"37f42079d49e7799f68065d7c9d4843e0a978112","tarball":"https://registry.npmjs.org/@mayajs/router/-/router-0.6.4.tgz","fileCount":37,"unpackedSize":71911,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhzpjjCRA9TVsSAnZWagAAHCUP/3W0RXHATXa5F/uh905u\nrxfTyUGNVjMEECJNXKQXh1fpVzHtcX/QPKf/MYbQGfaaqKjEYrOxn4MeRfnw\nuzaqllzpKB/eVahCNvNNO0d4VyulVgwabGLCDgmcGNrVqW4EM+HO7034c9Sz\nCdtB5aNyZADTwWOJcj4E2XLXq1hdLfTA/H2c3g8G4SWbdY2ZHyKpPiqvPN8+\n8vQKtj2zmGt7uEtdlzIxvb1jbz5u1iUDwVAacHT5f6lVRvNZw5DlSX6G7An4\nSrMjISLDEPo+zIGnIe+rHXDFfGqtd7Is37VaqxPV54GBG/+fux4AQpR5+tJ/\n5sqZ7dUAmbk39QqMc2S9DJWSboWSHS1GZLAvdK72uBXjR4ak0u95arTUsiRW\nrr7km9lxJt5GqkCDOZTsGvQD7s8ZKtTtyb18W0Ja89q31ZAAypP8S0/KVluA\nd/Ln9mfq04tY2v4PF1c0Bpl3ABTqxgVyT7eiI65Bj/y8bsy165FvO6UACwzo\njZiv/JmUjzOxiiagx7xPOA1YTKKFvz1BY8bDI9WZFdhi/W2yBK9h5KrKiZkW\nBybAipWc8yJCAQ9AELRxeXW8b/w3pEGsc1d8rwHRPCZFPeeRxBXMnAeaEloF\n3V5YFYymkRGONEhU7MHwi5bbbzCjgVfbY5m6e99RQTcqlWmV9dc+T5bqjF0O\nhpiJ\r\n=lVul\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCDRbCQIcTR8Geb9Yld5N2nRjP71KS2ACZ1IKtZTGY3ewIgO19NEcKkUkN9WsoJqU2jqRAcMkGr4YKqfSydnVegsmE="}]},"_npmUser":{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"},"directories":{},"maintainers":[{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/router_0.6.4_1640929507163_0.6214810492644847"},"_hasShrinkwrap":false},"0.6.5":{"name":"@mayajs/router","version":"0.6.5","description":"Simple NodeJS routing library created using Typescript","main":"lib/index.js","scripts":{"rimraf":"rimraf interface && rimraf index.js && rimraf index.d.ts && rimraf utils && rimraf router && rimraf lib && rimraf class && rimraf exceptions && rimraf types","clean":"npm run rimraf && npm run tgz","tgz":"rimraf *.tgz","start":"npm run clean && tsc -w","prepack":"npm run clean && tsc --outDir .","postpack":"npm run clean"},"keywords":["nodejs","server","router","typescript","library","REST","API","mayajs"],"author":{"name":"Mark Anthony C. Ignacio"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/mayajs/router.git"},"bugs":{"url":"https://github.com/mayajs/router/issues"},"homepage":"https://github.com/mayajs/router#readme","devDependencies":{"@types/node":"^13.11.0","jest":"^28.0.2","rimraf":"^3.0.2","ts-node":"^8.8.2","typescript":"^3.8.3"},"engines":{"node":">= 0.10.0"},"gitHead":"5a6a9e38e4decd73b3f4100b7f73e65279426b95","_id":"@mayajs/router@0.6.5","_nodeVersion":"14.19.0","_npmVersion":"6.14.16","dist":{"integrity":"sha512-LgOav/1lq7x2+EBvwQRWNbn4MEckGHhcxMbfBWNt9qAuAAO+5xxoFKvBwx3755oIO+Gah0bTCLU3LJCXPJgvdw==","shasum":"2c658fc535c907d34e3488917775958f89685b95","tarball":"https://registry.npmjs.org/@mayajs/router/-/router-0.6.5.tgz","fileCount":36,"unpackedSize":69605,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC+sIQdJ2YT28/Ok0GMRBSSEQBpc5w5GsZLsu+zikOEvAIhAPDkwkv7VaRZRJhbm6CZETJNXF1ySyUjQZHp51zie7xA"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiaWLdACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrNgQ/7Bg9Ho5tnPi7aFbcVyJ3n37bMf5g6+5lOCw06u4LyDtNTc7i5\r\nr26/d88vPp5uG8SlNQYe8dfOm0apnd+QKUUeG3we97TlcKH1mXGaPoNIBDIj\r\nVgy3f4xcLBtDVOh5ttcy/7eXWNhA8u6iS3GSbbZwYTKAwx4uSVbe+UTtGAfR\r\nPs5+Ef9Nsl7dk7YUayUif9GbNWuwiYFs9cnJKBjbm9+byrdUwXMIhD3X5pB3\r\nuo1s/J6FFLm+/bFcmKlrj2pi3GOmKd3xK2erQEhzVtQ+Qt7Qo6X9D1+WbypB\r\nyWB7MhVXCuibhkoMhaRtH2kNxuiw4dPFQxQ25iReNTuYXmV+VoNBQJW+gEru\r\n4yGiiUvaSxPd4saHyamYOqCwF53n0w+/bA7B91rIdsdP1nJaq+ToiiQT8j6L\r\nuFM3tzyKkXI925YbK/boBUNFYEi8i1/zHq9gOFkkPVF+wgB0W7lVxK3WXrzV\r\nfKz5lOxCUx9JQiqe2XxWn6H7s0eHfRvk8BB0TLSt3M61z5txYhCX64Y++8JJ\r\nttaFk/HoT8YOocc9FgSS/1BghqE7PIo0IwsY7BtqLdVbnICN+mnvJbDIbEe2\r\noQOUj+dvIEwJ3WCM1cDyNVRBpgoqetPXnGH2JocuaEhnjDNJVhiLv9EU5WzV\r\nOJu872TYRriilKB50tU1aZKrTvbxWeurdPM=\r\n=Rjp3\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"},"directories":{},"maintainers":[{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/router_0.6.5_1651073757613_0.019020903937470024"},"_hasShrinkwrap":false},"0.6.6":{"name":"@mayajs/router","version":"0.6.6","description":"Simple NodeJS routing library created using Typescript","main":"lib/index.js","scripts":{"clean":"rimraf interface && rimraf index.js && rimraf index.d.ts && rimraf utils && rimraf router && rimraf lib && rimraf class && rimraf exceptions && rimraf types","tgz":"rimraf *.tgz","package":"node ./scripts/clean-package.js","start":"npm run clean && npm run tgz && tsc -w","prepack":"npm run clean && npm run package && tsc --outDir ."},"keywords":["nodejs","server","router","typescript","library","REST","API","mayajs"],"author":{"name":"Mark Anthony C. Ignacio"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/mayajs/router.git"},"bugs":{"url":"https://github.com/mayajs/router/issues"},"homepage":"https://github.com/mayajs/router#readme","devDependencies":{"@types/node":"^13.11.0","jest":"^28.0.2","rimraf":"^3.0.2","ts-node":"^8.8.2","typescript":"^3.8.3"},"engines":{"node":">= 0.10.0"},"gitHead":"1c3da644189e488936d8099adc2e79da53b24122","_id":"@mayajs/router@0.6.6","_nodeVersion":"14.19.0","_npmVersion":"6.14.16","dist":{"integrity":"sha512-PkZp/NiYXqlyjKaNIcf6gbM5MMAqkFWl9jFAilnI+MYXsSwm61npbby95QR1m5ImD/P8BqWqNqsJUVMFzD80ow==","shasum":"f3ef5292671649002716e2767352173f1d09a880","tarball":"https://registry.npmjs.org/@mayajs/router/-/router-0.6.6.tgz","fileCount":37,"unpackedSize":71833,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCXMxvY3j3Cd79aHXIZQ+Xkwa3zIh1x3xu8ALL/9Ou8YgIgWSpH5uaNzz0NXNGQLJjCvYv9TnJpKirLGZoExds8sbY="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiaWUuACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoG8BAAg8HajAm2ZiEkZTq/BtyjjNPwURknBjGzfa6s51duqK0BQxso\r\nQTWOjmAPrBPXghB3npudhbl2fjLW2V6q6EAHapj2rpzXiP9HO0f7FkV1FfNa\r\nkSZFvginp/LhhpKE5zs3svDmeMJ9U3EWrcmGSB87qyBoDM/Bb8oxa7Nic0Hf\r\nHjfS0AZNucB325hLFhonRcZN7B7tGIvtoZSrtIInITNoDCBpTkKF+SAtpQ0d\r\njeBim9UiggUun3LVlt5uBrnmCRWZpGtd8OlDdWIIcXbpJC0/W4nFAYvh7URH\r\nS7RJ6Eui4jHSurgBIsLapCCzdnPURwSiS/Ukp9nLly2t20tOwx8xeWVB0MU+\r\n3lIhYTV6d/T2ChwDxXtXHJPJhoDkcIEJG7FwooUAK6WxZ3IPCySbTioZ0Ort\r\nte7tVT5+hZ/ySSsXauZEgm1kpi3MwqbSeYi9mamm0JAXBuDX1HI+l6KPCBIS\r\nsV2vLjyPMPASgT4UEwqDBxR14q34JTZtfq0EgjpAB9/x86EGN5HUfYUcH4Nx\r\nyecrUXhASY2Zg4XC6ft51/5tsZZh56TWC5suJ3CbDv8p1Pa7/Ya2YNUtwyn5\r\nv8mrwZkHKeuu7ST2naqqnIUlJ490tdgMSRp029GKVGluox0Ya8xk0uYEIZ1Z\r\n/pXqzNVbLnUtkyGVM1GjKocfKrt44ZO88qs=\r\n=m9U6\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"},"directories":{},"maintainers":[{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/router_0.6.6_1651074350223_0.45009647861175117"},"_hasShrinkwrap":false},"0.7.0":{"name":"@mayajs/router","version":"0.7.0","description":"Simple NodeJS routing library created using Typescript","main":"lib/index.js","scripts":{"clean":"rimraf interface && rimraf index.js && rimraf index.d.ts && rimraf utils && rimraf router && rimraf lib && rimraf class && rimraf exceptions && rimraf types","tgz":"rimraf *.tgz","package":"node ./scripts/clean-package.js","start":"npm run clean && npm run tgz && tsc -w","prepack":"npm run clean && npm run package && tsc --outDir ."},"keywords":["nodejs","server","router","typescript","library","REST","API","mayajs"],"author":{"name":"Mark Anthony C. Ignacio"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/mayajs/router.git"},"bugs":{"url":"https://github.com/mayajs/router/issues"},"homepage":"https://github.com/mayajs/router#readme","devDependencies":{"@types/node":"^13.11.0","@types/ws":"^8.5.3","jest":"^28.0.2","rimraf":"^3.0.2","ts-node":"^8.8.2","typescript":"^3.8.3"},"engines":{"node":">= 0.10.0"},"dependencies":{"ws":"^8.6.0"},"gitHead":"265496d2d7fc46d33295236d72a1e8ce84eb4f87","_id":"@mayajs/router@0.7.0","_nodeVersion":"14.19.0","_npmVersion":"6.14.16","dist":{"integrity":"sha512-B06xb0P+2eqRKhZ0QMhIGQ3/LgYGyCk7nV7t51UzneITscpxJ/tx1py8e6QCCJLNmmdstXOwZ8kXKh1DcR2IEA==","shasum":"c22aa6eeca6adb01d9bf9ba70fefc7181fab6ffa","tarball":"https://registry.npmjs.org/@mayajs/router/-/router-0.7.0.tgz","fileCount":39,"unpackedSize":76090,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCTru83z72Q+AZ3BBzGOsEX+3FIiUBCtwfx2kuGRtC3QAIgPIPETb3sb91/PJP2/rcGqUFgEnqvDpZO6fdfhnF3DNI="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJigPirACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmooQA//YAGjXCwouVlI4U7NHajHwJrPPKCClwu2FG28D3fxQV9DY6b0\r\ndKj2NCdJ04XtR8DZUSjdvW5mhbjitd6BBCibVdt0Mm0ReVYndzVujcEcUjKt\r\n/QD4W38WIPSgYw+VBFPsuJX/dPIaO/ZhQck8/Imx5gmJAkWqrx5WMFGtrI7Q\r\n/T8E32EjU/AvvkbW1gcPq+knxCCyeoxKsqZWB5hnots8JxrFVCp8pWI7lbUf\r\nxr3qxlgQiGzXPxMIYP24ei0uv1foHe9DPcGA2eGCw4WvtgqoDIT7R6Z3KTal\r\niP8U2Xs+XC7BCzUWkGdNbwgB5I9LIcOxLMZ/Qim0OuR1zvvjGRl3EPLJBrT9\r\nH8p7n69Y7uXZf3ofBwCAQNFDHUEz2ot2QQa8s9cfL1XQ6QHJSza366rbzUhA\r\np1S7H7Bb6Sz1onrEk53JjCzJardtgAMGxjzLPgaqIQqamQ1RYh9rnczMIJUH\r\ngbocs+dH3y6QzGiCLPYcxHoZIEQg08/0FMHl+a6RgJbxd8YDStPzEoCM42Qv\r\ny/+Nz8ekSopbStNybvhJyuQ2hdw05Yt8jIPBBUWMh3lJKQJ/t2fo2HD875OF\r\nMi2a7GV5bJczRCezWEFaicPI3v45zY6nhIIbDaswz36QKHxfYsga3bCzl8D+\r\ni9+UBYVa7kRmhfTdw2+xnFUZqwSIuzSapzo=\r\n=X2Tu\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"},"directories":{},"maintainers":[{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/router_0.7.0_1652619434844_0.48189187055922744"},"_hasShrinkwrap":false},"0.7.2":{"name":"@mayajs/router","version":"0.7.2","description":"Simple NodeJS routing library created using Typescript","main":"lib/index.js","scripts":{"clean":"rimraf interface && rimraf index.js && rimraf index.d.ts && rimraf utils && rimraf router && rimraf lib && rimraf class && rimraf exceptions && rimraf types","tgz":"rimraf *.tgz","package":"node ./scripts/clean-package.js","start":"npm run clean && npm run tgz && tsc -w","prepack":"npm run clean && npm run package && tsc --outDir ."},"keywords":["nodejs","server","router","typescript","library","REST","API","mayajs"],"author":{"name":"Mark Anthony C. Ignacio"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/mayajs/router.git"},"bugs":{"url":"https://github.com/mayajs/router/issues"},"homepage":"https://github.com/mayajs/router#readme","devDependencies":{"@types/node":"^13.11.0","@types/ws":"^8.5.3","jest":"^28.0.2","rimraf":"^3.0.2","ts-node":"^8.8.2","typescript":"^3.8.3","reflect-metadata":"^0.1.13"},"engines":{"node":">= 0.10.0"},"dependencies":{"ws":"^8.6.0"},"gitHead":"9901ecf79933a79200c142bf4fa0466c6f419205","_id":"@mayajs/router@0.7.2","_nodeVersion":"14.19.0","_npmVersion":"6.14.16","dist":{"integrity":"sha512-sxA4GOaFis0EG7YVudYmy+zTuTuwPQ9488DVWhsZhlqEfxfmASqAxRJtRnQ4DmS47zYpK6Y08x4vj0azXrwHIg==","shasum":"ac7dcb9559c333005beed2fe85a6cdc5de27a731","tarball":"https://registry.npmjs.org/@mayajs/router/-/router-0.7.2.tgz","fileCount":39,"unpackedSize":89286,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBt+XDCP/ieGYkcvxmNJUyjcLCOYNGei0OwNHB2eQdRCAiA42stMKr6RdKjyZW1jce/3DJnBKv6fLaO6/Cq3bw8e4Q=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJigPp+ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpdOBAAj1uj1vsXmBFT0ruDuxWgSrxDgUM50ltWNzLlyZsc1zComKMY\r\nXc/HgudMs62Y4EHKNNMM1cQv9EsjGDuaiQUxLruGG5wU1p15ZjXSXv7D+hlo\r\nbbdxxMJQHo1GyTrsjL1yHSSf2m5CM5oUIia1NDgaHd5MEW1dbOaoMYLyEXWS\r\n7wRxs0LDOhw65UJQN1rUj+TpN3P/9Dq99Kic7D07ZSloWR1d5emRB1zZ8QNJ\r\naX0HCrZ1TQfjsPT0Cvh6bg1FXBCacoTwne5aSAxAOzWkCfxNcXJOTov8qDAe\r\n4sYSkw2kjVGO8nWWNBVPca3tJuuaFVEy4qAUVq+pIVJ73NeygtzVa0QY4Tkk\r\ndGvl6ZTAY9lNXSno086loW4AFe9SDRs8FHkztQYrYmMX9trTIszl5UufpJBH\r\ni4p1ExsujS87YGQGikbGycWJ+TpIx7m1qzWuurdr5/BlOTRQAJ8uF4tRryPx\r\n0pJQDieraqR2PAZhkCnAm9wC8ec4nFsDm4c6wl+5Fj9oySUGCq8WkMHUj0ly\r\nwaXXRHQqjxWduPbusmdsb+YxNwyybBys02eLmI6Ct4UV3uN9LZTCmeEDtnK6\r\ni27ey51HY00Euho/5BnvjXpQ1YYTIOZzB0KQ/dqDFh4etUjJr4NXjDG97ejX\r\nD80pckognPzYMN76CQXYQH4/ikkyBQLqkyo=\r\n=YNbo\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"},"directories":{},"maintainers":[{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/router_0.7.2_1652619902550_0.4691714313473889"},"_hasShrinkwrap":false},"0.7.4":{"name":"@mayajs/router","version":"0.7.4","description":"Simple NodeJS routing library created using Typescript","main":"index.js","scripts":{"clean":"rimraf interface && rimraf index.js && rimraf index.d.ts && rimraf utils && rimraf router && rimraf lib && rimraf class && rimraf exceptions && rimraf types","postpack":"npm run clean && node ./scripts/restore-package.js"},"keywords":["nodejs","server","router","typescript","library","REST","API","mayajs"],"author":{"name":"Mark Anthony C. Ignacio"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/mayajs/router.git"},"bugs":{"url":"https://github.com/mayajs/router/issues"},"homepage":"https://github.com/mayajs/router#readme","engines":{"node":">= 0.10.0"},"dependencies":{"ws":"^8.6.0"},"types":"./index.d.ts","gitHead":"236a2b3a042e379bba7c4d46f69927c880cb9251","_id":"@mayajs/router@0.7.4","_nodeVersion":"16.15.0","_npmVersion":"8.10.0","dist":{"integrity":"sha512-2mqJgN03GdMEfSmwbhLhL16GkxW5hxNqCbgNe0U9xU/I1RLd/Budn7kWyEeXLKhCZtTRxptHUUmxv3s1pntyTg==","shasum":"5e446dca3375b89b27334bd3abd5bac4849099d4","tarball":"https://registry.npmjs.org/@mayajs/router/-/router-0.7.4.tgz","fileCount":41,"unpackedSize":90310,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDcH7eRKJYhhh9c0+4hgIjFEmRhkjlKa98mj+dpFeT3VQIgBdBn5z3uqH/0OL8cFHgApzbZGKJV9AXONISPEFbkzIY="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJigQKoACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqP2hAAlDGEhaNj9mhYHtbX3lzCoDPHnyhE6FPdlyCnVEvAJDjgKIHD\r\nFMCc3bXzWmoaQDLb487GPjIDu7jb/yqQ5LiogrO4Kwg0bH0PrsdStGj306KG\r\ns7oc/jfW2GioqYrpSHcq4Cl5yxqAuVpjZzgFY9Msr//5PnN2oFpKpB0SBW4m\r\nRwV+NtiHc0vDghi2R4D1axmaTokVykcEFSQoxPSnhRBDrk9GpQCQyFA0s+09\r\nAqmjaar8BQslpDhH3xgqQDG9iYa+VPJwAiw+ycCinz0pgP6jkdjU0giE5pTo\r\nc9DLqVUshGTA3ut9d2lBTKJkPUjJPSVJrmBeb26cKINTqlY17ha10ZsT4sgy\r\ntuKaIzCCB9ZHI3HoaAr3pArvQjOrslRAoQtqb2uQogLh99Jh2Zmb7Rp/cps4\r\nhhgAx1p9bzEMiyEW/grmHWBTZ/8Jx7H7Frq12wr5QKlh5ZIA7CfEp4QtmjGY\r\nX3ZZ4P7ELfXx6ktlYCTy2UTFuXjdJoKj6A7G2Pquy8FqVfIDmmXixXUc/kxT\r\nY1h2zrXsDGsA9zSjK8EKz7bRwglNCqPcLg7K3rjG1O5Ge+6oKnISe5rhooWQ\r\nbBMwUODPpmPyapntZwK/aXb4XjGFVUXDm7x4nYeDw30otFiioD4mW4CWJfns\r\nJt6BB6BDj4RiVpSdEiFD4nJoqOqKHTdcx9Y=\r\n=fSmp\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"},"directories":{},"maintainers":[{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/router_0.7.4_1652621992457_0.01145984207375439"},"_hasShrinkwrap":false}},"time":{"created":"2020-06-27T18:07:58.203Z","0.1.0":"2020-06-27T18:07:58.552Z","modified":"2022-05-15T13:39:52.738Z","0.1.1":"2020-06-27T18:47:37.768Z","0.2.0":"2020-07-19T07:53:50.098Z","0.3.0-rc1":"2021-04-04T09:01:39.858Z","0.3.0-rc2":"2021-04-04T18:15:17.384Z","0.3.0":"2021-04-07T22:17:41.988Z","0.4.0-rc1":"2021-04-15T10:06:15.611Z","0.4.0-rc2":"2021-04-15T12:08:44.521Z","0.4.0-rc2.1":"2021-04-15T13:39:07.987Z","0.4.0":"2021-04-15T14:11:26.882Z","0.4.1":"2021-04-17T10:26:04.665Z","0.5.0-rc1":"2021-04-23T07:12:08.630Z","0.5.0-rc2":"2021-04-29T14:24:22.277Z","0.5.0-rc3":"2021-05-05T20:17:18.346Z","0.5.0":"2021-05-05T20:24:11.856Z","0.5.1":"2021-05-14T15:44:55.241Z","0.5.2":"2021-05-14T16:41:17.735Z","0.5.3":"2021-05-15T15:48:26.628Z","0.5.4":"2021-05-16T10:14:15.177Z","0.5.5":"2021-05-16T11:29:09.321Z","0.5.6":"2021-05-16T16:40:15.485Z","0.6.0-rc":"2021-12-26T14:52:41.064Z","0.6.0-rc2":"2021-12-27T01:04:57.416Z","0.6.0":"2021-12-27T01:32:12.144Z","0.6.1":"2021-12-29T04:56:48.876Z","0.6.2":"2021-12-29T14:06:27.162Z","0.6.3":"2021-12-30T16:20:55.722Z","0.6.4":"2021-12-31T05:45:07.325Z","0.6.5":"2022-04-27T15:35:57.796Z","0.6.6":"2022-04-27T15:45:50.384Z","0.7.0":"2022-05-15T12:57:14.989Z","0.7.2":"2022-05-15T13:05:02.768Z","0.7.4":"2022-05-15T13:39:52.637Z"},"maintainers":[{"name":"mack_ignacio","email":"mack_ignacio@yahoo.com"}],"description":"Simple NodeJS routing library created using Typescript","keywords":["nodejs","server","router","typescript","library","REST","API","mayajs"],"author":{"name":"Mark Anthony C. Ignacio"},"license":"MIT","readme":"<p align=\"center\"><img src=\"https://github.com/mayajs/maya/blob/master/maya.svg\" ></p>\n<h1 align=\"center\">MayaJS Router</h1>\n<p align=\"center\">\n  <a href=\"https://www.npmjs.com/package/@mayajs/router\"><img src=\"https://img.shields.io/npm/v/@mayajs/router.svg?style=for-the-badge&logo=appveyor\" alt=\"Version\"></a>\n  <a href=\"https://www.npmjs.com/package/@mayajs/router\"><img src=\"https://img.shields.io/npm/dm/@mayajs/router.svg?style=for-the-badge&logo=appveyor\" alt=\"Downloads\"></a>\n  <a href=\"https://www.npmjs.com/package/@mayajs/router\"><img src=\"https://img.shields.io/npm/l/@mayajs/router?style=for-the-badge&logo=appveyor\" alt=\"License\"></a>\n  <a href=\"https://github.com/microsoft/typescript-tslint-plugin\"><img src=\"https://img.shields.io/badge/code%20style-standard-blue.svg?style=for-the-badge&logo=appveyor\" alt=\"Code Style\"></a>\n</p>\n<h2 align=\"center\">Lightweight, simple and fast NodeJS Router developed using Typescript.</h2>\n\n## Motivation\n\nWe develop this library to be used as the main router for [MayaJS](https://github.com/mayajs/maya#readme) RESTful API framework. As much as possible we want to have a full control of\nthe libraries we used in our main projects for maintainability and ease of transition for future updates.\n\n## Roadmap\n\nYou can see the detailed roadmap of the project [here.](https://github.com/mayajs/router/blob/master/ROADMAP.md)\n\n## Suggestions\n\nFor suggestions and features you want to see in the future you can visit our [issues section.](https://github.com/mayajs/router/issues)\n\n## Getting started\n\nBefore installing this package make sure to download and install Node.js 10 or higher.\n\n### Setup Node\n\nTo check your node version\n\n```shell\nnpm -v\n```\n\nFor new project kindly initialize npm using the command below or see documentation [here](https://docs.npmjs.com/creating-a-package-json-file).\n\n```shell\nnpm init\n```\n\n### Setup Typescript\n\nInstall typescript and typescript watcher\n\n```shell\nnpm i typescript ts-node-dev -D\n```\n\nInitialize typescript\n\n```shell\ntsc --init\n```\n\n### Setup Router\n\nInstall mayajs router\n\n```shell\nnpm i @mayajs/router\n```\n\nAdd `start` script on your `package.json`\n\n```js\n\"scripts\": {\n  \"start\": \"tsnd src\"\n}\n```\n\n## Features\n\n- Simple and easy\n- Lightweight library\n- Built with TypeScript\n- No third party library\n- Modules for shareable code\n- Dependency Injection and IOC\n- Fast execution with route caching\n- Supports beginners to advanced developers\n- `Function` and `Class` based coding style\n- Supports third party middlewares like `ExpressJS`\n\n## Quick Start\n\nThe easiest way to get started is to create a simple route. Create a `src` folder inside your project folder. Inside the `src` folder create an `index.ts` file. Copy the code below into `index.ts` file.\n\n```ts\nimport maya from \"@mayajs/router\";\nimport http from \"http\";\n\nconst PORT = 3000;\nconst app = maya();\n\napp.add([\n  {\n    path: \"/\",\n    GET: () => \"Hello, World\",\n  },\n]);\n\nhttp.createServer(app).listen(PORT, () => console.log(`Server listening on port ${PORT}.`));\n```\n\n## RUN\n\nTo run your mayajs project open a terminal inside your current project and run the command below.\n\n```shell\nnpm start\n```\n\n## ROUTE\n\nDefining routes in MayaJs is like creating a JSON object.\n\n```ts\nconst user = {\n  path: \"user\",\n  GET: () => {\n    //  ...\n  },\n  POST: () => {\n    //  ...\n  },\n  PUT: () => {\n    //  ...\n  },\n  PATCH: () => {\n    //  ...\n  },\n  DELETE: () => {\n    //  ...\n  },\n  OPTIONS: () => {\n    //  ...\n  },\n};\n```\n\nAs seen above each method name has a `callback` function. Mayajs will set the correct `content-type` based on what the method callback will return.\n\n```ts\nconst route = {\n  path: \"user\",\n  GET: () => {\n    // This will return `undefined`\n    // This will have a content-type of \"text/plain\"\n  },\n  POST: () => {\n    return \"Hello\"; // This will have a content-type of \"text/plain\"\n  },\n  PUT: () => {\n    return { message: \"Hello\" }; // This will have a content-type of \"application/json\"\n  },\n  PATCH: () => {\n    return \"<h1>Hello</h1>\"; // This will have a content-type of \"text/html\"\n  },\n};\n```\n\nIncase you need to use a middleware for an specific route method you need to create a route object instead.\n\n```ts\nconst route = {\n  path: \"user\",\n  GET: {\n    middlewares: [middleware],\n    callback: () => {\n      // ...\n    },\n  },\n};\n```\n\n## PARAMS\n\nMayaJs passes a context object on each route method. You can acces the route params by destructuring the context object on the callback method.\n\n```ts\nconst route = {\n  path: \"user/:id\",\n  GET: ({ params }) => {\n    // `params` object contains the value of `id` define on the path above e.g. `user/hello`\n    return params.id; // This has a value of \"hello\"\n  },\n};\n```\n\n## QUERY STRING\n\nYou can also access the query string using the context object provided by MayaJs on your route method callback function.\n\n```ts\nconst route = {\n  path: \"user\",\n  GET: ({ query }) => {\n    // `query` object contains all the value on your query string e.g. `user?id=1`\n    return query.id; // This has a value of 1\n  },\n};\n```\n\n## BODY\n\nRequest body is also accessible in the context but you need a middleware before you can actually uses. There is a popular middleware called [body-parser](https://www.npmjs.com/package/body-parser) that we can use to achieve this.\n\n```ts\nimport maya from \"@mayajs/router\";\n// Third party middleware you need to install\nimport bodyParser from \"body-parser\";\n\nconst app = maya();\n\n// Initialize body parser for mayajs to use it internally\napp.use(bodyParser.json());\napp.use(bodyParser.urlencoded({ extended: false }));\n\nconst route = {\n  path: \"user\",\n  POST: ({ body }) => {\n    // `body` object contains all the value from the request body\n    return body; // This has a value of req.body\n  },\n};\n\napp.add([route]);\n```\n\n## MIDDLEWARES\n\nAs seen above how we used third party middlewares to parse the request body. We can also create our own middlewares. Although MayaJs supports all [ExpressJs Middlewares](https://expressjs.com/en/resources/middleware.html), we also can create a `MayaJsMiddleware` of our own. The context is where you can access `params, query and body` objects.\n\n```ts\nrouter.use((context, next, error) => {\n  // This `error` variable comes from the previous middleware\n  console.log(error);\n\n  // The `next` function will trigger the end of this callback function\n  // and execute the next middleware in the list\n  next(\"Error message or any value that you want to pass to the next middleware\");\n});\n```\n\n## CHILD ROUTES\n\nA child route is a route that appended to its parent route. It can be added using the `children` property from the route object.\n\n```ts\napp.add([\n  {\n    path: \"parent\", // This is the `parent` route\n    children: [\n      {\n        path: \"child\", // You can call this child route by `parent/child`\n        GET: () => \"This is from a child route\",\n      },\n    ],\n  },\n]);\n```\n\n```\nNOTE: A `child` route can also have its own `children`.\n```\n\n```ts\napp.add([\n  {\n    path: \"parent\", // This is the `parent` route\n    GET: () => \"This is a parent route\",\n    children: [\n      {\n        path: \"child\", // You can call this child route by `users/child`\n        GET: () => \"This is a child route\",\n        children: [\n          {\n            path: \"grandchild\", // You can call this child route by `parent/child/grandchild`\n            GET: () => \"This is a grandchild route\",\n          },\n        ],\n      },\n    ],\n  },\n]);\n```\n\n## CONTROLLER\n\nA controller is a class that act as a replacement for the route method objects. It can be used to make your code more modular and manageable when your code base get bigger.\n\n```ts\nclass UsersController extends Controller {\n  GET() {\n    return \"Hello form UsersController\";\n  }\n\n  // You can also add additional route method like this\n  POST() {\n    // ...\n  }\n\n  // Other routes available are PUT, PATCH, DELETE and OPTIONS\n}\n\napp.add([\n  {\n    path: \"user\",\n    controller: UsersController,\n  },\n]);\n```\n\nIf you want to add middleware a middleware to a specific method you can add the `middleware` property in a controller.\n\n```ts\nclass UsersController extends Controller {\n  middleware = {\n    GET: [middleware], // This middleware will be added to the `GET` method below\n  };\n\n  GET() {\n    //  ...\n  }\n}\n```\n\n```\nNOTE: A controller has no `children` property\n```\n\n## SERVICES\n\nA service is an injectable class that can be used inside of a controller or another service.\n\n```ts\nexport class UsersServices extends Services {\n  // Every function inside the service can be accessed by the class its injected\n  // All public properties are also accessible\n  // A service is instatiated once and making it a singleton\n\n  add() {\n    // ...\n  }\n}\n\nclass UsersController extends Controller {\n  constructor(userServices: UsersServices) {\n    super();\n  }\n\n  addUser() {\n    // This `add` function coming from the `UsersService`.\n    // It is accessible on this controller via dependency injection.\n    // MayaJs automatically instantiated it and created it singleton instance.\n    this.userServices.add();\n  }\n}\n```\n\n## MODULE\n\nA module is a like a container of routes, controller and services that act on its own. This will allow your code to modular and shareable accross all routes.\n\n```ts\nclass UsersModule extends MayaJsModule {\n  // List of `module` or `services` that this module will use for its controllers\n  imports = [];\n  // List of controllers that this module will use\n  declarations = [];\n  // List of services that can be use inside this module\n  providers = [];\n  // List of services that this module will exports that can be used by other modules\n  exports = [];\n  // List of dependencies that will be injected to this module\n  dependencies = [];\n}\n```\n\nAs you can see when we create a module we dont have any way to add routes on it. Below is an example of implementation of how to add a `RouterModule` for this module to add routes.\n\n```ts\nimport { UsersController, UsersIdController } from \"./controller\";\nimport { RouterModule } from \"@mayajs/router\";\nimport { UsersServices } from \"./services\";\n\n// Define the routes\nconst routes = [\n  {\n    path: \"/\",\n    controller: UsersController,\n  },\n  {\n    path: \":id\",\n    controller: UsersIdController,\n  },\n];\n\nexport class UsersModule extends MayaJsModule {\n  // User `RouterModule.forRoot` to inject the routes\n  imports = [RouterModule.forRoot(routes)];\n  // Declare the controllers that will be used inside the routes\n  declarations = [UsersIdController, UsersController];\n}\n```\n\n## CUSTOM MODULE\n\nUnlike the common mayajs module, custom modules provide other functionality aside from managing your controllers. One example of this the `RouterModule` that is reponsible for adding routes to your module. A key concept of a custom module is it has an `invoke` and `forRoot` function that provides additional functionalities.\n\n```ts\nexport class UsersModule extends CustomModule {\n  invoke() {\n    // This function will run after an instance of this module is created\n    // But the providers will stay singleton on each instance\n  }\n\n  static forRoot(options: any) {\n    return {\n      module: UsersModule, // Returns the current module reference\n      providers: [], // List of providers that this module will use on its controllers\n    };\n  }\n}\n```\n\nNow we know how to create a module but how we can call it on our routes. We are now introducing to `loadChildren` property of our route object. MayaJs will automatically resolve the module asynchronously when the path is added on the route list.\n\n```ts\nimport maya from \"@mayajs/router\";\nimport http from \"http\";\n\nconst app = maya();\n\napp.add([\n  {\n    path: \"users\",\n    // We are using dynamic importing so we don't need it to manually import the module in the file\n    // MayaJs will resolve the module asynchronously\n    loadChildren: () => import(\"./users.module\").then((m) => m.UsersModule),\n  },\n]);\n```\n\n## Collaborating\n\nSee collaborating guides [here.](https://github.com/mayajs/maya/edit/master/COLLABORATOR_GUIDE.md)\n\n## People\n\nAuthor and maintainer [Mac Ignacio](https://github.com/macign)\n\n## License\n\n[MIT](https://github.com/mayajs/router/blob/develop/LICENSE)\n","readmeFilename":"README.md","homepage":"https://github.com/mayajs/router#readme","repository":{"type":"git","url":"git+https://github.com/mayajs/router.git"},"bugs":{"url":"https://github.com/mayajs/router/issues"}}