{"_id":"@whatwg-node/router","_rev":"217-66566024d85c7ff4df8cd1ce33ea0a3b","name":"@whatwg-node/router","dist-tags":{"latest":"0.3.0","rc":"0.4.0-rc-20230301165834-79d3ff1","alpha":"0.4.0-alpha-20230302123908-6a2d38f"},"versions":{"0.0.1-alpha-20221220101531-15f683b":{"name":"@whatwg-node/router","version":"0.0.1-alpha-20221220101531-15f683b","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.0.1-alpha-20221220101531-15f683b","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"5d4c7f4cba406e2751980c3f15c1b059eab7428a","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.0.1-alpha-20221220101531-15f683b.tgz","fileCount":6,"integrity":"sha512-LhGSI3yTe7rQNyNZrzjIcH89sR6kC/4sum5ciullbaEObpuUT9+cdNDpkIi9pPXd0hmsJiBqgmWEe4zU/W8LVg==","signatures":[{"sig":"MEUCIEDw4NM738V6mD5dKmbpx3mYpY0ATJSQ7JJmqOBb+FlqAiEA6LtQA2faafVCc+m3UiXUTHOoiJnHmiP0BbierrRXjFA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":3487,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjoYtSACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmp3PA//VJ5GfnBkz9RHjSm+poIzbEo/GM8oBKO+dCg3aYyeC7QGtPvk\r\nyKlYGU/Om9/ThMvMtIHclV2s2BTo9d4VhQ8Vlz8I9KpenAeBlUpIript+3Df\r\nfAu+wqOvuTMb/dB1x5oIbEnES5UySGIs8prQv8+yX9BQEBUOUomHW+gh69tV\r\n04cuIQl6x7jfJL9tGNcGSN3a/cQ6F6zH8YaFv8nCwbv3XOik9l80yvW3AzDX\r\nL09lJHynwiPBZ/Ftxb9AJQ1dA0bcoBtwQ6HyIhlKDOvc0E6ZTnb3kZQ5re3c\r\nWhS/ESHqEuvyPi9UpZpeTQndSOdF7oJLH9i/csMpmTrkbJpzkooz9rVI4Uoh\r\n8PEVpM3DtoHSsF+OfBekSi2UcUScvGbdzUQ+FR+ZfRQAv0RYG4oqc6xGg1Fe\r\nf3xrKmm48G1WSelKOcccv9rWrgaiXYF5sXeWxePp5dxSXdGIhaNv52ZP45vA\r\nXl3GbyHJhSq4aYh8ZE7BeLtxIwwclUGfJkROjuxoE0fxeEuRLkBGx//GOZOj\r\n11m+IOVZLRVpw7UrcVJbUuWu6S5VlfEDyiHsPxEjYVNXebqZj6L8nCIWevYp\r\nyJSPGxOCqgDBLzHacG8PKGJ9EsSgsihLr7koAOxXNenEwMgKREhdcC4k3a3k\r\nKfbfnsRxTAg8fSxLNa2uu8Pzee5zd/tUU/k=\r\n=arAC\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"15f683bb52b7aaeec3778a7a2c71eea01e5e7a29","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","itty-router":"3.0.8","@whatwg-node/fetch":"0.5.3","@whatwg-node/server":"0.4.18-alpha-20221220101531-15f683b"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.0.1-alpha-20221220101531-15f683b_1671531346710_0.12189693619770958","host":"s3://npm-registry-packages"}},"0.0.1-alpha-20221220104236-d3ce2f8":{"name":"@whatwg-node/router","version":"0.0.1-alpha-20221220104236-d3ce2f8","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.0.1-alpha-20221220104236-d3ce2f8","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"36de1e93ac3827e308d61c049e8325d82668dbad","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.0.1-alpha-20221220104236-d3ce2f8.tgz","fileCount":8,"integrity":"sha512-dTDvKy3Biy3pCawp67SwVaCNiaeS+3wJnybCYZv9RfTJwpAVKIljPzeZLjWgIRHZymp4/WBdI8BPwiV2EGf+Ow==","signatures":[{"sig":"MEUCIHNdATPqgnDtkaVxNMHsviPrIxSLrGcNQ2WygtC1RyrOAiEAtx9XZ5WJ8/ivClo+5b7CTV3qcjW0mD++4ZNrVQmVqqQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":17057,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjoZGpACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqFSBAAmdvIBdehEmw/7gBrInY+ATT3G95T2VlG5PGwJIhWDwEEZ8wl\r\ndo6jtYH2ZNIzlTHp0XXp7F0ST1HjNxJUe/QZv6hwDjNHEr0StVxeHGUxObmd\r\nEe3rvF9HIz7IZa5DlRzCx5tLrVX7IbelX2bMcBNh9n83EJnbWnj8R8KwOpjr\r\n879m2uOjjseh+SrjEQvFG82idAyya2NCBgvFqwqbmnhgWVX2QAhrJ4m/a3MC\r\nGj98l+bm2PL7ihQvtaL5jluniReDPUmzKyi6WlktaGjGF/TFExYLRG21xQ2o\r\nASGXbd+TAG1t3vZTjl4kY9Yp8eP6VE3TihXtYycfgR6OAn/9XfOFlG60mP1d\r\nNImniPAti1h33Gu9HEKRltZ5RcRt9brxCP/D0JrU+vQFF5TRltp6I7ReJ0+f\r\nF8O0ppmV1NJbbx7Iip44zL3pcwunO+FIz+7FKKJ/To+Hd+4YhD8wBmAJOWPx\r\nQHHoBln6HlvmiTbXCLReRaZdL0SuOxD1kNDfC9gkzJUv48BF8jHwDL5Fyk6G\r\n+vxdIQVipzgTFzSgztV219drUwHtGBrUny7LW+HpwA9UoItDvEuHki6tNzCN\r\nmslvI/ZUSoJPzhu1ZqRzbypidTlp9Sj0o3JVFLsoH7oRAakC/grsdzcya133\r\nnmTE8u4z+dE5bxdbZjCuqJfC0b2VOfdgMrw=\r\n=8c5D\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"d3ce2f8a39b4f5995e3e4d4b1f1bced06519e7b4","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","itty-router":"3.0.8","@whatwg-node/fetch":"0.5.3","@whatwg-node/server":"0.4.18-alpha-20221220104236-d3ce2f8"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.0.1-alpha-20221220104236-d3ce2f8_1671532969435_0.32972817795607257","host":"s3://npm-registry-packages"}},"0.0.1-alpha-20221220105110-a226647":{"name":"@whatwg-node/router","version":"0.0.1-alpha-20221220105110-a226647","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.0.1-alpha-20221220105110-a226647","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"78180131834ef102f6e3d135fb2e167e535bf750","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.0.1-alpha-20221220105110-a226647.tgz","fileCount":8,"integrity":"sha512-2HERexnoyFw8Hl2qEx0e7PIOQWNo1qfx1DVxTOZmqEJYqUQghooPM5qiC0GEt1COaYC59U+WtUqqLNRgYRPPkA==","signatures":[{"sig":"MEUCIDcfJPo3A8G+yN1Qq6pvCX4qUdNta8kLKa+FBd4ko8UzAiEA5MkBczDVqzDpr6jfPzJ3oU5tBnaKXrBw05ZmQmK1LE4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":17057,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjoZOrACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmr/5A/8Cn3WrBTaXoglaIxLOw/n5Wfvg+moJ9bl8Rm9vdbasvj8ZCtV\r\nw62uZrgcQVY0R+nWNW8o+GYObTFHIkY/FR3cAHuJc/zEiLnI+0BMax/pC9zz\r\nFZB/wJEE5FhTbxEDYXaX0HZHRzeJxv2vo2v3B7mMexAAAuWb85TA4GuVpZi+\r\n3hQFzUeCjlAPJrI2cdCnMfyHdNdwAvE3ePy+/QiWk/pXDaW40nS3Rs8yU9YA\r\neisxxkCednrkCxCHr0GvOk0ft8Wacjq7FVQEvl7bgBl8972HgZJH+NTb+WSr\r\nZu1vTZQdW2wtkB//+vlwNSVfxo4iIHykNqG1tG67+cPTTmqNCREdh60yqYop\r\nCcpKGULVcxlaD3Zbs1y5rglytE6hPIAWvm1oumT10Kqia2tK5typF+wCueUR\r\n3LosVjqgZVmZK+BdM1T3HrV4k2oLJO2rCeuQAq09ZHlnSBk8MxBPIyx08SBo\r\n17Z6WrgObsVsxlJTOl6McrKMYlDfibyU3WDrpooxwou7/L40c3gedPA5v760\r\nk/rKKCZIGgmj85RmKTh/gsWopCiDQidNKlfTORjd6pP49gylDlDO8tGkkuUk\r\nKaAk2dvldcemJu8khFtLr2S0+6Uabtg7KyY9AtDB2fAObrhQCFvCctIg1wKG\r\nHG6Ge7puH9KNepHBOna6ZvRfyUhZLsVvzCQ=\r\n=z1aF\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"a2266477b1d422e3af8cd76e5b555fdfd3962e22","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","itty-router":"3.0.8","@whatwg-node/fetch":"0.5.3","@whatwg-node/server":"0.4.18-alpha-20221220105110-a226647"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.0.1-alpha-20221220105110-a226647_1671533483316_0.1813850062045823","host":"s3://npm-registry-packages"}},"0.0.1-alpha-20221220120052-cd1457c":{"name":"@whatwg-node/router","version":"0.0.1-alpha-20221220120052-cd1457c","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.0.1-alpha-20221220120052-cd1457c","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"f18e7d19bfef3dcd22e94733a810e625ff95629f","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.0.1-alpha-20221220120052-cd1457c.tgz","fileCount":8,"integrity":"sha512-kb2uZDplOI217QBGMOEihLSVaIE2CNXsZXCEEbt6aUujm/LY3/XDPEBSi/IkJqCoKwBZ0FD+YCpt1IFVG6HSIQ==","signatures":[{"sig":"MEYCIQDfT623Gq6aqSAwaA1sXgkc4QB9KDnGNg+Fm7O9NOISegIhAP4qwqfvD32ohTv6bnWrtRh+USAxQP1U+yqoJaW+UyiP","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":17057,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjoaQDACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrzEQ//cr+QEGoTyfD33Z9IymcI2E+Pf4mGJp4id0N4q4sFm8+VLX9K\r\nyiGCn5T5amn0YYOPchdGJ6QzD4hq3mokhWnhB5mea9KU2jjCcX9+PlNX/9bw\r\nO4ViEgTVwiJUieKFmmPaNCfHqLAuLwplEfs+T4gPZxYSDYEAHYkSavDtpLiE\r\nHNXb3WfCUWqAgpI5qplrGpv5gq3KXkwp8XJmdiKRu7BSelVazltLLoxGML+c\r\n0589SiCkgvXnsEMw9smaVj0C3d+HwsjP9crjtjx9oR4/IJ3yjFM0oGy3Z108\r\nm5etIz3oLpZFvlfR5xhtoIODbV0E363mCG8TYDVHW+B1dxnaVyTkWs+QtMs1\r\nJb6CYn+ibEuPbIFnOCyR5D8id8mxFQwG64MYelSKx7s/vck91IVPrJY5zI6V\r\nmC7qSuQ1v8bgEEJf2S0Gy62qSN94zYZNreJzTJGblNrHPBjuRAaEqzpx59Sw\r\ngiFEd+fXzDa1WL4fQwbpXLAIS4SvHuuQHwKg3lG2wTYUwyXm9ZCynzvUm6qY\r\nUBCh3bKrxA/pxsSICFpO3/Jg6+IXbx2N68Tw56BFfEKFiTfB068Ann0OPWWg\r\nNncbzAmW90USC8qTKkwKIVpGDa0m6ez1P/LP2/uv7cj1CdvRfCFEB2fNtraG\r\n0bOKEEy37c7vVgkbwLeAEDaIhHHFgjlxR+s=\r\n=58J9\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"cd1457c14721e6e89798308e1497f32295fe2eff","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","itty-router":"3.0.8","@whatwg-node/fetch":"0.5.3","@whatwg-node/server":"0.4.18-alpha-20221220120052-cd1457c"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.0.1-alpha-20221220120052-cd1457c_1671537667783_0.6529448825139965","host":"s3://npm-registry-packages"}},"0.0.1-alpha-20221220143426-2744af4":{"name":"@whatwg-node/router","version":"0.0.1-alpha-20221220143426-2744af4","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.0.1-alpha-20221220143426-2744af4","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"eae35a9fdd84d606f50c3eaf22ba0e6dea5b78c3","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.0.1-alpha-20221220143426-2744af4.tgz","fileCount":8,"integrity":"sha512-Uab/YJFwc9wLNnkDaliIL10xdgF03xY1bMjcV/IDjQ9FDlOdnL7gHksn8tw8xzUBHU6hvtQEX03pBKl+AV6M8A==","signatures":[{"sig":"MEYCIQDF5vmiqb+rhYiTeL502w61Xo17K6WnnNzWyvfn3C1kkwIhANXWnCLqcha4cTRsqUeVqhGZODWE2AcsR90zncL3/cZY","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16983,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjocgDACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoGxg/+Pvb8glPuE2IynCY+hHgFx5TU34c8VgwEvI6CWpZuIxSRreWX\r\nIc794PnvYQWuvLkJe4FgH7izpM0TcNV36yqpBv6NcT4yieUPWBbEPyjNePlW\r\n6mtHFdVE1mCrLkisWEo5i5xIoIt1pmtzQWV1HrxmSsZTwFOhLAAYXiMvd4Ah\r\nTPi10pq76abYawrA1RYOPLhoVmS1gjc+Nm3mVvaN6laErm4GgftD0JYJk1Np\r\naKvUb58VHX/Y3gUqJpYVB90OV0oZNzSmQGv1DKj42+I2v1Dw/IKBB9qe903y\r\nrhySwcp0jSywVI3gWRNnhks9X2VPcuJHwvWaRkx1EPAG8K8rN1vLkszUtSbA\r\n2EZJwPcrMjmw0JkEPdXmxtp9hSaEuLM+OzzdY9iUOfni2YBrHMunNgmq0xuR\r\n9BI23GHax4t0W2r1GCf2N2H/O7hxIkW/ZYi8HZ41drkw9eeaNnBD/1Vxy47b\r\nkEw0CqN2K8MDJOXTBxX/xcwVPyZou286fNAfzxVuq1cLlZWLK+RmUNO7ZsZk\r\neB5UJdRl/jByCK+VoJiAOEMzFGu/s+qSPShPd27LtoBEFzU59LvUK7onxh2F\r\nrnK0s4YnfTRQqAOn2UQcevPj6C4gmTc7WUgd1VOQXgY+BD4ppgeiHgLqPPPa\r\nPoSYR5UrhRJY3TzsJH0eepJC9VZj1KTfBgM=\r\n=Cvy6\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"2744af46c9fa3da42f9785604dbeda038364a046","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","itty-router":"3.0.8","@whatwg-node/fetch":"0.5.3","@whatwg-node/server":"0.4.18-alpha-20221220143426-2744af4"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.0.1-alpha-20221220143426-2744af4_1671546883711_0.9127175143942676","host":"s3://npm-registry-packages"}},"0.0.1-alpha-20221220144402-dce2fb1":{"name":"@whatwg-node/router","version":"0.0.1-alpha-20221220144402-dce2fb1","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.0.1-alpha-20221220144402-dce2fb1","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"89ff6367781a9e7dee0a4739d1ade3123a8a179b","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.0.1-alpha-20221220144402-dce2fb1.tgz","fileCount":6,"integrity":"sha512-NmyJwungFK5fcKVoxouvPtqmsCXqqeJOzF4muaXUab/K94pCCQKVXSjicUvqLzDVP8a8UvaffIY6Jbxca+alMg==","signatures":[{"sig":"MEQCIDg0+pZGtdKDh1HBBwXd9xv+qlWVDkEyB9Rr6WFq3ZtlAiBap3BPK0vsEOSfWm2mpRmQq+B5utidNG4wUs6WKtp9pA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":3488,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjocpAACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoAoQ//Yb9WdINIj3/zurQdR52fldMqAhBWFDc+Cnyncsin6FUqdDeU\r\nONmdCpzo9+XEMjWnf+w36aBxI2G6zhHh4pf8gfUh+5Obt3nk9MarGcFq/rw1\r\nK82+rYJ02YFTJZqjHmpJdm17JaxxyKzgHe7iU2nQucyA5uYhIjZDl35KEJBl\r\nPITiApjgEraTBHGzfe0PdbaciXAa2U1KUYrUbNaBXLQ+qE0cWMZPZnPqdDFd\r\nkurS2yCVhbujGisaNdTslHWUq5ctxwPSY33nSABlMry2KdQPTB711e4PS1E+\r\nnUomQy96CSSofDySywh8GZfZAx+E/EVJunCI/VwY4GqQne+UU7rwCT4/Y7qc\r\nu0p6ZRXTDLN49eYAOKjqAHZ7k1a8IMXP0M1LIGdFFlmOKgXR0gMX210y+J2E\r\nAz2GdxndohTiyjhQ1PndrdjoG5x36bAZ65ykWNwAA+iPSXKui5U465oSVKJv\r\n+cd8/aukLa1IfbG1pXWfY7R8iLtppgMiqLN5V/oHxgYOsJw1PZFDD3ZamdpV\r\n+SQU/mRV7CXgdwwKZiYWZBOztxjA7xXFPRrCZu3UBTxoP92lSwERidKmtqKC\r\nGjhdWUH/5eN+r5BKCPTFOI5YV3Grrv+rRXCm3ML1jFWxIL71v5h7mmTCJSB2\r\ne5rZwS25T4z+nxP4WYrkIUBi5lLbkuN3F3M=\r\n=Bpeh\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"dce2fb116c6fb904519b730fc6afaf4ebb05cc95","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","itty-router":"3.0.8","@whatwg-node/fetch":"0.5.3","@whatwg-node/server":"0.5.0-alpha-20221220144402-dce2fb1"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.0.1-alpha-20221220144402-dce2fb1_1671547455822_0.9750105094494397","host":"s3://npm-registry-packages"}},"0.0.1-alpha-20221220145232-524e5a0":{"name":"@whatwg-node/router","version":"0.0.1-alpha-20221220145232-524e5a0","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.0.1-alpha-20221220145232-524e5a0","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"42c6284ad6ff438e3b87643fc8994f4bdfe76272","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.0.1-alpha-20221220145232-524e5a0.tgz","fileCount":6,"integrity":"sha512-IZmVljg+B6LzsdrZFYAmeDFKIlbYt6+dhutyl0dI0bhzo0WFVCiImoA9Jn4iGyLrTO+RNTzxHflL878fBEGlYQ==","signatures":[{"sig":"MEUCIEdxbUXioo4z5hqfPhDAyec8NrGnjPs3I+J323CkVuoQAiEAsQOe6GJcHDYPdH5m3hffEciHlSLDXDs5eixVX+MXcso=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":4129,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjocxAACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqE4A/+MAPq8908qSn9jVW/Q1l303me40y1s6Ab0wxk4aEW/OECVPhu\r\nwd1u+cTn4E4R70Hw5YgnW98hHy9JlfNUg4VZJn6jMCoGyQHa/2L+bVFEpjjr\r\nDdtb+yVbODw5DwEREs/ug8chXnpOycyALqltpooEOYZF+MlxnUJyPTDSDqS8\r\n9eyfIjH9941i7iF7I/Cgho1RxVRCO1NuyZNAj7pfgiJ41qIIq3ghQ8mT/Rye\r\nJRFv6HumhFOF8dRFuGKaezDvGmta+n4aMN8aIwIkWVmW/PX4e8whfiXlrGeh\r\n62QPAsujssO8XV2zrsOxJCTJNsAWFFRZbVYCSTyb6J/g0s/yxKGKRXuGmz4I\r\nYXFZZ2t4rRqwpxZovngnPNAngcYsvtS48Fq02pL1AC2y90oDFTrcGBVDaXG8\r\nu9C2Ko0QpxPJu3jPxJeJbHUkUBbL4c+rTp/c1I4H43XTVac9wnSxNUuK+bvu\r\nwtVhWJEEAELXLcYfERayGUF6CqRG8Q4hJy7hH4cGcxQA55/Gl/nAnOhweAJM\r\nlx+2hItbD3MV2ZORJ42UMs1mhHi5t8MKAuN60hapC4JxEj2T4T/m8P60DMIW\r\nul4Gkjep2wUbiD7DRolOm0luysR+9xJ5bxANcimPpHFrjBYnd+SzieMG9gUA\r\n3k+ZXVssG5yObjbuyybHKu+d7wA581yhd9s=\r\n=dyPL\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"524e5a0e5ddbd00fa78c0464001b42d406634b02","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","itty-router":"3.0.8","@whatwg-node/fetch":"0.5.3","@whatwg-node/server":"0.5.0-alpha-20221220145232-524e5a0"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.0.1-alpha-20221220145232-524e5a0_1671547968546_0.5457335546651501","host":"s3://npm-registry-packages"}},"0.0.1-alpha-20221221152949-1840032":{"name":"@whatwg-node/router","version":"0.0.1-alpha-20221221152949-1840032","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.0.1-alpha-20221221152949-1840032","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"2528e4efae18a6e85e0c840d788b107b985a26bb","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.0.1-alpha-20221221152949-1840032.tgz","fileCount":6,"integrity":"sha512-TnEjD62nu9sn/TDN4M7kyRDNI/Yrt1pv6oQpYaMr3sKUCTbg4jAU74tgfPLwOGtitbOEpxVUxJQXmkfR2VY13g==","signatures":[{"sig":"MEUCIQC/OLcPrAwpYta+WkrWdhJ1QhuvPEFu+a0YU5x2iF+GXwIgLH0DByGB+6afEXEt0VkoLmp2zTgYpHOO667Wl9QRBoY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5008,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjoyZ6ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmo46w//dM1TcPqcg1FFciBGHLBKorNhnb2lSGjCYOtQcn4uI4WK/c8B\r\nkXN29LTYosIkeT+QCTKtG43i/TM2vFD6u2tfB5ZaLTJkeInwjcyfKuqRFspH\r\n97X+ElbX8O6ntMcccVxghM079XceciPWU2UIy5fgA2ypY7BCgmYL5nONWctt\r\nOrJHCrNOVnj3HKNLXBhuX1EtciSId7O69yJebqDMb4UH9ljNobdfYA7YDjDE\r\ninojhRN413tW7RT3sJzi5AcZqUxlboPDCvnPvpMqYKaf4a0nLVo0S/0OXD41\r\nmi/NGlW2/D95lVSC9rzWWSNvpg9AyOcgxc7t+Q2UCRHBxsMjfeuMDSe/2ke9\r\njM35wSZYWwv1X7+E/5BbntiEAiItfnrzvPeaT26RVsreYL8X8ovtDtdHfNv4\r\n+/07J6M/2otg/J63IHjVgmf5nDbyVbo304PFAGO5SRPNVAqf78xgZgCmHW0t\r\nHHdkFfrabeEQF5LfhhXbmcYH6l/GKzf5AC55b6JTCME8kqEWr7EZLyJUwSz3\r\n4CZUCtQG3XTTwBqKYFWM2VEYJs3YMyBP4SWyQHAO9bHUg53KPNReLQ7eSdqe\r\nO+JHnfcHT0MhvKgGEC8+b9zunQfKHs83+391MIK2OKfMQtrCb+UgYKXnxXNB\r\npxFcnFVu31fyT7Kke4gCxoCYLAOOSffEe8w=\r\n=m7fc\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"1840032dc1d8f3cfef1949e864124d731f28498b","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","itty-router":"3.0.8","@whatwg-node/fetch":"0.5.3","@whatwg-node/server":"0.5.0-alpha-20221221152949-1840032"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.0.1-alpha-20221221152949-1840032_1671636601728_0.5147738522178829","host":"s3://npm-registry-packages"}},"0.0.1-alpha-20221221153028-3a6ed6e":{"name":"@whatwg-node/router","version":"0.0.1-alpha-20221221153028-3a6ed6e","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.0.1-alpha-20221221153028-3a6ed6e","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"4463c584cba1a30e4b172f212b65bb09118c0965","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.0.1-alpha-20221221153028-3a6ed6e.tgz","fileCount":6,"integrity":"sha512-f8KH8D34LyErAdxgapD3ZdyycCo7i+PZA/kJRi5aDEqfQFgtpFH0GAoTDt+nFlYlW0kT4BjsBFdjAF9UAK0+Ig==","signatures":[{"sig":"MEUCIBE5CFXtAaiEadTvYdJgFwHI3BKUjKW/yO3OCMMOubXlAiEAq+GkFApoSr8kt3PAysQxsBIlDgHFZDXP7mQ0CqqkGIw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5008,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjoyakACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmr+3hAAg8aO9muODibXWJc8chAAjkDFRQzOgN551TaDzxljZ76XjGfK\r\nro3c+79eGkWAbq4jEgvcLyoLwYT+zBh4Aj0FbY6ILWOg5+1fx+zwoAh90xwX\r\npS/9eI+bWVu0v5C41phcm/XMZ2C0JtudhOQTW0Dys2kw81NvJHESsnakmlyM\r\noeSN36pTQXnfjqHYOvAirldlHMH9AF/bTbacackV586p4X2Gp/peH9osp5Q4\r\nTOOCm6IlZBrwb8aAxUvzJpzm+Sm5LF4/8IbRE0iqSoyvyowHLnWO+erUqNKp\r\nGa/AI8UcTfTR1Jn3bKBN18QT7zU7P9yp/k4yWJ12e33lIp1lcFKGQbua+ku5\r\nsjzpF1AxSTAiCQx9ghV21l3cFMZkvlKxXe9tcI436P+TfatEXrknoK12q5DT\r\nTOeDhHJ5X/I/vxjugrNHiIbylMUDEd07dE3qF6UvX2SbnhdPlzFGrAHgotQU\r\nHv5xWjek6i6oeX2QC1gdDgftBsJojGWaMT085vwyK4LFvb9qXYX/gGaDdLve\r\nWs9gkmF+u9kD7dBJiZ+m3UXk3tRsLQIUQAXwJEszy9QlNTt8E0b00S1zwSsr\r\n3pX1vJtNagf0h+plLAAoNn1qn4SpnM/MCBnYWMFdeBX1GFrr074N9ziCxNob\r\nShgb6IxLQ/G7do5gHPwROwLGk2oWWqIf+HE=\r\n=9SR7\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"3a6ed6ee7bf1cd438d83414484743dc9935ae4a8","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","itty-router":"3.0.8","@whatwg-node/fetch":"0.5.3","@whatwg-node/server":"0.5.0-alpha-20221221153028-3a6ed6e"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.0.1-alpha-20221221153028-3a6ed6e_1671636644631_0.25952857946586705","host":"s3://npm-registry-packages"}},"0.0.1-alpha-20221221160202-c5565ed":{"name":"@whatwg-node/router","version":"0.0.1-alpha-20221221160202-c5565ed","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.0.1-alpha-20221221160202-c5565ed","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"9ed91aa3cd7f87d302e992cd049b3ca327773ccf","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.0.1-alpha-20221221160202-c5565ed.tgz","fileCount":6,"integrity":"sha512-qTFkA+QTGU8n7B6EMeI/r1kiRFe2enPzrWrJS2SOy4EtLBwMyGsMH+YqFzaGMdEFLQzfz6j7LS7zLcA//V33Mw==","signatures":[{"sig":"MEQCIHBE0TscgLGlpc3vc9RrlfoM5OG1W1bxNa47p/yKvP1yAiAXQFfjzoP89XM7nccUIf71OKHsMr2h2xRUb559EpUDfw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5037,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjoy4JACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqXBA//biwyw9/rrchTMV+WheJWNCEfouISey4YkhAx2q4b5kIQVyUp\r\noBOyyTOE/3iOjWJ1ShKoAny85i/Qyia+KCWrsleigAJRHm3D27ylCWiN7+/b\r\n1k6PL3qmnOBYdkrzMZri83DMfLtR/oIvBS7fmNvGvf0cog9a7ltLaBFIy8re\r\nqCLmWIH03BmN/sq0vPm/K4v5Tq/C8ogWi12LMUxe/MQHR3lbKWkVKOwovUF0\r\nh6ZMpXsoSQ2A7NuD0ZsA7SO/mO6xa8uxv+rdeFKA606RydXFIuOVT7Ok5r8R\r\nz/JLWC6HsW3fV27N0iD3vmyKXiaMEtpXqFktuK0x7QmnDj58n15Ox+FHkzdY\r\nRz3338TMhKhnyRBEjXp0iCuObO2u4THLAS/YNu7vq0rdi+zEJiv5VK6K3W7v\r\n45svbQM09SWcETpgI3DH4a4z0+nFL+6esh2SoIRGo2N6vsgYWCnZcWvI28Qy\r\nuo2WOZNUr1mIIt0SHFJdWmHEb8nAxIiI5vapYUHAusbJaYaQYp5Wrn0MMfLP\r\nWfMC977jn2LZGHcdx2q0YLoIOMq4Al1YMoBhujyBNhtKoiptIBJeRWOdSRkr\r\nPvKVLmpfHzgfYMpuDAb3ToOyyCCWDoYstUIHOXWxU/goVjQ0C4w201uPhNd0\r\ntz6m20FtEsT4lCGymnTYhol7eVmHcX28jQI=\r\n=x6Ju\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"c5565ede8d582f92cec023eeaa4c1027678aa148","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","itty-router":"3.0.8","@whatwg-node/fetch":"0.5.3","@whatwg-node/server":"0.5.0-alpha-20221221160202-c5565ed"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.0.1-alpha-20221221160202-c5565ed_1671638537096_0.4505807720133028","host":"s3://npm-registry-packages"}},"0.0.1-alpha-20221225150206-ee1c0c8":{"name":"@whatwg-node/router","version":"0.0.1-alpha-20221225150206-ee1c0c8","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.0.1-alpha-20221225150206-ee1c0c8","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"7bfed3d2521a7063f86b34ba5f253c3dcffb1341","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.0.1-alpha-20221225150206-ee1c0c8.tgz","fileCount":6,"integrity":"sha512-kN0tXXSH1dZkb/gaTiu/kCftcnebbBd1Fq4wKLADWp1ziVUuUB9FARK+oaCvgrXJ6ngORH8AyqZVDJGTek91qA==","signatures":[{"sig":"MEQCIE/NcuPwbOX1EV8JifFnkye7gZIc+qmdHeJ+TYTTriQUAiAu1tkZkJG/f35J3/PwGqYtrMPUKaiuxiqNc1lRGihFDQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5037,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjqGX8ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpZJRAAnyzjAdSfi80KzeMSrieARArxNJKUrwbkOrDKCDAjMD1ZPqxA\r\nV/ReX/ZceY4y7KyBY8Q4B2f6+0RF9UCUe8nIusGo/Kz3F2BJR08p2Zg/EQgZ\r\nXhlst0hMHD1aeVBmLErIfO2CdyW76ekc80GmnXaOgLhZS8cXCks01jArP49J\r\nDCvDx3ON9eBOOHUBVEGvJN9XaFl+T3yjtTn0iIN/gbEY4jILuPc1waifsLVt\r\nxDysREJ90zJlZnGmaJJ7J4p07n0BJ1gWBiB0OsHIO5iUAVXxM1Gv3uURSJ5e\r\nJ1iG0ntUW4YVj9YUgLvcq6wHgBVfao3eEeIBqtWDgts7/zMs7LQKzjqlB3ta\r\nj7sdj5kzrrbURaHdOOb5oNiWCeL0YdJlXzMI37Sdd8IogUZz9ALbQnlUWgAv\r\nB+OLL6XjWJ4OAc4QuMnxRXWnwPFk0iM1StIdFRYpU7/X/Y0TJun4Cvb37zxX\r\n1+TC9lDRL1EAMVjNe+n2dqzhmChuSqMeqVF/2ZITAaCFuycURDx/19aoYPOG\r\n/Lqga+RRZOdx6Y4S3neeboH9yC/750ClLIZYAxAztCJgW5MAYJ+JK65mKzgs\r\nuriy1Tf7XLVJclW5Bfv8C6qC8kEHloef8/efuECB03/TJ25qW15tuay0PcYA\r\nA0pYMoDogtpaZPpPzdBysHGqAhld4hEojXc=\r\n=+qnP\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"ee1c0c833250fb4d3ffc38772425c4460e630239","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","itty-router":"3.0.8","@whatwg-node/fetch":"0.5.3","@whatwg-node/server":"0.5.0-alpha-20221225150206-ee1c0c8"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.0.1-alpha-20221225150206-ee1c0c8_1671980540406_0.08165813309395986","host":"s3://npm-registry-packages"}},"0.0.1-alpha-20221225150335-6bbf958":{"name":"@whatwg-node/router","version":"0.0.1-alpha-20221225150335-6bbf958","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.0.1-alpha-20221225150335-6bbf958","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"f33685307b6416f77ce0171d00cc73e31c023900","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.0.1-alpha-20221225150335-6bbf958.tgz","fileCount":6,"integrity":"sha512-o2FzZFzdNo4QMNOhvtrSyOIsTTYC6MPxrI5YK9A+Mgi59F5bkyShGOoiUHxYRvAME2n6pjpwHvqQOF6lgQpfOw==","signatures":[{"sig":"MEYCIQD/ruApgRwnYcAlmoN75UOmXl4gJtTSI9NidP2qimlmVgIhAMr/kOQdvM+aZ/1XkHCQukROfOptYjlXEHjAOSxDPCvU","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5037,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjqGZTACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqVgw/8CjHYeHpCoUQ4OkbC3NOuehGrzy8UjjU2vDW1+G77NKM3nbL5\r\nQ/G+HRLsq5WGESSjq7nCJz4OMEeiIqP30mN40Xl8Z3QndaFxPi5OYqaTBiar\r\n2L6AN7/P8muskdgi0z7i3c229M7dTL7XJ7sCOlYmdhnzHmJmgsrU0S4w5gb/\r\nHMGrwQgYl49T2utAq9qxB+pqix62XWen8k5DAiFQHO2ImAwtRG+I1rOeEFOu\r\n0fmc5McZoZObN2jB0d+pTxQ+oYb0clNM9gHLgVdH7Z9+F8xqdxsyP+yNDn2H\r\nBwnMhhS8gCj1cM2IBw5M2tzTho/iKkEYo5KPoDQ0n0iKby9HJv26c5ORTkAp\r\nAmNiPOgEZGKhCSCllofmTIZAIUfosOKzjo3so0q3TPzBSX6tx+4yMfkevqRS\r\nyoslB+DIddKfmSb2SXG+Pd8JWXIhk5pX8wcRpdc0Tx+fdr82oxJ6l0cheYkt\r\nNczn6UVHz3v27iJieSBeOPliIlyVA1+oBXv8Z8mX2boqVChA2w/Z+Elrpic3\r\nby4tZBbPhMGqPD33TpvpQE95xbX9jIl9/XZab1UZjROxB9pINjqxBTDRdv7j\r\nreoAKAOmlm9HTRAvQwM1YZAIAH60TdFbMdX+zCNiNCo1IkMQoYkYFp1a1lw/\r\nB+NSpgUvGVYEUagv2NzDIG/A/JStKmP026s=\r\n=COq4\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"6bbf9586314fbddd0a8ce03c61417d9e90cd0988","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","itty-router":"3.0.8","@whatwg-node/fetch":"0.5.3","@whatwg-node/server":"0.5.0-alpha-20221225150335-6bbf958"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.0.1-alpha-20221225150335-6bbf958_1671980627738_0.6946307066702322","host":"s3://npm-registry-packages"}},"0.0.1-alpha-20221225155445-dfcb269":{"name":"@whatwg-node/router","version":"0.0.1-alpha-20221225155445-dfcb269","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.0.1-alpha-20221225155445-dfcb269","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"80d7eb02f120ca38054a1e8ffb9cc170736a7572","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.0.1-alpha-20221225155445-dfcb269.tgz","fileCount":6,"integrity":"sha512-l54HF0csqaKle8Rw877DdaPpaklfqqgio6Eh3Rhp1GVN9fX94H1aGuhy1NkcIdC+aGsEuycDrohXay6ZWik0ng==","signatures":[{"sig":"MEQCIG2GvP3gBKUPhfqCpPZTOMCwzZkdHiR5+iP96AIsfweuAiBN1tFkmZQmnISylaA46VayCWLgerwwB3FTwBtUESsCSA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5066,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjqHJRACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpY7w/+PhjCC6MdbxFHnp3p73IIn2nPs4Ar6F0u4sXed/L5zfm0dpxc\r\n9ozGMbllnCBGzyF7SWz4UHlXNiTSPTazFy9rwuHzyeTdhKdS8dBIWfHpa/k8\r\n0d14MXoWDhxuTMuduHWe4jTGUvAtUrSrT5L/HHNGM6SNJd7xU2regJZf+rki\r\nCUobwDtc5ies6n5QGpHYWCYJksnYp6Sa+RvbpqiDBHNN5QoKCFdy/ESeuZ62\r\nAMiQI0DxeXExMvMPzhxaq5pBxLFP9Bk0r+Mt7dKI4DXFGiHdWFsWp8EoGXPr\r\n6KdwfWkDjijbNGjfldgabza7VphACjHlHydMg1w7ko2QXVkUI+VCajikFd2d\r\nOu4ZZ39LcihbFEn7mxLXfrO2QJoKcWOyjBRh8L6p5DUxMLlNPi+VxDHREElL\r\njJ13NDUHtH6ggmKiS/e077jGZI27xMTYZs6p/mR2dQ5WAHNvrWsYwARKkfkl\r\nANX5Z0mo974aazahDQZy1Qn6dZYYeav4+deA+VdEcXSYKc2seYrN9w7XF3fy\r\n//MFH0cf5op/fj9lwy+/Sv0NygrTL8ey6X8AmKfDIBuub7GCaBkKlgatNEtr\r\nXRnnm3/CBruU9JPTDTJ95uHSsc9ZBn92nWl5Piyba/lMfEg8tkYJiv8jmWES\r\nS2BX6T2/ZeEaD6UU30rZ8JtqoGAcna7hFDs=\r\n=CVny\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"dfcb269b50f5b9ada214483104ee3159d0544dc3","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","itty-router":"3.0.8","@whatwg-node/fetch":"0.5.4-alpha-20221225155445-dfcb269","@whatwg-node/server":"0.5.0-alpha-20221225155445-dfcb269"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.0.1-alpha-20221225155445-dfcb269_1671983697760_0.6738747910375773","host":"s3://npm-registry-packages"}},"0.0.1-alpha-20221225155816-6b54cb4":{"name":"@whatwg-node/router","version":"0.0.1-alpha-20221225155816-6b54cb4","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.0.1-alpha-20221225155816-6b54cb4","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"599f45b981059615b7d0b3761136858200c7845b","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.0.1-alpha-20221225155816-6b54cb4.tgz","fileCount":6,"integrity":"sha512-nZDY0tNY+QS3MFJ8nGVona1xHrftitpQNv+Dc5mt+4Vk9gwmBIOWDUEqS8wf5IToi/xpn71Oog9TfZa0odCMcw==","signatures":[{"sig":"MEQCIBMDouMeMW+aG1O+UWnf6dZixZ1QUHrXUA8BZNodps16AiBb7ZfnaAh+OBJgZAfSl8GIfRkM0f9A8Dyhq0Z1ianGPQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5066,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjqHMmACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrskQ/9EQB4XbUHr6No/WHyFS1+P6hJLmz5bfNkYAIXPWia44ftaCcw\r\n6qeThCm0UMMydshxMhTwo7kiNvtqykLOUDB5mErmUrQppo/Mp6EidP3SwYW6\r\nUTfWzo9cc+3lI2zhtjxgn99B+GXWvOl4V5v/Pu8nf5VX/stnbQd0CWj7vTZ/\r\nYJsYK0HXsEEkWHY8ieElUC2mNhXdariG5QXcIVbRDUwvb5gKUwts5WbVZtHD\r\ny/zk+10Ef2s1pzFqgGluLwFsgeVEOWRT6MRHRYG5H5aNGJqDIRzW+zWr77Uc\r\nBR5snmW4l82HfmkT4P5r7GKatVfPQ5kV7QsMHapUu7Osw4B5xFjFZ6Kkhd81\r\nZTkWGNT+bOHTB/f6REMWMszfCevd9EE6fIhZHsfsEmZYE49v7vGWrCBWb+hk\r\nvFkmOpHJL3ppDFvxLGqOhsK8I57+64PLiOyhmp213nhMEcM5unPM2saVIJpb\r\nlrQUJ0GCb1jTTNoemWPg1xOD4OqXsECz60R0Hzvo+On6+/lpRWrXwzjU6U/V\r\ngdQWnaRhhKSDopl2cuWLWCg1kif/+zHkY7jyc9ruo8Gqp/IYU0LhDiAzMMCW\r\nygQBl0N8lH6MYie06OkDlAKML2bamPyX8po2JrpbIG+KcKzhAF7CRMyo3G0+\r\n7VVI5i+2nHxwedWiPoXYC4Q9tsx51joGcYA=\r\n=WTnv\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"6b54cb4e65a6460e381786f487e7d5221c891b78","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","itty-router":"3.0.8","@whatwg-node/fetch":"0.5.4-alpha-20221225155816-6b54cb4","@whatwg-node/server":"0.5.0-alpha-20221225155816-6b54cb4"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.0.1-alpha-20221225155816-6b54cb4_1671983910683_0.4579760958874468","host":"s3://npm-registry-packages"}},"0.0.1-alpha-20221225160212-6d4b104":{"name":"@whatwg-node/router","version":"0.0.1-alpha-20221225160212-6d4b104","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.0.1-alpha-20221225160212-6d4b104","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"3c8d8b8cdceb8446cff6764c9744cbd585265430","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.0.1-alpha-20221225160212-6d4b104.tgz","fileCount":6,"integrity":"sha512-PD0644YJpDbIjOIHZ/Lzr0Kz0qzvnCjZ84XqkiJU+YAks5ZAX1SQYlxL4B71U50F4caGmZ40Q/qQnP28tBTV8A==","signatures":[{"sig":"MEQCIBzOXlkWxw2hERci1n9qttBljyWiaWlxkxRCe5MXi+Z2AiA6p7GHDPVBlCXO78N+rALyMps1/VjeoiZ1PhWI9L5bUQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5066,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjqHQRACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmr2Rw//bIfbzID53SfZNr8Gf21y0vXbzA+m/6c2nsHa0shkufjzYzpG\r\neVCLmBwNhJ4v4NZjCmJu9nxjKcLN1f5UuBzH6njmufpAEn+oQhVxCu7ACyyz\r\n4rQXAqDV4UE0tR1Il6P0BJKtGyvRrzmK6MIVD9+M+GtLKgWQWOMbqwIGkfz4\r\nX4hWD9PHPRdnb86Nys2Oqqa0pBDHf2ndMs5orlwD1bNwGVZzMd3uiI2UgALQ\r\nd3HXhWWW2vDvU0pAWOnnfAY5IM8ZcRNxdnT/O/T5xXPSFYc7ZKhsKKVo+AFH\r\nY2e0Au52O4hdSqFGOPpPvlqpyfo0J+6uOXx2n85uOpPRuVwM3fOALWxhZnqK\r\njsHTcz2+2b72x+4862IjmLtdBGl07OME3+rCn6F6jZmrOohkt7MsBxb94Ixw\r\nZzAhgfk4I02BXcIPL9cAVvfLKrCFX/qfZHe0pGVzjEsGka9EfWWstbSpzJvy\r\nIoVlf8co4YwvI4ZiCFxPgqut+E3XpFwU3Ps7BhTFrL9C5nFEmpojMfN9Bf5e\r\n5zCmr2eOZrZyn8HK5e/XButAG5jmd6hg3SbdJMXYy8OwxJeYEHnJIjyb5+ys\r\nSNlaNUZuJgVOYeVsAQcqR0UNk+2v5vJdPnZU4S5QthdRy/XeeL5TdqvWe4oH\r\nebne6HeJdq0GwzJxshIpjN+pwbQ5g/MsYLI=\r\n=QlDU\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"6d4b104496165f56e8e8a5b724b6e975a600b626","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","itty-router":"3.0.8","@whatwg-node/fetch":"0.5.4-alpha-20221225160212-6d4b104","@whatwg-node/server":"0.5.0-alpha-20221225160212-6d4b104"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.0.1-alpha-20221225160212-6d4b104_1671984145671_0.05069657824453855","host":"s3://npm-registry-packages"}},"0.0.1-alpha-20221225160313-0935cfd":{"name":"@whatwg-node/router","version":"0.0.1-alpha-20221225160313-0935cfd","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.0.1-alpha-20221225160313-0935cfd","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"c10e05741ba4738422914316338ef7ea941ddc95","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.0.1-alpha-20221225160313-0935cfd.tgz","fileCount":6,"integrity":"sha512-tqvTC+eLP3eO0Ayu3g9jL/b2yI1vzoIHuVNqHXuCnJaXfXzvR//pXNbue8tYpGfrqNwbDu1icIIQ1rKulDQRkg==","signatures":[{"sig":"MEQCIDfUh8dHtxI18aIGSy0L5E/Xk21fPDfACEA8jtxi5pgjAiAkequnlhSYooqRAsKWG7yn4n+basqK26y/D08JejNc0A==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5066,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjqHRTACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmq3fg/9GgJO6C1dSqtsZA5UKmFLzibSHFc+hNE8nl0cSdmeWnokrVqv\r\n42l469gIIR2p+D1AZvvRdEt68lVl5XQTBaZoTa3rBlgpk7rsJzyUJVUvaX3y\r\nHw1cK+2BAsU707pK2DjEpw0W42L1vXQiQj8Aoyd2hXVhQJ4tmCv34izAG4Og\r\nLqiMECO4/hzkzAUr/AIeNHopuXdVCNNAy7fMy6mHPK98+Nq7ZAM3EEugq7yv\r\n2xI3vM8S6lS5zGmog7T2b8m3ZhgSUUZ40IJ0LdDHlMoaWPYEnTi4jVJ9Hz8d\r\n2ORjjeFR8WJrqiFsZU2wOPaIYxvEYTpV5zKVBJ+ojKENHEYGNX2+8kcJfINw\r\ndVPjJAJTPrWgBSZOJrMkTtMxwrnsuiwhxUXIY2FrAEnateHQLegwHU/qmR63\r\nXMw7vTcCfzDnDRFlMo2PWwm/3DPxCC0gy0EDG2g/RgQ+4u1VGIurJlc91dcW\r\ntNHfzc9C+apmnlYM4noXERJ+NbLcUgRUaJx3zI/uVTI81iUnFiw8rK+s8q4R\r\ncs2XA7TkaUYkcvEIxiQED3JRg4MNTeKhGsQ5w3NzM46hsrBtMw7gpGEGYpHA\r\nhHCHp+ZEcjeOEE8Kif27FXPHaCaEmOwHBttHPejL+7YPkF9ujTJQiRjtnmda\r\nBx+nPTmql61ZL+t7hUgABuDIPeQjXUYqRnA=\r\n=EEib\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"0935cfd8b53f70bb8661d5b77c833c44f54723e4","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","itty-router":"3.0.8","@whatwg-node/fetch":"0.5.4-alpha-20221225160313-0935cfd","@whatwg-node/server":"0.5.0-alpha-20221225160313-0935cfd"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.0.1-alpha-20221225160313-0935cfd_1671984211498_0.6611988836584719","host":"s3://npm-registry-packages"}},"0.0.1-alpha-20221225172458-8684a84":{"name":"@whatwg-node/router","version":"0.0.1-alpha-20221225172458-8684a84","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.0.1-alpha-20221225172458-8684a84","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"f2ff2cfc8e0c1c0b79f91be2dbe52eee6e899725","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.0.1-alpha-20221225172458-8684a84.tgz","fileCount":6,"integrity":"sha512-Y7xrIh5/LgDmc80ILPa3cZmrmbCP3NZUmqsgHqy5Roz9LeHu7nM9IpzM/79O4/yawINHyu6p+Lh1wBylrZmvUw==","signatures":[{"sig":"MEYCIQDFYdRBwek/AeG3OAJ79uq43g7OdREoaJUZize6zUwc4QIhANUhntIGuGPq3NoQO3wvG7WQPWnJwLCbvz37kp+N9u67","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5066,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjqId4ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmq59w//UGQ9phwVbyEsowwj6scF10FWEHyaVxX7Ey77fDPyJWgwNZCx\r\nrhlgR6l9JgS9ApoUseGhUe6ik6cNBuROdkCUCZNx1VPEcjLRtiiTjNFIndH2\r\nFpSuPIgsBgSwiQoCEU6YVFVi2Fx1BpJZ/hK6OCfqgXnTXqCbMkHr080xzNgK\r\nOzj8tvCWVynD3YyF5P9d1VfuCuPc2AuwlNaH9tWsp71ZEcgQFs2Yo8IES/y/\r\niJxRRq0uLKVgV2XCaiXGK/GCvhald1AAU1SLFh1CopzvduqM2e3n1/tvcUhV\r\nWFVPDEuEehAtOvsDLHO3fTwAeaHrnnADOE01NqcJsWk/6YRVnAN2UYRdVBw2\r\nzGbgXPX+TBV7RBFkfy1JlqzgceFHGvj5VFtdcu3rcSIaS2Xsu5UzUl4v9uNg\r\nqF+J67G3sKS1SVbnmGqhEa5yOEkxf4LC1IWL/qS39P8SAGQLdgveecPgWHn7\r\ng3I6Ce6lls/Rf/mypAqWgUBhWnjKR8RhESGXOlCWp0XwKj6QuEx3CgSpTTXl\r\nvXJ/C+/WfadteCXmz02Ykm/RwRvzc9UNkaR5yJigngP7+JNZ5mGut7fEIjaM\r\ndqUZAvQkCNyX8cjkEWcm9MDNA8nqMM8Vv07K8IsJArLEExImFIO1nrfdpkZw\r\nTXpUuo09cso6Yeg6hAzq/2b8zu4E2S85jbs=\r\n=nrXT\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"8684a84c328fc7cf5c0c6cc3811fd7e7f55d2cc8","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","itty-router":"3.0.8","@whatwg-node/fetch":"0.5.4-alpha-20221225172458-8684a84","@whatwg-node/server":"0.5.0-alpha-20221225172458-8684a84"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.0.1-alpha-20221225172458-8684a84_1671989112362_0.9107784568326247","host":"s3://npm-registry-packages"}},"0.0.1-alpha-20221225173053-f9310f6":{"name":"@whatwg-node/router","version":"0.0.1-alpha-20221225173053-f9310f6","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.0.1-alpha-20221225173053-f9310f6","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"b39b7681b961676f14a55371da94c3e744466f9f","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.0.1-alpha-20221225173053-f9310f6.tgz","fileCount":6,"integrity":"sha512-ehSQECTdQemv/vIe29wKnCY4kx1v4mAr8BfGGIILZqlqOoBgKsD3I0/kL8dLdQK1cv0ZjYiLeatlN3Tg3JnlaQ==","signatures":[{"sig":"MEUCIARpD7UgHGvR2tAeROr8ieVvN3n1WpwfRZqb38xwtujgAiEAiGpzEhUee2dFZj7lnKvXFP4aYMKdsv9XrWEPbpknNH8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5066,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjqIjcACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrkYw/+Nq8jI4i1gJbJkXHUDlM/xsYs9iJpzoogXyRREDscHVyLuc8e\r\nQa6MQ8g7eso2GWVu2nLkHLoVM53X4gPyURMXhCk8FQymqg20eP0xYNPigX7G\r\nU4JWcsSagBpBWryU77AQjp4YXzhcYThHGGqn0gckDhCHiRdgsql2MORQhCVR\r\nPPCAXkSrAUilLiA85zgEC3o5UzgMJqbyfNliQcwMdMlr6DkgNoIR/wWMaDwz\r\noRkGsX0ACwfE3r8XEFEhgcF+NtEhXaDNZ1mjbKt0EuI5HkzOMGZzmAaQtZif\r\nArXVTDiaUwZfy5DqPQGN3fjuhTK1SfY4F2nZiZ2g/VxstVUXJ+kLxeGoKJny\r\n1tuWtvRduoRA5VXX/dEMwaCYRGnX7gmF/R4KY0yPoKeTUAX9oRcjEpMK9Q7U\r\nERec0wMco3aAqNkA3plfuqLW4/dgGkHnWr+9iRlPjJ8REdLXydDYhaF/QBfG\r\nFvOWIqGOvZQ12nQfsUxPUV6h5TnU/YO8IPcWjMTAPmmHG8Ks31GiYkbihgU4\r\nRsVU8yGdmXr9oXO2qQ72t/gctpoFKwDo1iYEExdyRUmfhVEIHSVbVVtafjzo\r\n2KfQhJf8VGv1aIL7uS7iXyMHhVuu5n1bbO2HjY2dF60NBV/9fkVPcP5yim46\r\nGQpoyajirvv0wLOWjUKduIG3y24CorIBt/w=\r\n=uMy0\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"f9310f6ab06681871f2e17871c791611ca4344fb","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","itty-router":"3.0.8","@whatwg-node/fetch":"0.5.4-alpha-20221225173053-f9310f6","@whatwg-node/server":"0.5.0-alpha-20221225173053-f9310f6"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.0.1-alpha-20221225173053-f9310f6_1671989467940_0.7509511209385513","host":"s3://npm-registry-packages"}},"0.0.1-alpha-20221225175918-b8ec28d":{"name":"@whatwg-node/router","version":"0.0.1-alpha-20221225175918-b8ec28d","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.0.1-alpha-20221225175918-b8ec28d","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"0ee4317b5a2eeee483735e6f1293dcad220763b4","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.0.1-alpha-20221225175918-b8ec28d.tgz","fileCount":6,"integrity":"sha512-ry/VIYT3S3aVAy4vm6ksLstqTV3x7zsYMFxy9vPnLpqgwOjQbIi/6tGmxRtOQaQVyFqoqJE7jaVAfO88Lx/9DA==","signatures":[{"sig":"MEQCICXJs+1ifs/YheQMlffBvLJMmTkS2V2z0Rv7HTUhbUTgAiAjWdFfTpJBC7z66CGoxkhFdMiTQ3aaVE5195fo7vb3+w==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5066,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjqI+EACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoKuQ//Q/xOb2qPf3llZQWQzRZ6GAsGBqmCC80Wo7Fc5mMGXDbwA/xo\r\nqykxVcD0XvHkH3Wr+Zh+jW1i/J1XleT+BO2VQa81VnUUU4ytLEvo4/jFq+gw\r\n4OJdJIJzD7c2H2V91of3b8ZXCvH0kc+teRcUnVcVCoHZtNQsjuUpjP/CXJMN\r\nBf8I4RFHXC5qkDob5PLXtpFnCuaSj96LLUCd1c/yoPvX9JFfhicBWYlNWe5v\r\n/tp5q5HvdHAMGk7TDTIZd1NU50eL6qu/j6pQ1s5D9u9dZckF7+dYY5V8TAA/\r\n74mpnN/D8RPQTrZMrJIT/tGYycc2Uy6JXeCk20ZCxpY85uROofy4xgvgzhHI\r\nVqHwRC4AEdn+77HrqsZ26PsUUxliBpHzMRXnefoVVs6JrcXnHFyMk9N0VHxP\r\n5aOlY4IYO7Y/1nicHPYHh2erRFiEXhkLdt5ZyUUkipyr2l/C5KilrTs5HjRa\r\nC3i6oALZCWezWYX3uenyBEGLD7xbbRKazZd0+Rr4IJxVnPhx3wDhA825Ayn2\r\noGpgYS9NS19PEpN0eRSVFv8FSiBDHb+W4eLFrBqBSi2TRmIvPFIza7AJaTSK\r\nYxLqnbVKBZgbaY+8y15vcQLjXRal+tqkHFe+aKXkUQu8SXw/VUtkZhcFHEgE\r\nOStMKrmAXrMEZIlBlI3IGZlpqoB66dCmhfM=\r\n=8d9Y\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"b8ec28d693963708d091c75c581acf8966230459","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","itty-router":"3.0.8","@whatwg-node/fetch":"0.5.4-alpha-20221225175918-b8ec28d","@whatwg-node/server":"0.5.0-alpha-20221225175918-b8ec28d"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.0.1-alpha-20221225175918-b8ec28d_1671991171834_0.06369047020157725","host":"s3://npm-registry-packages"}},"0.0.1-alpha-20221225203520-794aee0":{"name":"@whatwg-node/router","version":"0.0.1-alpha-20221225203520-794aee0","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.0.1-alpha-20221225203520-794aee0","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"e78ec552cea9f6a031c63877403d0e97fa32b0f5","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.0.1-alpha-20221225203520-794aee0.tgz","fileCount":6,"integrity":"sha512-uHAioeQrpLzmysrE0UsJy3J97Trp8udLPO1z4n5ncYnAgMv6n0EuvdynwJjcFKqhkdBDQOcVRskJ76ay6RskNg==","signatures":[{"sig":"MEUCIQCNMF6aCOwmDwHdASnzO+pFOKCOXZsi0hhvGm/AsPZugwIgIUK6mAEJ61ZtwfWujz8ULWI5BpnDeB79G6ZjGuSFSYM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5038,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjqLQVACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmpugg/+NJ26/F0q0ghhAj5lwpWafwAQXtxcNgZPPi/LzmjLIPGx51di\r\n69EyAnD3IhSJO8Sxhm3BlGAIoSSH72QVsG1ogkGYBM+JuEax338hUK2xJvI7\r\nWSlhC4rfmv43A2GypRZEKm8qgUVN5mRZ0IbUfO/hDmwm9Axoj5jS/pqmXLWM\r\nywUlhKy6tOrS2Vv0FNf+9N1+aDo93DfnKfPv0l5yAVEHxXdyjtn3IY9K9WZF\r\nrUgPPbuvJF67lrQgygfsiertrqaEPAZlV/KwJeLRWvpZEBIGxbuKdCqOP2jJ\r\nm1m/S87RnMMTR9kooRvGDgKPvTb+w83jEuF36j15vdU94xdLMFrpji0A2AEf\r\ntSWpShxiQpd10Zy51QVHhGwBQQ92TZsuOgRuJATViTN7Kkvg0ieWk4S3Swkn\r\n0tQ8r+0SOXpblDhLyEHDEA2VFYUq0cm20UaOM5pQLVzZxi7NPcfluHpDF0C4\r\na5b+ViCvE2zY8+lBlGUSpQPxD11asxhgGse0QrjZ0oBjAT4pDf1UnoFM5rYZ\r\nkNHmTEHjx2MdQnEyLS4GxD08nRp9hcQbPn5Ql3ihjOxWYnWLUZrnfOZCbrvO\r\nk4feXu7L0G+K5GaZSW2GUvmXW+eRNeE+Y4FauSEpmunSmFhraNuiTvLFEZfn\r\naWef/vNAGD87qatRz7SpCa9xpIU5a0ytcwc=\r\n=OG7a\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"794aee0a5f91aa36c6918e24e04dd27389ab6eda","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","itty-router":"3.0.10","@whatwg-node/fetch":"0.5.3","@whatwg-node/server":"0.5.0-alpha-20221225203520-794aee0"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.0.1-alpha-20221225203520-794aee0_1672000532774_0.18987606924634304","host":"s3://npm-registry-packages"}},"0.0.1-alpha-20221225210907-6de9f3a":{"name":"@whatwg-node/router","version":"0.0.1-alpha-20221225210907-6de9f3a","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.0.1-alpha-20221225210907-6de9f3a","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"ba8f5c15e63a568ed1f604890631efdbfe59852e","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.0.1-alpha-20221225210907-6de9f3a.tgz","fileCount":6,"integrity":"sha512-JtwjSWhdMI2uBICjgUx0FSRu1Z+zN5AeLWMVo1zn7PEU7xlQfAwtRXrTRbsN6rYhQIjecU7/UyoElU+b2hS+jg==","signatures":[{"sig":"MEUCIQDJUHLUxyq2oBVwwvHvZS2pVlzcZfB/h9sYfPhr80X77AIgUREqM4obOkdDJbZoqygJLgnGEMVV9s8FULDWQDH8mT0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5038,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjqLwAACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoW0xAAkmPH+vTF3oK0zU04NlCfGcA/Bmw5rdl53CGjpHTzb/QwgK6m\r\nxP5GB4aXsHwW55Mf5RoXBynK7nsbBMfaQF6yY9e3Hk5bP5Nttyr44k/EwYYx\r\nTGj4dK0NR3NjpK3xIBXvLw2IFWTVyyyeVc9+dis7Kh7+xz8mIcqyvGlw75iD\r\n85xrv/95rZTVEJorXGLsRaKWD+6P4R1/jyI3ewu+aAN7xlMf7BVsXvqvvoOG\r\njcaOPwuCcXY9aNNoCWgT/mUMerVN6mSFjfzMtXbugqb8bFKCJz8Jcda8bAmB\r\nJWDbdBbO3ZgX9IY8Lo0Pv2221GahBg+EbcNb90kTDFDKp3EtIvKPFSqmLD8i\r\nqJWgpNOH7t1dxYdZXfduJUShU6I3HgHyG/0kcnB2eaFwbn8QZqse1f0EST1+\r\nWGcwEWyL+zamszyDCNQyOll8mMd0+euOWkhDDCcrAK1gN9wIJ6ukUJXLKumo\r\noeZK+JMW4HDagrQp3ERuS1Bg8lsjJscVWq+vD5nUXRjuj4qrZZ/opL4S7htR\r\nPRudUiEIyFsL65fZEv/VHHAHhkyEbIcFW0QkGsXDkA/78q9ephnm7My5sqi+\r\nfTcFSx7+lF1JTotCkFEFeF95ADFU5qJfPxDVxAGgDeEHP1vFD4tgdRg2EfKj\r\nZ1O6+9q/odFelHA1I+u3A7HGADgicBnxf40=\r\n=qGzN\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"6de9f3af9beac557cc0c8e239a51eff76842c462","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","itty-router":"3.0.10","@whatwg-node/fetch":"0.5.3","@whatwg-node/server":"0.5.0-alpha-20221225210907-6de9f3a"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.0.1-alpha-20221225210907-6de9f3a_1672002560134_0.6507507596048241","host":"s3://npm-registry-packages"}},"0.0.1":{"name":"@whatwg-node/router","version":"0.0.1","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.0.1","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"17058a5a20a3dca4b40dbdfcf0ab4af7158082c0","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.0.1.tgz","fileCount":6,"integrity":"sha512-cqnitDRRd59jwYfoxXP+7+IXNkfQc6cc+DPTN0xrmkNgzAfKRlgFUCONRyi5I1o4/KEjQbEHDHyKG9qyQTWUDg==","signatures":[{"sig":"MEYCIQDIHh+ithtvKyA1K9HkWdTaLigisfw6tXYwY9Vg4rMAfwIhAK5xYc7Q+gvnm0r6xVHyQmmBYOWDU1gDBhq9FPZW4r9+","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":4980,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjqUtEACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmp1KhAAm+5XjbDrWqltR4GfmZt458QlBANs3w7RVtDTBlh2bBvo+OzN\r\n2P1ipjjo7mp/mBXlU8AmJQE598IZxFeCWlcBnh5wJr/PFBP7LjWuBlZcnY3m\r\njN6Z+JLImDdk4kMp8VPOTz00+FtE8V5Jw63MVuq3+WxWN3y+X5AtmeP1azHN\r\ngbLCoxGBFZStLZEgfma+s/Ggg0lcTg5XIEETH2wayDOWqqANbpda7stIUUlf\r\nOhU16ua58T0PFIUPYMbHbaZhZaXOVPIX8S96fZV5tbFcQ+z3jXYBGaMYnaz1\r\n6JsdXWO9xHV+3gnaf/k5P9bcd1P0A7onyngEPfgTmLQAFck15Vlr+bN9hubl\r\nz9Yo7cTxjVE9V9kMVRfyt0wqMRbgAT/jYBgoMvloWLgF+tTtujHxZydMnSXC\r\nlClcXYbCeLCEkKOt9OvzfocfbsTmUz57vE8Xh2H7/rbpopwQCV9Fb1yGuZOR\r\nHfnLH+RFRuMObXGyl7yLD3GpxiM+t3WM7KZbWwgd9xIDxSkoQwqqbEjyZ5lu\r\nf3kRleQrBz2+HdD5HEqlsIQ29B1zSy1Pq3y3F46hiTdqeeXldB0bX14dBeXf\r\n3w4+9ILUrX88y6kWk6CqUZaMNHDYgQ+UqtsO7VddXwL214eAawE8LOj3WaxY\r\noNL77vkI6spsfRvcD0R05kRwXCBKHTHKpwU=\r\n=UeU6\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"37a420b591f5766c03a3fae2878d504b3fe829ab","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","itty-router":"3.0.10","@whatwg-node/fetch":"0.5.3","@whatwg-node/server":"0.5.0"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.0.1_1672039236291_0.3364668266862252","host":"s3://npm-registry-packages"}},"0.0.2-alpha-20221226093125-61200ea":{"name":"@whatwg-node/router","version":"0.0.2-alpha-20221226093125-61200ea","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.0.2-alpha-20221226093125-61200ea","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"6ecf5a02b864924edfd44e6778d2aa90c42f4119","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.0.2-alpha-20221226093125-61200ea.tgz","fileCount":6,"integrity":"sha512-C8WRGon1Jg/3aGy4lyN1XpAAptBz4FMNyvwnMv+ao3NffM/qfYtAyTcb5UJ7us2H5fUXVyDU4vEuELkHjuQSAQ==","signatures":[{"sig":"MEUCIQCkCTh0scmnjP9DRhWw3MI8akRRtcmmW8RT0PkdqzMm3QIgMPE10k61cjUVTUNbdzWJqwYukoQGDl+ezr6Ga4iSqe0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5015,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjqWn6ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqVrRAAoB+H9wqgesPxSyUOR4roiNsCMT+P6YXhiMjk52NYQZ3bqXfu\r\nmZL0T4+yWXhQlBbMbUI+eqiVU0TfzewokxBOChO3zh/rLHMoHHVrptIp/p1R\r\nATnMmAuZah33bU/ZM/BSnbIpoXDL9ql3qZWpVgRFdi1wyeIDZV2ipUeoQQ3Y\r\nb0ns63PIsiQlxsaU6Mk7MaEVTSAlQpojY8hD11fJjnvkVNOxWPtcy/1zODaf\r\nGdnA5qNhQFtdPbRQrVNHb5bp4HUq7JUiNHWnb6YxVj0ivQq8tlTzUFjffG/V\r\n4f0l6TYAWfI0dqQ3y2Ly2ODfIh15VKctRWs5NxB8czDzJJdU1+qWDpFoupd+\r\nYevuOWWuOzPDF+NT+nNjugvLI9GGQB6pQH1Y9TLebdpIdGAjA0C46sF0F5cw\r\nrCZr2i6GdwDAZe2v8cf2qnvn+pTcB+bI1n5/zizjfehIq6v5tKzKsJee+IX8\r\ntPZJQWevQyGWfnKwPFeXnMWAfFL9Y7hEWYtYioPGmjVrBuldAY6IWnpmMzod\r\nc8vkElJCr7s2GzDb6Z872W2M2rdGcUZuA9XDb93jDKs+olwRO4Wb47TGBlqa\r\nvs9Imni+9ozYIJui/erYCuHyyEx+62rf7/Ft1zv6YQCMLucW2r8k+OGe0T6s\r\nOo5kDElJPvIYruWZJogz5EDD9O3oo0XDfaQ=\r\n=CKdZ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"61200eafcc4051d0e268235987617277924199cb","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","itty-router":"3.0.10","@whatwg-node/fetch":"0.5.3","@whatwg-node/server":"0.5.0"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.0.2-alpha-20221226093125-61200ea_1672047098311_0.3882295360246204","host":"s3://npm-registry-packages"}},"0.0.2":{"name":"@whatwg-node/router","version":"0.0.2","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.0.2","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"35dd17d6ff2eaf4cb6a257748c70facacd2aee84","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.0.2.tgz","fileCount":6,"integrity":"sha512-JzL9olhli6mC47Mp4KC+ePhuDvazKZuOYFnvIQZPBocbJYWfzjUHpLzTdAVyGevqgV2n/3zIalKcUMKxVy4pAA==","signatures":[{"sig":"MEYCIQCCqRpiKHVbhd4Ag4utLRDXKgoZ9AhJ/xrP/wf4/2ecOQIhAOh9OB4405aJ2Ew7nYDJLQkwtIqgRBmT4TAJzDbAZnQi","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":4986,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjqWuAACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqP9w//S9xO0dHuxKQcsKceZthltnUvQwYufzbw8wI40Vs+qybyA7Dg\r\nCgmyblSUNeb/tlYnK4Wi/9y3dzpSRupv2/Vdcy7yKbAFqxdI4t9AX3fS9X/s\r\n6ovaAoGoffsJFZeIHsFwpoMAJpGW+SzI24agBridiHdaz3pzmRtAfLjrUSkg\r\ntTi282cmH189AaWZuJYoi1pCH8B2lIDcRo21pYuD7720nhMwQR9NRSmuKeuf\r\nCyqzdESFSE/zpOdxnY55Fz3ZnS1pxWLn4PLUsCMIWMKubGrazi7USOlcYqIA\r\nfgh66Srs6qTNBA+pQp/ZsMT5IE6/9G4YlRH+OoLzOb3kpeciY+cObW2Lm2cP\r\nNP0RwqnQqOrxzGHTYvL6wDHa7ZIeJ9C/QwAqnvWWWGcKe8IrIWVvYKwHMo9a\r\nO7+tU/j+yv3NPcadc8NK233O294NwKDf6Y806bRLZK0Hh7eW+x12IxTrKMGX\r\n8AyfdsFB0gtQkHHzvWJakaz4yhGUnOekcyKSFiLqno+e+AbZf0hqat3Z0dfX\r\nXOm4dHuCJSniz3fWpvq+Xezh4ceWtAYKjdQ5ZuOc1RT4OEkQcPUZ5+227n4M\r\nzZ8lCg1zDfPwzxWsyVkUXQ5mK4PfRdiZyxvMJ8P1LbrJZcS89GzRNCykHB1A\r\nlmpjmlM/JgDeTAjBUSIm3xB0ucp1k+hmdpc=\r\n=TIw7\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"2d50195ffdd7d807878f8f45b4a5bdab5b3fe318","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","itty-router":"3.0.10","@whatwg-node/fetch":"0.5.3","@whatwg-node/server":"0.5.0"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.0.2_1672047488108_0.8326316181777336","host":"s3://npm-registry-packages"}},"0.0.3-alpha-20221226141545-8392bc6":{"name":"@whatwg-node/router","version":"0.0.3-alpha-20221226141545-8392bc6","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.0.3-alpha-20221226141545-8392bc6","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"ed5d0bbe92d12ad1b9a88291be472a40cb37d49c","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.0.3-alpha-20221226141545-8392bc6.tgz","fileCount":6,"integrity":"sha512-HN/MXMXz9ccEL/CMWSP+d8Y6vdUuCzUtRdet7nliUPqIT9BElHn6TfT6PoWLycefpyhZpmNwak8r924bugms1w==","signatures":[{"sig":"MEUCIE8I2zjnM/a3+er/9PhysNphuY+M+kBh1fFIwpQsoSpHAiEAsVW8iM+okRDSmkmPpRIkObIHm5cTd/3y3MyzAI2hD4w=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5073,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjqayhACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmouGQ//WYkT2N8Ps2Gek401WeM8MRXUETpuuXqtAPB2aT3T6uvdP2d2\r\nXE3GwF7wpodu+5raipPvf2ZrMhhJJhIw2//IRSY0EIXpEWnkAL7XIwcJlwbA\r\nCYdEikb4XTzf38pbSgZRezd947yVnqTRZu8hMfxKntdYbMZ5IVOGhkLxSKr6\r\nIXU6wXnLALYCEyvUr6E9el4bCJLRfYeW8tV/GgV0a+53QHCrE9nT6cAsQMpL\r\nO8kOkgDTr3DXhj3enfiJkBDlQyZgitnpStEct4gnFZWD0iKW4juNexhENEgu\r\ncP1nHf80lQHXYoiRX8ieU1uvqD+eaffOA0kQBkBCZiBi88ATwlWGGHI/UDYM\r\nHEGkjUTQr6p6LpC9tAIX+75xXI6BSNTXk7cXi3USgQh7XdXEg/cho3x0z84/\r\nSD0hhxW+UHnl4RkvWcyTfWMQ8excLBcFY4RXEKNdaxwuqLlm6Wru9rm4YYC+\r\nvY9npSa1WhKBgjKrduKnd9PJnAMgCf8bfTDo4hXeAcUcsYers3OllfLkDqkf\r\nJbeA/U8Rhf03PVsXJ52BQ1HAXjPpbWVO2lkCbCNN5yiuuIi9tyYKv+RZ2c0u\r\nunbPz+aRxNkPFTbM06v296IgjasgTo2Qt4PqEmYLnkpaYJk6sOqp8CpdXfwH\r\nyEqCu+k+d4oZasnvBJzR4P4jC6im2KWH8CY=\r\n=pMHc\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"8392bc683a424b6607b82b972b29b49c76e19cf1","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","itty-router":"3.0.10","@whatwg-node/fetch":"0.5.4-alpha-20221226141545-8392bc6","@whatwg-node/server":"0.5.1-alpha-20221226141545-8392bc6"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.0.3-alpha-20221226141545-8392bc6_1672064161054_0.7420656669691048","host":"s3://npm-registry-packages"}},"0.0.3-alpha-20221228080239-7c1fd2a":{"name":"@whatwg-node/router","version":"0.0.3-alpha-20221228080239-7c1fd2a","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.0.3-alpha-20221228080239-7c1fd2a","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"590a0d6961929ef7aab40065232c59b6826dd9f6","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.0.3-alpha-20221228080239-7c1fd2a.tgz","fileCount":6,"integrity":"sha512-IAS4QECa36Gt7axehP5qYJDDERavQfFfzfEGy83/CzPcNX33a50NoXOflCI6Wjre6Iu9ktlOW4k2ckFwzfhPOA==","signatures":[{"sig":"MEYCIQD/Oa8oPBr2tKUiNKsi9ZUvTKzm9e4L36t7TeloNZsnNAIhANl/RKiyg+WmwexnMb/p2rhE3Rq8RDo+XZ7GZO3gZF1/","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5073,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjq/gsACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpWMQ/9EkxDwvJTenQfE5RTJDXvkanm4AFpmXq7snvBWkq26XtwYGXd\r\nXmN2SJ8rgoSUduWAKkl1Sb9flL94KRKCBWQx14qNjxkmPoffL9jADtTKJOkj\r\njAGg94v1S+5mqL5xhND6AfSH2ADTmIuItgB8TicR/2D0JNKHQbb637NsJ1IK\r\nJdhbrMY559efnbLGwM9kSozoWivlqaH89pL9LZILYAkQX23HwvYV8qmHTr57\r\nx5HsJYD8hteWTmliZJwH+EHIYDERm1ioI3HVXBedhT0q/TPPWp9sggPEnFpn\r\nt4z9g+CwNIW4sDrGpqpvhbP8VFONA45x7nUSRaUfbSwfFxmeRXl5INeRtLgj\r\nk4wN0YTKWttv+cE2iw8ilxmncp8Z21HjyB96nxayH/bv9tXcStQEmYAZ0OJ7\r\nmPBCkZEp8A0et/S44YCFOQtkHavYHFiSbVawLHfg+B/XjO6ediAhBF5OCjRU\r\nWRsudTjBp8SrOs/HeQWB/evDBW6HYghyw/oZml32WPcVEpcquTQssJQMYHlU\r\nP3PiZPgXdO06qvs/XTPnVy6YMOu/nyPI+3NaV27a/lxvqdkEPN1lGdizRikf\r\nrRyQHGff31WSt6D0Ai9AzfeP0rEbbDB1PTH+ABmuvtHIy1QPq33BGd8H8u3z\r\nqNbHTpcVoKVwECkxbiH1uPENZxJszJaZbQU=\r\n=QbEe\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"7c1fd2aa6512e2c415c25bfba328c922b88ee3bc","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","itty-router":"3.0.10","@whatwg-node/fetch":"0.5.4-alpha-20221228080239-7c1fd2a","@whatwg-node/server":"0.5.1-alpha-20221228080239-7c1fd2a"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.0.3-alpha-20221228080239-7c1fd2a_1672214572527_0.47172264966494715","host":"s3://npm-registry-packages"}},"0.0.3-alpha-20221228080444-fb2baa0":{"name":"@whatwg-node/router","version":"0.0.3-alpha-20221228080444-fb2baa0","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.0.3-alpha-20221228080444-fb2baa0","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"e0cf3095ecd7203de663d3e866415fc9373be7eb","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.0.3-alpha-20221228080444-fb2baa0.tgz","fileCount":6,"integrity":"sha512-SdxIEwJbHZ7Cl3u0uFPeiuzaOkmy6ZnN9wTRcmnp9zZB6CSelR67kmb7EvwFx/reku6LVbmAurfbHZbVRRf1jA==","signatures":[{"sig":"MEUCIFNTlcf2+oKX7eB57mJYCef2GOXo7bQ7PQosJJGb1ua/AiEAlOfSoBBdLjkUGy1S9T06WlhrT0Y+RgrR1zKouMnKdfk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5073,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjq/itACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmo1lw//el2KOrvU6go+uh21oB6a7T5xaJ6Lr2sc7AzUTYFTWImRUpg+\r\nqraOf+ogijX12losI5srh7POcJYxqtBfjztQT35JYxEAvV0FdMN4pJLtFdmi\r\nk0OiCwOADsyA/MEd8aiHsoRd8sQHeXSpFvALE4aUPDyT0rIJPUied7cXzzRm\r\nyVKdX0ZhIrz8kV+0yqDQ3l1zTO9Xf3Gr+AABeTvBBlBL9gmoZqCJHSpbMrhI\r\nSN3gE5VGc58S3VXAqZk6G3L6sl0jb3c8EjQ1B06PpV1cIWvEC9mGzSB538A1\r\nWyl36RzOg4xq2TAq6bTE8hMj0PDORdFxhpIZtFHi8GzI41+pym5EBswxU2Qz\r\nAqNeQXI6Rs6kej/cCM4bzMO9Ysr0zZmueKw9gqL1/P5E17AettATc2YbSe2k\r\nmhIwJnqLvmZ2+yHUl24MqPR0GxTABRqAuUzQCsVS+ukPh41vOL4LRWJWBBTA\r\nMLoGKtWGaWMHIcp6V7Tf0tYhoo/y64Jfk1R3JW8BKxlqY8DBDp8lzCVZ+WgX\r\nL9Hnzmnw/PUMreNvocxjEQQLGsDZOVSPYcbZZcpoSnAjqwKpfFI8MwRHoF0Q\r\ni3hVU/55oeuh1bJXNeEbXS+EHiTTn9ib7Qq/zD9zXKIYF8UfJzhece4WeyTO\r\nSlE7OOMiudWrE0rtjfGvAZ9UBzCu0KMBPtY=\r\n=Pvnf\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"fb2baa00f33274d26994e6ae32fc7966e77b0657","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","itty-router":"3.0.10","@whatwg-node/fetch":"0.5.4-alpha-20221228080444-fb2baa0","@whatwg-node/server":"0.5.1-alpha-20221228080444-fb2baa0"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.0.3-alpha-20221228080444-fb2baa0_1672214701470_0.5480295415039735","host":"s3://npm-registry-packages"}},"0.0.3-alpha-20221228081333-b271a45":{"name":"@whatwg-node/router","version":"0.0.3-alpha-20221228081333-b271a45","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.0.3-alpha-20221228081333-b271a45","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"494aed9804e5ac39d458fbdc236fe94eb89ae45a","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.0.3-alpha-20221228081333-b271a45.tgz","fileCount":6,"integrity":"sha512-l7G7KU3P0LKc6TWnMFqxdKNphQ1irAeMR5tTwjo7BlRBfyeCgGTECEgC84MGn42G9KRVJDRt446Km1H1bXztEg==","signatures":[{"sig":"MEYCIQC5US4IEZYnoz6Elqeh46q1AivA9PBgu3ubY+EFJJ21YgIhAPK+iPhOApQIegpaW1HKXmSa8dRWD6my7HbGgCOif/+B","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5073,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjq/q8ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpQUg//WxYqoMOLiVNvEwGX4xDSY6Q3rhLZUgwMcF1MS9AQRHLN4ZRo\r\nPqmImwQSK6ZIxd2qcv8Z+3LCIKaOL+M+aYQQnwETSxeEd5pqsf+cTgMQ8LOW\r\nviuJ7z5vMaEqmnXNswEDds3TnNa8stDRLEDEXxgzRp8J/BniYjSRl92PidO2\r\nEViKYIuJ8UhDk2zqLdCLQxm43+CKCAuLg2iKfm07NpM7CBPPdhcXgKwTaeOp\r\n4uk80toad5TDm8y0TkCRqXFyS6W3ThLrlTM9jvsAaBRIJlRXk1lw+gjadyb4\r\n4t4kHyFlWByrwNYXpVpO7TCfRAkp47+2aFkOXlTP/fe6it5V4Q40+KyBfgfb\r\nXeLasj3KTxp0N5nIZPECx53cqmv9nHvPv7fkFtQG8tW6BER9q50sAvyh+eBk\r\nBHzM9n6XlWkWclzVszXXX8INpGMFz9JYGX2bUjZs+TyvSwMtXTRTI20DZ7Tr\r\n/uX84vdtrIZj4EHc7qD3OrFhi7NxHtaQz5p/fcG1xf/eqefuKGQ3dN9Sjfp8\r\nltB24RkwbIlZjXCLwT73nDxBJ+9cJcq6Iz3FP/C57G3/tjndyzuW3OkMcqus\r\nZdPIpaHPZ4mkmpW9nAm9UturGgvEVocOxKax66tiIeP31XrRh8eb/ARyQ+HO\r\nHdDseEuR28G7j62G4MCh3btM/zv3mBGiPsY=\r\n=CKIB\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"b271a452038e496d689ff55fa9266b86c9be9e0b","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","itty-router":"3.0.10","@whatwg-node/fetch":"0.5.4-alpha-20221228081333-b271a45","@whatwg-node/server":"0.5.1-alpha-20221228081333-b271a45"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.0.3-alpha-20221228081333-b271a45_1672215228531_0.518870678205178","host":"s3://npm-registry-packages"}},"0.0.3-alpha-20221228081805-75e6dc7":{"name":"@whatwg-node/router","version":"0.0.3-alpha-20221228081805-75e6dc7","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.0.3-alpha-20221228081805-75e6dc7","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"170fc5eea33be12c2b819bf808c61a4d7a52009d","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.0.3-alpha-20221228081805-75e6dc7.tgz","fileCount":6,"integrity":"sha512-IMW70QftOmpN19QosbdLjBk3wTuZWyKM4J66FePxHRwf225DKek12qV/q/4D9TgP6tMxENc3xlzpPKnDYmjLTw==","signatures":[{"sig":"MEQCIFxFres+WKCac5I8o3YFtoq3xd8YmSXW+VKhlG/XkzpLAiAbqQUnYLMlXtfVb6NGWaeeTOVUZR3rNzdEDge0ZcXu+g==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5073,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjq/vOACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpeXw//RUrHgnA7drH5PWbAr5On70Fgin821pgMxdYvxRVoAQHuPI3o\r\nWBf9GYAI0sPPeoCebLd860AaWdZfByiM67Kyx1IT/xoyyLkLq3Uy9bCkYzLM\r\nBkqJMfRpXO+Oy0p/YZxyGOBNIjDVf0vvoHHpQAe3FBytheRll+KvivtEdmz7\r\nYTOQDj4cLDO0CAvEaJ76Iw2/BcOCvj4p01EDxJ1KwGf/D16u/JiSyI8c1xiP\r\n7mNofvffgH20gRVlwEAVfcejcV7kMEKuhmLyVmsSkKopWbLURQjxDt4E4bQH\r\nKrrqsoU91lSQZrLQSJjB9nqRvl6xf1K7fWjJzKNzAAuhIChnV5jKZ2cf9dWa\r\ndW05M6K0ezLbndB21rvC40KI4WYidbAZ3rtngvltWhM1IqlwlcttcAF9K8CU\r\nOSmDhxw0kLHK9CeDIrfSNuTeEUb1ilF3I6wMzZ8LbkNrrWD2O0wKB3DWTFGM\r\n1hP2oHBIRskju2StHbDLT/FCOWIO+UxuwlrFr32JCApZOT58bK+d8FFn9c5k\r\nzOyVhpyBCupShoNT6mZQZQIOTpFFtYPjtl96ySirsqiwpHiWrAhstHY0ksCW\r\nUKbtq+/SIjeuQleqImSDg+N9Xj+iZocq5GkYQBRyauYyJZ6UZdLji2VHvSkf\r\ngZj2x1X4NEywihPvo8cOY/8IdlbjqHuVV7k=\r\n=NlPz\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"75e6dc729e35d56f374d8d88fb97cef8e8c8eebe","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","itty-router":"3.0.10","@whatwg-node/fetch":"0.5.4-alpha-20221228081805-75e6dc7","@whatwg-node/server":"0.5.1-alpha-20221228081805-75e6dc7"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.0.3-alpha-20221228081805-75e6dc7_1672215502763_0.1391294732420525","host":"s3://npm-registry-packages"}},"0.0.3-alpha-20221228082016-9ef2266":{"name":"@whatwg-node/router","version":"0.0.3-alpha-20221228082016-9ef2266","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.0.3-alpha-20221228082016-9ef2266","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"dfd39aec2ec9ae8d5e3366ff31e294a6ed795109","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.0.3-alpha-20221228082016-9ef2266.tgz","fileCount":6,"integrity":"sha512-h/Ig5n+dx4ldH2tXwusw9RXg2A/060j3NvApldyNy9ZhtgnPJrDP8D6wpacND0Z4Vq3qdcjhCgbMM7XXFxExQA==","signatures":[{"sig":"MEQCIFZq2B9XyDLW6VLr5akFXqB2UwVvqsFNAFoFy3USpQQeAiA+d+Qm76aZQbWlwPxAjyxALniTs2IaVHV3TdNP0fO1UQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5073,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjq/xOACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrX9w/8CrAUJo0lbM2lnSoXdXpDfP4uLGvgDUqkxrFDDBHKAJgfbwZr\r\nI2Hchr4nmGOh6rV/NdcgkQKwHfyqiedhv4b9IUYm+jTcqLzlbYHzl3PWiI5f\r\nigkcHM0/yJouRIeM6LETsiyx39uhk3F8h3JLFAxvs2SBz8jZ5iyj3d/dDJSz\r\n7qFZ0pLbiCGrinsjpSUVrtqg0ITYq/gHlC3K4ycsfoNNgFdCZPpoOcNnNE13\r\n5I7Q0pbVDFlCpJTWqY6r4sbbE3Au7wOztdeOU9pEoWzcETuXc4gDl9+5Et9J\r\npU4RcUH8CAI7am30GcxW1FE841VzepF/w5i0D6OYfJHyQKlq9WXmwWCdLJiU\r\nSGLGFPfwuf8R5s6YnnC+UY23cqr5GGr+mCeTgbiBJ4iWgylLk4J6RdEWjvur\r\nj6mwJd/wVutIoXBELLbEEPMprSPkzy3V/geaWuEndOgZ2jg6+oxrflEmjZZ5\r\nO5BiL42fePOo1/8gb5cWfEw1se/CfObtrpaifkqpuNhYlrWi/QPyOb9wAPJM\r\n3xAVj5CYECRmAfcmAS+yR86LYvLVAM52vBzE2CKUYsyz1oMnE0xUwRPc1NZp\r\nSyUKkKmztuFcCzjpbajs9Ta0lP9C82DjkzPz1s2FNBsc0F+Ko/kMu4HOzeZ0\r\nxrt/c8M8X7C0JkBCZHgOL/7O4lbRFShjujk=\r\n=JMfL\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"9ef226613375c233cd59882258f2f92e2ccfdad7","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","itty-router":"3.0.10","@whatwg-node/fetch":"0.5.4-alpha-20221228082016-9ef2266","@whatwg-node/server":"0.5.1-alpha-20221228082016-9ef2266"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.0.3-alpha-20221228082016-9ef2266_1672215630621_0.4905510273457381","host":"s3://npm-registry-packages"}},"0.0.3-alpha-20221228083733-4041c71":{"name":"@whatwg-node/router","version":"0.0.3-alpha-20221228083733-4041c71","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.0.3-alpha-20221228083733-4041c71","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"03a7f44551e1b6b4b079d748a763951ff6fa1e29","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.0.3-alpha-20221228083733-4041c71.tgz","fileCount":6,"integrity":"sha512-FbYJqs3OIbt9XUxYOtsp95pre0QxvXAy+VziWiNwmE5W9xoo3yU76Z5cx+fYDP/YeSqX1egn9O5iA7rkAaP6vA==","signatures":[{"sig":"MEUCIQCweVgumq/CiyWduFeh9Z5VdHmPgdlL3pj1svjqeNQM/QIgakKT5L9qBeAWBzn0hJVAUpJ98WBdBt3aWT8zKVSNwdY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5073,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjrABcACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmokVA/9H0R4tmbs2zy7tgfpZR6kDgi11xfiBulHKtMtAwexE5fdAjfs\r\nHSWaklfikmgCxJqjtBesJoqumTRI605pvUrWk75W477a8ZbtBgwwKRquLKq4\r\nANGJ52FkX/YfiAActF1DbPLzXhbhrYibO/ordT3Gvh6Qd8TV/t1cef4x/YYk\r\nuGUx8RTV58DUJtgf4AV3YaN75WH9QN0anKVIuTNofN516pEpKcBYG0d48oVh\r\nPlZvSIT+nxc168CsgJ6RjyaKzbzjj1Ch3tuAr/R+stvfss7KMEStpijEhtHu\r\nMk6hvy/zEKLrx3RR8HihWnaL6+2CdndotDYAT+6tkgF1/SsbZGK3w6cgTUpM\r\nLoSkLq5fULGpKz2Rr34OC5friqoyGaKKKwY0s2OJ5Z0CXKXwPKSwzDJY+Uyu\r\nZ0SxN5owDXoxn4YsTtZk5S+zUnk3KHzkj+CiA5E9lWd/vhv6x79pmgPELtD2\r\nVxVzUAE9E1rjObQ2prgW3MBTRO66O0rtsxBwd/yOkncfhTEeFWKZzdqDcd0u\r\nEEojFpvfsdX+Y4oHLfURobTj6XbiEnncyNAjRVTkIRJl/xeM3rzRoh2pnATb\r\nkU85YnK4axqT9/eVkE7EssChYxqV2/XwTAQ0um8UZ1dfei6n1Tm+2555aWEX\r\nkfKhydcFxMt2aMcjZiplOSIYbtyMkV97NgU=\r\n=ytKR\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"4041c710b1727f0e22918b663df7c3f8045d8d14","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","itty-router":"3.0.10","@whatwg-node/fetch":"0.5.4-alpha-20221228083733-4041c71","@whatwg-node/server":"0.5.1-alpha-20221228083733-4041c71"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.0.3-alpha-20221228083733-4041c71_1672216668592_0.4257769092885244","host":"s3://npm-registry-packages"}},"0.0.3-alpha-20221228110205-1d6dcac":{"name":"@whatwg-node/router","version":"0.0.3-alpha-20221228110205-1d6dcac","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.0.3-alpha-20221228110205-1d6dcac","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"fba982e508adb49fd8148f125e38512c744f8a9f","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.0.3-alpha-20221228110205-1d6dcac.tgz","fileCount":6,"integrity":"sha512-+MPxa+8PrZWT7roIB8cylZAI2SK5dMRaDBRfXtyXf74/hub5vdCMyNaQbvKU8h52cCQVzT2lMfnRP+YTZJk/KA==","signatures":[{"sig":"MEYCIQDbETfwN/YnznAfCvstt1VgwS+a0lEmdxJiYz8GDW0QvQIhAOXpO+iLw9GKAazi6eda4IJPVBb97yTnnePYn4nTxXSA","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5073,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjrCI/ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpJ1Q/7B5zFKd5aIm+cObgpnsJ4SHy40saKRuKSGF7e/eW1lQ+LkRHU\r\nOFmMUJDe8TH8JOuhaFvJSDdGUXihF7bW2H8q6Z2nB+RBrg7DiAHIj0SmfIDi\r\n/G4sSpZt4gcMxrPOADKEfTvatYnVwGxP09EkES78K1mwPDRV+f9gX5oOahKo\r\nNvbsP+pv4grPqPEdVtT4CzMltNvufVTosrvylYK82m2uCqE3QMuU3p0KFlvh\r\nHYxs2pdnnlR0g3B/NDeBTZuS5i8ZFPrdtmYhhLtrMWYIfSI2F9Iy9hGRAVbB\r\n064ny7/9VRpvXpKjzFfV4pBD1R6ssIAXgL2uZvErwEopLlwPsxJoMiQo3AuE\r\nxN0G4vr748driUfYXAmPkimbqdiTRxp5j6bmkiWlozWWDtWxq5m7dlDkhYG1\r\nfsMstm7vtmZxvlKk1xMyu3iK9v85NdzeQrN/mBnirXYedHcFZ3otQtTG9zSB\r\norDKYbF4a3aNva69wN1heinY9hzhHs8eMI/WRF9USHaUfrU1kAEB4JTr7fA+\r\n5U4YFlRzFfihdjlVbEeDELCg1Tzv7zXGAUYbNP9W31XlG3X5JDNbGikHWAUb\r\n9OFza2XKn7R1NCRwo7zIdM3kH2Mo1T3zA7fz2WSC7JDsnOvtSB0d3QkbX0Kw\r\n4TwH1YFebXjrvpKOene3yGL1xsuDekklN5g=\r\n=auTj\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"1d6dcac92d91faee32d0fc4c96b1238ea7751747","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","itty-router":"3.0.10","@whatwg-node/fetch":"0.5.4-alpha-20221228110205-1d6dcac","@whatwg-node/server":"0.5.1-alpha-20221228110205-1d6dcac"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.0.3-alpha-20221228110205-1d6dcac_1672225343314_0.7690870116450665","host":"s3://npm-registry-packages"}},"0.0.3-alpha-20221228110541-2aa6aea":{"name":"@whatwg-node/router","version":"0.0.3-alpha-20221228110541-2aa6aea","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.0.3-alpha-20221228110541-2aa6aea","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"20be7d4ef9680a8c98628ef96cb44113999bd745","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.0.3-alpha-20221228110541-2aa6aea.tgz","fileCount":6,"integrity":"sha512-hzNasIZWk4oaqQCavMJAUfEBH8DEML4G76MYbOruB8qTvW5XqIHd40b8Ewl8ZIcY/BjonFvJROGqKEYCz+jAjA==","signatures":[{"sig":"MEYCIQCDdQuO0+PUJ+9kUzGrn8Ud0EQX+yH3tN6sUcErw90UFQIhAKNXIr1yJOO/613tTx8bbCJvuvSeF+GG5didQ9t8mlYD","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5073,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjrCMTACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpPsg//RGN6M7ru/NSZ7aRzdFCJH1fUa4aDwIW+f5A1JS8jdOScWXtz\r\nAGVyajQtsot7KP/PINleXJh49U3WyOlNdLxkSs9+eDcJ4g8QDKj7hXfq1/0E\r\nSdBnwo6n9mnWTzw/segzDsQkUNez/TIV6Dy+XAzhvuDTY3DH1e04aCf8/NSq\r\nUnN6nuuZPnWpBl39rkYqaSP+cbUQ74nfGcVdVjP2zRCqrr7T7RZ9cuKyLYWd\r\n8tPtN64cfS0WAXLR6PUnblfAmO+bUddd+0RZFn9rlbIU95ZYbPyxTXx6snwV\r\nD2VAKyce4XdU98r8uJyW+OgEsl3/nT66LaWh5qiqFXHZxg3qAT77kK3ustjN\r\nDXcXLK/8nB4P4qZRYuGt305j3yN8OOExjvkrjOgwdQY8LcFrHVtWepOJNF5x\r\nRgyXkoJFvYmeY+0I7wgecUMrnKMdb8DTdYLQnkjsLLhyPAx6Ip7/WmJ1QIQK\r\nBgggpgf3FJgc+qo/iC1Lea09ss1cnTfsrTY1CYRLMStptCPHnlDgpqo4ZuWa\r\nFpL/fCetqPVnkAOjxppCOAdq2/7G7iDQj9f0hSKY5UZiN0kmmB0CSZn+YbKP\r\n2c6xVeVWRY046UnmAsiieCrs2x4nHg+46EFFggD/eLEmMKA1kruDRGl7PYSV\r\n2TWzEUSKHz7JAjqNvD+FJQJHKNqxTYfR86U=\r\n=2Vj9\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"2aa6aead9b97bd2a4a5c95e99b273000d3c4b923","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","itty-router":"3.0.10","@whatwg-node/fetch":"0.5.4-alpha-20221228110541-2aa6aea","@whatwg-node/server":"0.5.1-alpha-20221228110541-2aa6aea"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.0.3-alpha-20221228110541-2aa6aea_1672225555127_0.577913805479596","host":"s3://npm-registry-packages"}},"0.0.3-alpha-20221228115139-6b81aa1":{"name":"@whatwg-node/router","version":"0.0.3-alpha-20221228115139-6b81aa1","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.0.3-alpha-20221228115139-6b81aa1","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"9065c66d117a5c3750950a02d8d44912ee8320cc","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.0.3-alpha-20221228115139-6b81aa1.tgz","fileCount":6,"integrity":"sha512-myYqtDoPzZLlpFX1uECwA0t65a0fUQJuDnrjUA925cWwPqrO+wyBmRcBgnHxEc75sfSW+yBM4WaEt8s0ipaH5w==","signatures":[{"sig":"MEYCIQCakvIESGPi5yuwDVzUG1+CmF9wxbEaU8pxsBw74SG1wwIhAMDn6le+xnykR3GbStRJqcUIXLdC0RqkeNNh2QDEddLh","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5073,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjrC3cACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrMdBAAiabo2odOlR+EG1k1pFKVx3g+vUjQJuo87doda+IZCfGQ40Vx\r\njtrhsC/VOUlf6hEnnF3gNkQx8SnfrFAQCtP9YHYV8wcfpFwBlfJM4rQDoRJH\r\n0r0xTkArf3NPMNzawqlCVtgZ1HRFxwpSh/O/D7A4drsmAMD5ZvGlmobpI5AW\r\nLypz6LKrB6I+0JKd718QMIN8/aC4OOkY4MpA0KlnIvuCH8rTq/gPWQxvD9cR\r\nL658bQsooAIzsSovMym7Z12aiEsfWC6lh/MJg+8hshU1+fCLwDJA0O1Y8sra\r\nBd/SfZbmelWpFLwm4qTcUdVeI7dBFtq44/rzulvZ5/FW+dm3IyD1Bzq3ys5L\r\n6N5rUuEKGHIJ4gstEIOGanCRr2YjGg9exFnJu8noK69HQ6sJXDpXDS6Urrls\r\nIrknP3Y5l2Q5wuYMBxDoaaQIA5jdHPMy9wwFS8xNxb4FTsySkjd0JyenWf73\r\nOouuDESqcJ77Yn7IMf3ERT1k0ui4UTvGs8EI82yV1fK5DWzaUslepvY6jvL4\r\ndSGqIO2Hr3vrQa7r8lkPMMihokKc23T+LQ9sb7A7U3mbIj5+BxLdm0YcMjZc\r\n/v49cYtNG+ILOYkxur95adb6abiXy0R/hVOvdFAVDhPz6AY//gmwYWVDzCsa\r\nCypAEawGpcfFFed/wNIxwf3V/jeEqG3sJnU=\r\n=qqET\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"6b81aa14de9f75b552368ce106e062a6dd1fcea5","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","itty-router":"3.0.10","@whatwg-node/fetch":"0.5.4-alpha-20221228115139-6b81aa1","@whatwg-node/server":"0.5.1-alpha-20221228115139-6b81aa1"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.0.3-alpha-20221228115139-6b81aa1_1672228316221_0.9867153260610175","host":"s3://npm-registry-packages"}},"0.0.3-alpha-20221228172034-08ac509":{"name":"@whatwg-node/router","version":"0.0.3-alpha-20221228172034-08ac509","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.0.3-alpha-20221228172034-08ac509","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"32ff6624e9f90b19730b148897bd8f1cf4426868","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.0.3-alpha-20221228172034-08ac509.tgz","fileCount":6,"integrity":"sha512-lOq+gTR08Hw1D50Mz3NDYwsQyHlx92EnY8cjlVnoxqAv/RB+YAKea64LguAjdo62tQ0lnjt+/zG1NFFu3WE/bA==","signatures":[{"sig":"MEYCIQCpf3CL2FeduQTlXZHo4IYEawCQwgPo9V3S7ZA4mAp7VwIhAOpg4zQ9ZtnBujV0d6lDRVD3P9vEG0HB/k07hFDxMIF2","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5044,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjrHruACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqXyBAAkSaThC984C7EK8d4aiwZWvUZCmaZGv2oX5WQfwFtyevUIHJv\r\nlxY638tJyZEH4lwXzB0RGiOSk81GgTRwpLSjx1317/xZjCCvgRigTlfSdCjK\r\niRXIzH0d3EKfWGEfXvDIs3ZacNMgClE7VFwE4Xk03kJ9knCa3OVkPJvJS+oJ\r\nrZbwVSTBsju4FGz0SyajFpVhMjEMhCGP91FiMFHYqcg1tp+/2O/SVayZvroU\r\nFVqfhqLwLcCnIlUPBL6Dw3oQgkmjvXHlvqUaJHiHcPjTZcqMY8njC4SUz6i5\r\nney9hmhD6Ftz+K0u8sHGHM7MUJsn/Ry7rdEUfbGwf4S/ETQDtzyWHAEM88O1\r\n2miQ2IV6M5YieQcOOERS9bbmNcgKyDrYd7JJl4hhl57o/J65LWA3sR4dy3t4\r\nQyw4PWHsBRghj5yUEYTpT+jPdur50CiZC3dP4Ned/Y4BbbPthdl6QmgFDL+4\r\n4B/EvyFhesk0SlhmEQ6TPBUFF7fjVHPhPYRteM+fKhUHa4lcAT+kJH5ulMpx\r\npfGaVp16YBW9s+H7O63kd6Kp6zv835f+U5hLR+KnPpjeTOpAKdS4bRmEDjqw\r\nsP1axFRmFNGEh6QD0OllMhW77E9TduQPsJdHGiv5Mc1Qm/NEfliTDf2ktuHB\r\nHRW1j35DzaJG3wvVF7iK3ta8gR6xZ+PWrx4=\r\n=ULmj\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"08ac509a6b74e190523013a6a22881d1d419f004","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","itty-router":"3.0.10","@whatwg-node/fetch":"0.5.3","@whatwg-node/server":"0.5.1-alpha-20221228172034-08ac509"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.0.3-alpha-20221228172034-08ac509_1672248046319_0.45826006412749787","host":"s3://npm-registry-packages"}},"0.0.3-alpha-20221228193325-21c8f71":{"name":"@whatwg-node/router","version":"0.0.3-alpha-20221228193325-21c8f71","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.0.3-alpha-20221228193325-21c8f71","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"572bcba12f13676aec812023fa9d68eea81f81f6","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.0.3-alpha-20221228193325-21c8f71.tgz","fileCount":6,"integrity":"sha512-OR24IvFvm2UyPzInDHYK60NQZvBQdGbp91Fz0oMFLYEoRACTnEzWq+eIkj+D5VGdTHSTwdIEq+tjyp4YqVpJmg==","signatures":[{"sig":"MEQCIFsEmZgYef8YNy8d8CldS9h319uC+YBOyo/ueCLJNzQTAiBESqnVpbcvxy7YoqQixmIRnaEeeaggmzSuO7c61N2FBg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5044,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjrJoTACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqXcg//dgD9KQp4GNHQWcpcEyDJAPC/XtOY/g4jW7U+4miHnzurQZBx\r\nXr/NEmIwp0PSp8wk2rX2su/SXL5FQgJZ+ERt3RJJZRoiGhNZIBfDIf+kUbHc\r\nD8vVEFTwiCcYHq6qrPt5HzZrgZsiZxJHW6A46p+VVzLStWa3CazZWvvB3XQD\r\n7WE6GInz2DH29TKsxUTyWg2VzMdM1w/AWNbtmbswjWj6Px8rupdvJgLy56HC\r\nxK2CPzXbJxDznx1fxr31N+dwoyHJoVFbGB07xSIKyq0Db2aTRfAzj8JQ7OS1\r\n/gT5ICghqNLBVMuJYqI1vNxJcHPBGJZTFxa8L2kju8TjqoVeGXFMyCMPfczc\r\nhtl31Ug+9D1LHuHwj4uq+nbzLBDVwnQ5cPGKxyxIxPdUAjTNyCsY5vdwVzXQ\r\n5YdMrqH1c7NarNQ1oNYcbs105HMuPyJ3BytFONQBUiRdXYB7GImuyGkMhn5H\r\nYZNgdfX5mctY/14tDEPQuXUNb6+jG5GywinKVKTCIuQ+e/RNfkf5bF7DACxz\r\nYIHk4PqdbpABclNcigmbOinGO05yQdxw4kiA6Hw0sstu3yrVwQgSF2BRDSGm\r\njwmRcU1f5XYwuEbwUs4/rsuB4T5gDsy0Zm7NP6zvBWndsC2UPziJpD6h2UWj\r\ngyibOkkK/6PJIHTxjFD7TGeYpIBpEMPp1ug=\r\n=P+xb\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"21c8f71d313ec0b0934621b57c05cc74e1413b7c","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","itty-router":"3.0.11","@whatwg-node/fetch":"0.5.3","@whatwg-node/server":"0.5.1-alpha-20221228193325-21c8f71"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.0.3-alpha-20221228193325-21c8f71_1672256019455_0.06965484691293655","host":"s3://npm-registry-packages"}},"0.0.3-alpha-20221228193327-daecf41":{"name":"@whatwg-node/router","version":"0.0.3-alpha-20221228193327-daecf41","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.0.3-alpha-20221228193327-daecf41","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"0b4b3b3d72ef76730dc240ecb165316161253b64","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.0.3-alpha-20221228193327-daecf41.tgz","fileCount":6,"integrity":"sha512-WYookeHTOy0jePXHaX6RMQTcSbcNg8xQQLrVW4401UWP6K9nHqxg4nWADoH+VOSU+VyFI0C4611eeTTnruJZXQ==","signatures":[{"sig":"MEUCIQD8gXg3WmhkXCbnoLswiL82HL0Kl26iXGf/wG+9OOos0AIgUk2ymXiupR7hcvCEx9p44sFsFczuVZ0rbP7ANJuvQvM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5044,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjrJoUACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmoofw/9HFI3gobmkdcipDW00lI96BVSDpH0YnPfcFxvoBUx/sskcSaV\r\n/B2jIH4XctzYK7duv6v0GG28dLcyfnD8snzU+DZcHrpAQu4gJ/ggJQIDISX5\r\nTahjPfZ+RSp4RP4j/yqeXhR7CMKjLXR06ZtVMGkQwAN9XRZpsCRYmscJRRiP\r\nEKWYO6enpi0k+Sjhy9HHJvKTYzbsbWmWj3whcjh6+Z28evcsXJCkHa+sGbiR\r\nrthNvVpeo5fmdh5uASawz0KUv+GlcCp+NvVo2fVKIDBA0PEoHyZtuSTMpsRb\r\ntPYOxwUtJl/yVArXq+zFJzP0QRBZaGsvtaZiickXdrjOK3GxpJuHskjPz4Ll\r\nhGjpHm5Jp9PX8cFBv5kLjdHPU34ASJHP06WP0i5VRL5QjhveaBfN9Prz5XPD\r\nPKZcYn7Nn2RmEXVHF4rNy14TyJifmOHiaLtSx+vj7bZRb5hNlhdc13Mxk2/Z\r\nMJNfCT3PtYppx1N4ZhjYlYj2DwBrHuS+8wgPgKDy7mFdPnDHTCn0jmt1EC/k\r\npUpCUo0C6Ol6ySVplAMm1zfrBjqbpVi1b8u6ZurHmeXLts/3K263jnNlpwEq\r\n2f9iToa+A6A71cOX2I9wohOWfvV5a8txDcX4X8vIoJzz5Q78ShOZqxioJ9vB\r\nT+iQIjt/x5sF0FVm/00iDbE9kxtjCSyZ0tw=\r\n=XJvX\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"daecf415e66dc4bb66265b2c285604c421d8ab7b","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","itty-router":"3.0.10","@whatwg-node/fetch":"0.5.3","@whatwg-node/server":"0.5.1-alpha-20221228193327-daecf41"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.0.3-alpha-20221228193327-daecf41_1672256020340_0.5919831237318107","host":"s3://npm-registry-packages"}},"0.0.3-alpha-20221229225529-0521d37":{"name":"@whatwg-node/router","version":"0.0.3-alpha-20221229225529-0521d37","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.0.3-alpha-20221229225529-0521d37","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"b91d7d61d7a9da183d219cd2b6d0e9dc840563fd","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.0.3-alpha-20221229225529-0521d37.tgz","fileCount":6,"integrity":"sha512-zruTEZt6GbaXWsgtEkKMyuTnKv0EMiRHMUhxl/e0mG4yC0LwLv+jgzTxf3d31PF9AUTuSPo8m881nI6WG9eNVA==","signatures":[{"sig":"MEUCIE8AQMU/tFiIEI44aQa64xHesfV+WXrQmUslhBBZ4WK9AiEAhR/E+KRoFQ97yW/9CtSGoTU2wiaLydyyj8JHl/bMVg4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5044,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjrhrtACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoCzA/+OyMFhu543V0SdRMkVzF5v5OzPH4xkPk06YJRRcngpSFYfaEd\r\npamegdVlk98slEvViRGIx1FHNGgLFETbyVHTHy8od8/o+ljpEx/h8FZLdpzx\r\nMM/31f0WmxZXcNkly+jAaRV8+9s3MWTWupTt4hVqImuaii8N8b3Axemo7b0r\r\nv22cgQYporXOQQs/CYIpXmL12oqJIi8pVYPHtFvx03Ewv8frV9jg3E+Qp7RR\r\njF73PaLXlNbIchRC8VOzjP0B5gjkh3GQ7NiiD3LXq3pz6HY9svjVn9rwWRAw\r\n19MquzS4Y2LaSgo6/EYBUgspZWkuU3Hc+jWw/PFvMk2RpRnezW7gbhqeIMtl\r\nnpL85/Wq5cwSo7ioMyyievUc4un/972QTo87yaogZm+VuGft94OUmemDZEpQ\r\nrJX7jKnel+kfKT+Q/GpM9ra9kZ0iBAixrpmqho8StXsg82jLfoeiHnGzfGee\r\nZc3ZcjrfaBKMTYDFVTJmrlf8KMPbShOJm/HUVhNk7Z9wJiQsFUTIYUL9WJGC\r\nIFiUWnDpSUeChF7etm32DbHfnp39mRK5PDdtUM6yoyritvNR9vv1we9d7kxJ\r\npp2+4R1VTXX88xzgAyKZBw0Y1GaG2oWcGjd9Q4bk6WilqrhI1+6FOm9znIUe\r\nJYLe5HIAmwtUzSTmOX5rsGv1jeHKQMdaJzg=\r\n=AE6p\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"0521d371c36ffe709ff260cba00bab86b4c8432c","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","itty-router":"3.0.10","@whatwg-node/fetch":"0.5.3","@whatwg-node/server":"0.5.1-alpha-20221229225529-0521d37"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.0.3-alpha-20221229225529-0521d37_1672354541430_0.9679259376915226","host":"s3://npm-registry-packages"}},"0.0.3-alpha-20221229234839-9347e41":{"name":"@whatwg-node/router","version":"0.0.3-alpha-20221229234839-9347e41","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.0.3-alpha-20221229234839-9347e41","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"507a3a51ff7b4166907073c65241a91ce8fc5d76","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.0.3-alpha-20221229234839-9347e41.tgz","fileCount":6,"integrity":"sha512-iJdCiNMKNho+9Oz9Wcb/cq2faoOH2XAWlu9deeWMM58P2ilSIVqnCD81uJDOe46z7W3k7Ti0paatQww4/DMgsQ==","signatures":[{"sig":"MEUCIQCHDqxOV/Jb+V0zXVPx9r6TBZBo93NOQuMRNMGm2ILNMAIgIFJD/k5uvpOYcyVN5XGpHjRRDviPbAF4Od8IDHup3wQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5044,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjridlACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmrf4w/+J1hyRPPd7AsDFXZKbLqjMmvvPwUE/Ya9jTUA5wL6CuFihwLt\r\nbEB4jfAf51xRe+uP8Zstt324KYnP/fP4pfZjwAx9CyU3IT0cwIgIA666+8Ax\r\n3285kd2BobqIqP8bYMjNq6vzjviXjJvf3qq/iWc1cHPcASYBM38cGuwS9b9Q\r\ngj8KhKkqWeOS6Xe3YLt031OznCczYAtZMQ4OXlrhA+L+cr647+fMFNNrk/se\r\niQx14UQQRf1AuaVyhruvYeiLVjsa9CVJRk/DxKhcET9Emvmo9WDEI9FGdS+H\r\nxWUVsobOxCGDIblDeyXjpJTfqrRQNRAFQUDxpzrfTj+3oJI26rEQ0RD0XO0k\r\nZOi6Saxzp8AzT9uyA6Lbs5m5IcuDl4ybHMvghgW1tEtrae60awVbGC5iSl3I\r\nXC4I3SuPvwtV5p8KZiZ+LuSIIHmVY4yaf7bu+b/ljBz4u7VH+x3nszFCGFMb\r\nQEz65OMpBSwb9B/DtnnXKhKqoubQEoyvxJ5Zemt9hlwgePbzUzD24wuSNqRq\r\nn9TFC7Aw0rvZQ7YkyLM+swhz4RXwTqvayTFRe79IQkyAtbsZGNaTX8Y4VGQJ\r\nRqxEizwwcSCyp65SostS6UiusoP7r8xfsWUDJLbOF1jq+TWVMiQiUHNgp/TE\r\nSXRGXlNP+X395c0Y7wDY5EwQ0OgJFUj8odU=\r\n=Rg0f\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"9347e4194307c28b7a8f0d71ef2454cd1f91686d","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","itty-router":"3.0.10","@whatwg-node/fetch":"0.5.3","@whatwg-node/server":"0.5.1-alpha-20221229234839-9347e41"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.0.3-alpha-20221229234839-9347e41_1672357732828_0.9081766976657932","host":"s3://npm-registry-packages"}},"0.0.3-alpha-20221230002545-d84fa28":{"name":"@whatwg-node/router","version":"0.0.3-alpha-20221230002545-d84fa28","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.0.3-alpha-20221230002545-d84fa28","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"3bbacd21399635b82b68070ee86592e3f04c5f94","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.0.3-alpha-20221230002545-d84fa28.tgz","fileCount":6,"integrity":"sha512-8P8XqjmgWQUL/S/EwS1DeqzReZ451OU4gqlTS3Zb6xmHGAp3s6CqhZtWbghKPVmy++BRnK16ejUnMGK+m5VBAA==","signatures":[{"sig":"MEUCIQCHnaDHpDGMg1+ED91j95oh5pP1wBuyvsKlF4PQz4kwqgIgLMZo9fmMUTqDfgN6l9ageCOKd67XRZQd/tloDBdHKTw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5044,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjrjAVACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrZnQ//cCZzPkti81Co7/x480Q2/a7pkfF7lamsGf/2xSuP/dMuQEDF\r\nMkvXoCvZtijer02PvqazInlIaV8qtQ7XNOmoqIXLhYmUIKQah8ZinQabEegP\r\n0U2MJo6Hb8IX3EjUjmytOyktKJsQK2sKmvfsozBtRBJd18NPcDwGEATrUNEH\r\nN5j1lly9cXiyWTmqwlZWztho3keNp3Oq8cC58pIB9AoSqpHou5EYAYGZNiuS\r\n+1zlVguuEMB92utCsQG9HAx5anImcGCYgDGiT5cqw1+IST1RSBK4f87tHdcr\r\n9NEmUa0oyFccjVIZ9NjgvuQC+gFQMc2awgNOe/CVuUjwoSQiGQqAwB3E8UeY\r\nDLvpBbxoBGDrsww4kIYUmaAJztiB5c32tWQT6GRx5+VxXGEV+BmJFccjrpRb\r\nCRfzvh9q06TYami2aMjDCjR9qpa6Wf3TzPqM0e7gPXYfU1PG+panKnZkLjo6\r\n3vXmVPq/3EPZfksP24zWhJSs9wC0eiF4Q5kBFcKFc+iA17is9JvfzOb66N+u\r\nmhBsu6se3WTUDRTCbcW+8eKn53CGdp0jBE0QJcALypYgXMK9HloXD7DLcIS+\r\nuR6EDtOxZGPpv2XzJw0dZOE5btS1Aca1mM9aG/kJQdoRAIkvkO303oNPARZq\r\n7TzaF4lhqh+3TU/01XSGpp0V/OiXYEG9T4E=\r\n=ddMS\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"d84fa28cf1d9e55e755b8d271128d5778169f85e","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","itty-router":"3.0.10","@whatwg-node/fetch":"0.5.3","@whatwg-node/server":"0.5.1-alpha-20221230002545-d84fa28"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.0.3-alpha-20221230002545-d84fa28_1672359956903_0.9023679756789447","host":"s3://npm-registry-packages"}},"0.0.3-alpha-20221230002610-34d2b2e":{"name":"@whatwg-node/router","version":"0.0.3-alpha-20221230002610-34d2b2e","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.0.3-alpha-20221230002610-34d2b2e","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"45b1aca766980867d4936d3e4bd7a10c8ed27451","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.0.3-alpha-20221230002610-34d2b2e.tgz","fileCount":6,"integrity":"sha512-yDJmtaT2HMj8BKa8UqsTaxX2CZnZhmLyDFYnBffr1R/rB8mBFnR8pWWObcfjtdxSTl5QEZkM/OwfnwUIoZCt5g==","signatures":[{"sig":"MEQCIErmChC/ZgraNEXubPY6YNSGjyKyVtUPtwSKRi4bSjs0AiAXPHwwAcFsBUW5JnskP6VvjSnrQjTN7P4RYSekocorFw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5044,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjrjAzACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrsZg//axDigpd8Jz5Ps/Us+64sR/AkTRLGqLN925VhOqtBGx+FkY2S\r\n2I7JUFUmLLLDUH/j0TuPc/N0kZW4ExuSniwpN2dO5JYQd5gBmWRYVaW+y5eg\r\nXAr895+H70Hv44YvAme47Nq6Vct9tEfP6ajuu0ZHhbaM2Y2Ek6nzbe2kenGE\r\nyJr5365iTmfPskc2KnOKqT8aJpFfFQDBj7b7aXnhC+hWSnUYMofdGQ/eHKfA\r\nq/5oKqOnI1wi93bM8WXxoc9rbMzJbpSP2Hkx8s7vm+ov3AFA7Z56eIBtaYJp\r\ncb9Xt0cihPgjm2ZkEHzit6BDWbmw//xF6HTp6++fIqDvkiZEJdf1GG9NYyZP\r\nil9dRYkltv3lyW9Qn9WnKOyRBukBi/QxLVNC6eD7gfLboMGh2YLsMVnL3TC6\r\nxhYQGbJ6huv2O9m6/pLmTH2/pCsxsCDmUMBZQEh8m38Y94sLc8buo0ikfdrs\r\nbMHX5ropdYLXa4XPmUwmaHF5J4Oz6uvD+yvJ9FLsafJ+jLUGjsRrxEEmEtwy\r\nmGg8IDeERfoE8ZUOCLucNnKFJeWRVEJqqNi3gyASkwqZd8a/7GncO/EubWpZ\r\nClrEmi/DV4YbTeVTn/L0dUa64ucM9MOjfMI6TnxxiyDZ1HxTjKRQQq5w1Ooh\r\nnCnYlV3qi7H5+uwCPxC5kXFpXGzYWlBpo+k=\r\n=SKeb\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"34d2b2e1ea4b21121d9eade7a30e52aa90aa1146","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","itty-router":"3.0.10","@whatwg-node/fetch":"0.5.3","@whatwg-node/server":"0.5.1-alpha-20221230002610-34d2b2e"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.0.3-alpha-20221230002610-34d2b2e_1672359987001_0.8745947970273318","host":"s3://npm-registry-packages"}},"0.0.3-alpha-20221230002923-0c64426":{"name":"@whatwg-node/router","version":"0.0.3-alpha-20221230002923-0c64426","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.0.3-alpha-20221230002923-0c64426","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"f125e72879f9681a47011adfcf608b1a9ab46c92","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.0.3-alpha-20221230002923-0c64426.tgz","fileCount":6,"integrity":"sha512-nSNMShzMQMq0LLwqpsHJqHoSfZMk326uHjKCFr+PV5ik3MS3Bt+RK/LAm8pG5mw+dzBBHqg3OBx3eIBtbkH57g==","signatures":[{"sig":"MEYCIQCjhRS961gzlP7mVsYSPdDhA/tn8BgDlQPgq5yR45xx7gIhAMylvnstcJLVoOOGcEnWnaBPlNPUVMiLLVxAHRgzxs2q","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5073,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjrjDwACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmr8sA/9HtmwGZE1aHDv5CMfV0dM4JkUWyIMN0b6pHwvURiDrTysLGDM\r\nIjZIEUZtm+VBOEUiTcfsM3eE85Lx9A5rqLZ6DR+MirkMqR/uQXzguy771zGA\r\ngujTtLpBuU3NWfkEGJ/DeTRu9vbaOI31o1kDoPDPKTzidNCkq1ej5K70lEMc\r\nyMGySc1+aIqxHnXBzCBBLVf0BXMrl/uCk5R+SvlsGnAsUt38UCYQNOUChEHR\r\nhidZcjoHLKGRDURCvXp7yf4/XxQYV0BoBTlyB7CH4qg9xUb7Xtmf4epPQjfv\r\naq+DuSZ88yuJ4mfKVXWh89P6eyzaoC+uzOExkaYFSAAwAupMkKFQ0dLyVRrk\r\nTFLspjn29gjEQmBXRo4Eb7Sx8g6m2UEzsp8YcQKMsxHD+5Wx78zG2JQkVOef\r\n8zp8bGf35xCRyH/nCPcyX5jqtGXSC8j5hJEYyT7YwApcZFjQZfv3QTCJPF6U\r\nkPya5Zh+zKzt5sFEEU2o1xhem5/OJypnwMTOoe/Jz34CcuKjQpbE2j643Yov\r\nM8EtvM8QnYFUWLQw1S6wz/QqrIazBLCKjS9LwG7xhN8fUrdHV+HJMuthorne\r\n08Irhdri/1gHqMpYfN0k2C8BHNFb9ahOnjp8CZDGHOc+u83rucuVXal/gCV7\r\ny4+3kiEfollQCd4G8nJ5bftqWW84LGyNq/c=\r\n=cxi1\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"0c64426466e4f2f2e0051a999fb273abab0f327e","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","itty-router":"3.0.10","@whatwg-node/fetch":"0.5.4-alpha-20221230002923-0c64426","@whatwg-node/server":"0.5.1-alpha-20221230002923-0c64426"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.0.3-alpha-20221230002923-0c64426_1672360176132_0.9563184032008352","host":"s3://npm-registry-packages"}},"0.0.3-alpha-20221230003229-556f2f2":{"name":"@whatwg-node/router","version":"0.0.3-alpha-20221230003229-556f2f2","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.0.3-alpha-20221230003229-556f2f2","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"a1dfea67c5e3f5d65c19296d821c32073e23312f","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.0.3-alpha-20221230003229-556f2f2.tgz","fileCount":6,"integrity":"sha512-0SIVqquZs+kxSAK31U2uDV1YM1bcGQ1nNXcHFxL6t4ZPCIur/HF3BU/EIn2v9EKBLVT1KGSuAEzO84PM16EcBA==","signatures":[{"sig":"MEUCICNRAhpvL/+MyXi2JELEPEwzptDB10upGXySJMj+FZ5MAiEAh8h0kjlK/WhGkbCkhh3LY7BMvP/yeEdo/Nfxb0AcqRU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5073,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjrjGrACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmouoQ/7BDjAFE1fI0/JrWFs4PhZy76tXbK/HVHp/iVn2IX/2hzNFUSn\r\nyrKk6K/MHQ/pKiK/EfaIKGgltGbzedHDjuinPgjNM2beEcOFG28/RD1ZQYpw\r\nzLgxmGSX/sQ3bauaSZ9y0CxptOC1T/46nJKIvLrjDkPpBsyPjaH1327W1OB3\r\nSXoC9cHDdt83FUFu/3btyNC5/rt+veoZ/We/l5NhYQXwdMrtEq+Trw7yJ13z\r\nV7vpvP1N40VLAJMzC0dBe/CIvgzdrB/VeOXDEQ5/Af7JFV3nvCsaSmRSh3wU\r\nQ6N0CTmxkD6r75fXdPHVoxj7jS3/EinTDjgwx2X1LmE3H2IFqVk8LKFELBqC\r\n9u8YHshayaDTPA4xAh4ufu4vUOihoB0B6+w7DquMvdlSf+TcFaMTEIXsE02Z\r\nSxBDqODcUvn0ytjQG0tmBzltIlMUnHk+acRuAuoTPHPvwnGPYLpjUGlHbcPq\r\nppTAhFgqCOCzDhekX8trJZbHlaAyUsYsGUZ1X7GS9OIraJe6pBnxQcLwQ7MI\r\nDSj27ygaakvqcqcTETAq5fRPVGS2rVx6iXHDppWLDwqf18i8DNSiglWIIoD7\r\nPiKwb1y8U1DENMdx5ZbpB+rNJGqbqjh8sBOV02V7RN8pAaqviMItbzHo60NE\r\n6fDK1TtASvf3x8ZFEFg2MJLCcnqhSFshKqQ=\r\n=Ez9s\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"556f2f239b7d553b21dee205f4de33ea1fc231da","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","itty-router":"3.0.10","@whatwg-node/fetch":"0.5.4-alpha-20221230003229-556f2f2","@whatwg-node/server":"0.5.1-alpha-20221230003229-556f2f2"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.0.3-alpha-20221230003229-556f2f2_1672360363101_0.7683150069982589","host":"s3://npm-registry-packages"}},"0.0.3-alpha-20221230012104-11e4902":{"name":"@whatwg-node/router","version":"0.0.3-alpha-20221230012104-11e4902","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.0.3-alpha-20221230012104-11e4902","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"66bb9fbdf9e08bbb0839824b37e716b419da0595","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.0.3-alpha-20221230012104-11e4902.tgz","fileCount":6,"integrity":"sha512-uNxmVGR6vaUa0aVwMXOYZqD7aj2xeXYzGbBHai/melKjqFF9OqrYoJ2PPooxS76ssr9qXOvUeosZLKZYy79bpA==","signatures":[{"sig":"MEYCIQDKtfe1+Denfa12i09qfy6mlGnJ4oeLCayGGdRKLVHknAIhALldlVPam26fRZ6GUybodYyMdxetJ3ph5maNEtyDoYT8","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5073,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjrj0RACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpabQ/+OGkYPHBPJU+2UlbT1opFvVuo7Yal6hSqUW6idxCCAxF3I5Kh\r\nK47reCNZMmEb5G9uqkHSbhS/0Xm03XPkPcs4YPFtqt3WVwz7kYqXy28npBzJ\r\nURkTjsSd0Ge3S1zJzyZLtiZTA7Sw8e6VP9Qy9fsOPq/Th3I1rJYOaPZrI3vt\r\nM04IdJTiRHfDAGtdPJo/UUrjjxvupqNfCimJaL3aFXmpb/qQ7m5+F/uweTRQ\r\nNYnUl+f8yukwqHmWxVN/z+dzTy5/gB9XNMrl5wOslUMhWqhQFAX//NXt4JRF\r\nLqFhEwQcNKz2bN/rHf4lUOkRsXfNYKpBLyJcz3b43myybzgh4O+4CwejiVIv\r\nbgTJycZ6vPNSjrxh1KB+NQBO/tn6+GUslJRJY1CqQPiGuIQFjzQUeZg06tu1\r\nJ1IGaSbgRsYHkGdTb+D0KSFue9Dymq4SBXdQL7ppnu/37yiEI4Wvb1lAJT+e\r\ntSTrTq4JI03mEgBSyGN9vxWNMi68Y5Mqh70UgXdvqUDmqdxqJMhYCzDV49QC\r\nAnMfZP5ono4DvzoBFagu3SRu22k1u+X2OwhyvtH53FOdenj7jF/La7HvIl7Y\r\ndc2ZPG8gOi55BV85ePayVxN8wL0nspkOiBu6D47RIy4t2J0RCnXDVrCYZ9sK\r\nbF9Pi7eUUQ7ffvVbtNY0m903gtdayLXzLzY=\r\n=gNuj\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"11e49023fac46f9bbb3a9afa1d6e7bba03def699","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","itty-router":"3.0.11","@whatwg-node/fetch":"0.5.4-alpha-20221230012104-11e4902","@whatwg-node/server":"0.5.1-alpha-20221230012104-11e4902"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.0.3-alpha-20221230012104-11e4902_1672363280951_0.8892663238577296","host":"s3://npm-registry-packages"}},"0.0.3":{"name":"@whatwg-node/router","version":"0.0.3","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.0.3","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"0662f5ad407f2768fb074297ddaeed9395fa7225","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.0.3.tgz","fileCount":6,"integrity":"sha512-D9iB4Fw4VoACOw8sbKDENHoVJBTcfr4wx7reEV8FSEDhOVomjy29cSc8tnxPn3u3USyzV1EBdeJGCbfWhAEe1A==","signatures":[{"sig":"MEUCIChksuBH6Pzuz0eN7xeKGO8lEhKxBsqiohqk6zgwKeFQAiEAyyuluJYhZCjD0PhGfkjSLeR1iAT3yMgF+0zGk3NT9QM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":4986,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjrj2BACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpfCg/+JJCIb+IaULNvFfdYlyUbPjmc7SFtJUAH9bNO7+vP+tVq0iU9\r\nMe39GYb2YKoV4w7P05AJ9yrfz6907Bg0GlhUVjTmMUpqnh0liTKMZZEyYbo7\r\naXf9bkaerJsPC5fEPYfYjjNv4Mksvl8tRYsS49fezqXP4v+okJZ6UM6jgo5b\r\njHdilm3sqqC4O62zE6CGPHP0DwaJrnKcZjEJ8U+LQfBPN9E/YI3V9YBaEZP8\r\nJvaP0aeTUO/bXcrbh6DwuC6J/63yInVhN2z2fWXfNxVCUWxnQFELk0If8FTL\r\nB4f06ZoxGky3sIzMiaraZATE6WznvXXkAOEFh+Wdu8IVNkTuq2IYGjkPNg/H\r\nn2preICe2k6A8LaAQYmdCns9DaBIphLoUZvUGkWytvg7ItE02XmsJFrOjO2U\r\nGDAh31QB+W3BhVOzo8EL2Wp38CaWkIhboTvw2QVJPZ072p2siY1QkwW4Qyft\r\n93P7SVKD84bvxvo536pugJkIroMZutsLx6c456SM73XOYlZ9xM86uQJorx8G\r\nNihir5mQiP6OTvLZzxF9j97947VOpEbVmEzqksKyEBoc+kQzlVF1fLMGzqnR\r\nhMj5Z4iIxt8oPOepXXTGnMjJ4o/yNqyMdE6SL8nGGGJxYXAbUdbfM3u2yRL3\r\nuMqLwW0+pwX2amqzgioNXRpef5FlsEwt5WI=\r\n=tnBm\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"a6ff4e4ab6a9c7ee7f20187dddd0b415deca9f39","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","itty-router":"3.0.11","@whatwg-node/fetch":"0.5.4","@whatwg-node/server":"0.5.1"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.0.3_1672363393676_0.8139341445444088","host":"s3://npm-registry-packages"}},"0.0.4-alpha-20221230075257-cc3a93b":{"name":"@whatwg-node/router","version":"0.0.4-alpha-20221230075257-cc3a93b","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.0.4-alpha-20221230075257-cc3a93b","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"26a7c21b9be4154b633284b2279a85d0074573de","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.0.4-alpha-20221230075257-cc3a93b.tgz","fileCount":6,"integrity":"sha512-rz6fkbjAG0jZVamFoCyNzWk8uRe11U2iGEm0pVioz+OMj3drmHCvnNsXgp5UX7Xct2qPp65I7urPDHNjaW/wOA==","signatures":[{"sig":"MEUCIA7LL5N5OO/qBrlGLxGRLszmGUldgQe6LahrjRIZJVL1AiEA4n9QuZm7fSREoDc14m0T/ce7flC+r/EO2qUCLCuGRnU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5073,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjrpjqACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmoo4A//TJ5B7qtTT6u+By8zcyUflnPYxOpZ1w2FAy8KpGCJ/ubGx6aO\r\naK9RD2Mv+2vjmKKdNiZdeWn6gKd4XyHaS5UgAA9Smhi7cC61KWIL9fy/KfT4\r\nBu6yMmVqBp3LcLvxBphHsqpeYmIszddeKhxLV6B+7GLSxrFEhGJQrC9FYEIH\r\n42KuzplK9BBUa82r3QNb/ZQwBLF1hDSmVR6Vbp3RY/n/cSaKP3JOCA/KCLOw\r\njUGUerALvSRhtv6Z49pYXoTEOARyIkoYfzXsYXeOszxSTWTY/E95oXBa2VgH\r\nsY2vAdb3Djzy6G9ZjAXMDlwf//vkF/vx5L9obyNgB3sDC9pcvvhvQ6eAHUGj\r\n+splkmsTePsJwqgZnitjyBtLAbsgbtO8Mhot/10lN8j/LT631rjulhFsE4nZ\r\nAR+7Ibblqpdj4dt/RiRTwH2vJQRy0gZUUoqyQQETK+v5FozCW7JhaXURPAQt\r\nHM2mIVeTxEfcQDg9HJXea9ga3ga2gaFawc8SeXAaaRg+7oUIvsZOdUTuTCgC\r\n7ESE+Gn1nHPW+ZJawrYOYhpxGPOhvLix0ap4b7nZHqxYKrujlS+XsbTosv0P\r\nz27sSLvl1gwnP+rZCbxwdfvX8G2Iaky3QDGDXI4B6UH+yD4TgUqXl0uX9C3Z\r\nbcYoZtmd8u0B95szgQbqy4/B+R4nHjh/Qrg=\r\n=j2gv\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"cc3a93b9aaa07a84aab5da65f84ad9d8b68ca1f2","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","itty-router":"3.0.11","@whatwg-node/fetch":"0.5.5-alpha-20221230075257-cc3a93b","@whatwg-node/server":"0.5.2-alpha-20221230075257-cc3a93b"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.0.4-alpha-20221230075257-cc3a93b_1672386794557_0.9275621156373668","host":"s3://npm-registry-packages"}},"0.0.4-alpha-20221230080146-72104f6":{"name":"@whatwg-node/router","version":"0.0.4-alpha-20221230080146-72104f6","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.0.4-alpha-20221230080146-72104f6","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"08fd2a21fe6cefb8b954f81ca91a571226e0b630","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.0.4-alpha-20221230080146-72104f6.tgz","fileCount":6,"integrity":"sha512-ThBzvGAqEF6mI2iYYKt0SZNyqp8ypabBoZO8PPepPjQ2aQON2nPQsIkvnCOYsk0Soy9jLKYGszZYXNhwb1MNLg==","signatures":[{"sig":"MEUCIDBKvzskmKdmjOW2uYfiD+3asigw30wzWRiJtb3GHtrjAiEAvoAmavERM7xvYg9wvrWNtD10t4yZx48R28FdzHzELJw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5073,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjrpr5ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmozahAAgDD5gnMMiOZ7/FfpCFzbfgP9uAsQmT2Vy0xVc4/Vx/ZTN8sg\r\nmgRWVSKB3bT4UY8A/lwnYclZl5qx6mYSEfKN+uOg9a31zuPZmlLC4Vi5yokt\r\np40ws7yNJ4xPxIvMfCBu3AiH4MLvHw4KJaqX3he25YX6rQMYcW0mY+WD1IwJ\r\nAlMDDomMJ2XeL+Y/9xlGpwho275aiQ0xiDCULTdJjPA1K5XQHBnF5AYofHs5\r\nsnmUYfuqxYFwi/XH05QEsepyjQueGxQbbAYIrJ8heTY/13NkVYFiV/2NjaW/\r\n43nRZr3MqVRZ152+pcVwFpQvIMYj3iBqthLk0pvt8Y8D3PBPSzRXU4wcmCfd\r\n2ndEHJtHImEzpHwELtaRT2oqby4F75tA1DAKtb1h/i8Kgk+75PsYlA4FLC40\r\nMLSSh9BMaRMAuqfMAjbZ+hjmEjmkzv8nbvqpZ5RRCKEd2ZRDJx6ZaobvlXZg\r\nqwOD+j38zjCUBJscRj5INdaEgQKeWURoH+MqBfiC39qKPM+LsOxEZbhA+A9t\r\nRCPeb6oXYkLkdcX5pPhQ3wZnHihzLi2a32PGt3lZ0R0EPo2cePeXV/MWcFDd\r\nGyqrkgKRswsGtW4YuiVs7ZWKPMEv0c59e5ffgBkzUkTP+F9+9MSJxEZ7e9UB\r\noYMHn5ycKySUHXmJUiFi5kbIXlCu3YQW02c=\r\n=feXb\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"72104f67255a969a403746ce35bd74abe1f0864b","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","itty-router":"3.0.11","@whatwg-node/fetch":"0.5.5-alpha-20221230080146-72104f6","@whatwg-node/server":"0.5.2-alpha-20221230080146-72104f6"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.0.4-alpha-20221230080146-72104f6_1672387321179_0.6409141652367691","host":"s3://npm-registry-packages"}},"0.0.4-alpha-20221230080207-dec357b":{"name":"@whatwg-node/router","version":"0.0.4-alpha-20221230080207-dec357b","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.0.4-alpha-20221230080207-dec357b","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"90a577b4d257d83ba9c5a275e5bf39c53a269047","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.0.4-alpha-20221230080207-dec357b.tgz","fileCount":6,"integrity":"sha512-n3WJR3AOTCaA5BuK1SSO6Ye9INPjGJ01yh4unB/OTvRTcXmE3gq9kj7N32Rlx6TQa6Rz/xrM7p1NTbETu/pGRA==","signatures":[{"sig":"MEYCIQDm4L7d4A+2QF1VMbW3sPJAcZLo5ykymIliMXxQ6aZhewIhAIB5+ZidTFbhW6gqAtTKSDkg5eHONHzlHnBwWISS3dmJ","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5073,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjrpsRACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrEKQ//cMtGga923iAXSVnO91T8lhbWisF6phAgsFDGqe0vvKsgWJT8\r\nAYd1yV7B/ZU/Va0jn0+S9x80h5pZThFGPAMlmZPZ1eF8ccmOF01dCm6dOFy3\r\nI/s83FUdJNbHWF9nfb6SyizfQGesA2jdC32Z5EJjaewO9hGUg7giyebBqqtw\r\nI3Z8Vvn6h/7FPOOJQDuEoZXOdGCWRYf49gu6nY7AN39KsMJg4/22mEr6OVVy\r\no1N0/l/cG597QoezCES8JU3hcwNCU/F2gYAhxvHGu6pXWPhrbZiZmg7bf7DS\r\ndlDbhPW5AShPAbU2uujdPaknu2eRMrYsfgIfAiEBx0pR/I8N7Xf9DMlLdXRp\r\nUMTDVMmrcGxXt5vd00hPobfPUEbh0X5+kmKuQpaMWbkcUZn0Nzh34UPJt8ko\r\nQvW3vGpdufmk5kBUlCPrBeqoyMAnpDWevCMHerpkbmpH0lp6emg/T/rnuIc2\r\nZGEpX7PmcV6cs9XER9X9VeElxCIcMyLV0Hh4YQDKX8ACRz+mAAHfYhwt5VP5\r\n2o804mKupRaK5D12EVrUVMUZg+oC4g9dYFZW7/tlIogc4JEEVjU3xL453CP4\r\nYQDXbEyaIKEYYI+ojSV0yyzFAh7n3bK3Sat4tiKF0sXBDt8nIZBAS2GwZUKw\r\njijYsWubUu6bMNFaIIKiiOOA8qnUFQ+0j94=\r\n=t+K2\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"dec357b95b1b2a96ea9e83b821f3ce49630e7f74","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","itty-router":"3.0.11","@whatwg-node/fetch":"0.5.5-alpha-20221230080207-dec357b","@whatwg-node/server":"0.5.2-alpha-20221230080207-dec357b"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.0.4-alpha-20221230080207-dec357b_1672387344904_0.9794858394172081","host":"s3://npm-registry-packages"}},"0.0.4-alpha-20221230081647-5963234":{"name":"@whatwg-node/router","version":"0.0.4-alpha-20221230081647-5963234","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.0.4-alpha-20221230081647-5963234","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"7538425a2514ef2388b7d02e1c0c9725a1ad900d","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.0.4-alpha-20221230081647-5963234.tgz","fileCount":6,"integrity":"sha512-Qqy1Ekr6T/VVuy14qLGIVChbYOevqK2ISZd7Zatvea1sVSI9G9TrGHtcQK8BZzz9yutFXC249ShyV8WJShK20w==","signatures":[{"sig":"MEUCICEUvJ8ZjXypUQRSoF26cwDrBD9qzpybySyx/2OQ37gHAiEAzbYI/7pv/I41rKzB+PD7ENpv7IPRfPzTgQNyXmOj8MA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5073,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjrp5+ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpOXw//bHOxWnx9r/OtgcXSp2Qrlxlmx3dOWRJ91tJZRHY7rxvjMXzU\r\n4BWcQSSBgVqBycnZWzsVFbu5V9b/MJjb0sXZum4SB12PJI+T9//psK1OVIdb\r\n7OvsGCaWiiMYzNG5sMvLzBvCby3TM736dKxy7xMmdcdX/dO9i5YocVOYzlNe\r\nAOZf30F+Hi0Ij7E5CIMY/tpGfmOBxZZCtfBzV1ahnOWRqJ84/J+GQgbVXHhC\r\nR9TOT05djrldvJqEv2SvRqwnwgAbAzGUg3GxrEWrq9I5b5lriYGR+s4LfcX+\r\nB/Rrz5QgYfl/+qYdVJb7OASQvEEF+G8nANW5ppp/ARqwvP1yH/ZwxJNQKIZf\r\noMk2Hkc+C/+QYsE0m6yPl9hcJZAHr09u6B3F0rciO5mdbzqMsWJydTGvFNAg\r\nM38XbSzoIXNSxPnaiI0NOGGNaAlBRvjGSGUFhYAPVWM+Uj35dRq/i02WHahi\r\nbe6w2ktcKywyBHGiZyvzC/VnoXCbbvAaU66dSk4/bz5jWvjf5yH65z6Dtt3M\r\nkhhxMnw1le4VRqr05lwRlKot5kdIJceZfpmhUoim+bxwD+4xrqBF805fvnDM\r\nWwBS03rYlSBYPzzEic0NOLGmc4VtWWHzKDC65rGpOu8G2HuJ81nPOdn5tl2H\r\n2Hu1hvBFCjlesUbTG0twIdGhyto8RtO1y/k=\r\n=0Acd\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"59632348b6dac3d5275fa484b2cc89ca4597997c","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","itty-router":"3.0.11","@whatwg-node/fetch":"0.5.5-alpha-20221230081647-5963234","@whatwg-node/server":"0.5.2-alpha-20221230081647-5963234"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.0.4-alpha-20221230081647-5963234_1672388222685_0.6056431967102969","host":"s3://npm-registry-packages"}},"0.0.4-alpha-20221230091810-6546310":{"name":"@whatwg-node/router","version":"0.0.4-alpha-20221230091810-6546310","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.0.4-alpha-20221230091810-6546310","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"4b57891ae814b983cb97425418d36a34e3aeb6d8","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.0.4-alpha-20221230091810-6546310.tgz","fileCount":6,"integrity":"sha512-XR0/J8+wTKBm9gjmGgJ2QiEOO8Td+ZqIH0k1rBbfaT4QgUwmPO58x+NNBAU0O41DMTVxpGG/qAU67/o46Bj4sg==","signatures":[{"sig":"MEUCIQD35LejthjLxAjrmUsad88Q2/kl0bQug8sujN2Ks8D5yAIgCAmo/D2LD5/RnP7kSP0Rv64s4Q/s69hFFrAM64HiqZE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5073,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjrqziACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmoy6g//aprk2JpLsb7Fc6JlS4j75mMH48/8rz5hQsLt0Gq5GeM45ws9\r\nFk3WVNnbVKyreZCs9dkNJUb2pnXn5WZmak764bJVpaVH5iGHcX7QdeAaVhWb\r\nm4r51nfRfiW0mGtsIw7+C0iC/B6NjhQhsd53M56aE+HrjeiHDtAZ77oc5dnt\r\njCW+BDrPghpr4eVW9wn7ofmFkwIQb25k0cq2uFqjSiYgaL+mZb4KDHU9p/7p\r\nYYCIPUGgQRN/p+nIuyTUqhG7TiHslETqRe2ED+dFJ4stNIviMdNjgXPANFEn\r\ni2uH8FS2YoYXLkZmDa2BuPOIShyySQA0VYWijjpzhSbAhBR9VGbGYGo1prRW\r\nUuHFBLhXXsHYGnxI2AaXxNk4/T2KphfvVTmtQC0RKEW7N7nAoQ8WtI/y6kCT\r\nhEnCL66YMvqR0uCkj22Vaaui5icaXZkA5gvMWira2Iwr03d+1awsvdapboVy\r\n9gTo4ZNshgQ18UTsUB0FESQIQ4l8lVi46NowiGZ5IbRhakKPRrBr3mV0lTCx\r\nvpdCnhh4CJOluOcfsRQFU6O8KJCvUBrdO7ZrNAYPMe6JT+PKkvuv3KXWi4R7\r\nK0wVLjrz6oLjiDf2rdX9RHDyuUeyNHJp83nSh3bNub1HuPg4/5h8mm2y6tqq\r\nzzMminvwwKTWRZ8rM6+9003Ww1LEtQrubEI=\r\n=4/WT\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"65463109fcd69acbef9b6300fecb8dd0e118be8a","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","itty-router":"3.0.11","@whatwg-node/fetch":"0.5.5-alpha-20221230091810-6546310","@whatwg-node/server":"0.5.2-alpha-20221230091810-6546310"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.0.4-alpha-20221230091810-6546310_1672391906163_0.5015185756790514","host":"s3://npm-registry-packages"}},"0.1.0-alpha-20230102083143-994de43":{"name":"@whatwg-node/router","version":"0.1.0-alpha-20230102083143-994de43","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.1.0-alpha-20230102083143-994de43","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"7c75b4c08ad5f7fa84a8e953a4314490083f08c8","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.1.0-alpha-20230102083143-994de43.tgz","fileCount":6,"integrity":"sha512-naQTJbGf2qCXAbyCrW4KtKdb/ZSB3/YG8jHebexMmcvmOI3gpoDdYJxXqi1AgpUrJ8r9JeCjWa6eECFsRFqnuw==","signatures":[{"sig":"MEYCIQDwf3ANlUUk4NpVocWxMEz/3t2dlI3aRzvN7WKLmevVzwIhAL4zxOM5Jt5FtpaOSfuDExDty5A+TrElo8t3MnxZvnZm","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":11725,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjspZ8ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmrhhg/8DnqdVa/21tvsMCbJnJgx0aiawaES1qUSDG4cUla56vFTspdn\r\nc316ftZZlJVqL9ZTz0YIkiWuHjAn4U/MMtibCQXAPqAiA9wtUjFiC6aXwaE1\r\n+4cly4MW2npc/5GuB6YlJ8SQ29Kdcx6RHMeXQoXg0KcQpVaLVHuVw13l8Ttb\r\ntKAmU7emTCxhru4d5ARGZ9Jne0WvjgwRQU7jwzXjQRAdZyyXorMpTqgcl1z3\r\noCrmop08Jg7N0eq+I+BsYdC54SHSIq2B7WiHDsdulx+25UvXdv5V8DgTSa5V\r\nmQnmOD7fyPnhNWNLYQWzfcsdQLFfPCaEW7QgZJnBT/bNSX3fmmEDi6L5iIjG\r\nEBhyXtAL3/6xqskCpfhC/V8uWBVd6bugryy1MBRKxVxOkNknDhP8LRpZvCW8\r\nMmlw9WLt7QSq/UiGiAynDoISsnHCNMxz9rEtykZXs9WDdonnzqgl002oKKdq\r\nVaTa18hHR+SFQ77ywM0fzlcRK8rWuqlYEt/LazaWi7qVWhMrtnjKBdNfvGv7\r\n0Sy478mmIV+9xYhRhK+KR+wgfCnKWaUZQqb5J65IUg+FwEqsB4SJ+xwd4i7x\r\nz9ecmedtR1sqNAn5TvA1/n+FTEajcKos+jFryGYDfw3egLsrf8LoudhRqCQD\r\nPwNjgWKNJpiEbT6ulfDb6uWFohCzQCQPMkw=\r\n=ttNz\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"994de4366ee8fb76334482824493ba7cdc416d0c","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.0-alpha-20230102083143-994de43","@whatwg-node/server":"0.5.2-alpha-20230102083143-994de43"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.1.0-alpha-20230102083143-994de43_1672648315941_0.41208763553650396","host":"s3://npm-registry-packages"}},"0.1.0-alpha-20230102083740-9f85a58":{"name":"@whatwg-node/router","version":"0.1.0-alpha-20230102083740-9f85a58","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.1.0-alpha-20230102083740-9f85a58","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"4f01cdc66044292352b31ec223a600a41cd81abe","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.1.0-alpha-20230102083740-9f85a58.tgz","fileCount":6,"integrity":"sha512-i2zVxdT1cfAX0bzPQF5TKuyayoWziv4QGqKKjLj77+LY7ZKxpXVTJ/uEqJZYKkIBfhfb1Wy26CNtKDCrwiqmwA==","signatures":[{"sig":"MEQCIEYi5rdh+/bt7cxopP/UBPEtLtxzsCeXNNJ7fEP3IeAyAiBxZnbOmCKhv4aXX0iRJfXZlnXmYRLtEP3aqV+Ywe4f8w==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":11800,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjspfiACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmp3pg/8DKRy97gcgAvov1hdip4F72WswHE/86rQb1f6tq6kM6Vd92JK\r\nL4O3kmEyLvXJxtUloISjWXluKwsaHlzDrW4Qxv5UeFVeDb4kJQDPNGOQs4xA\r\nZUiTEOGude88TlzX4htqQqrx7glaeUarPsVtjnUPDDr1frMyyI7r1nJafI/o\r\ny7dXBRtS+p4Eb/H2g7Lb2zPy9LIZ6mm/LWeOVXgyvOCWM8mTJZsL2C7xblP5\r\nhVIUKkz8xk+3r7YVuDcXhNEYh7KM6cPqrSZEYoq4oveINWRuHE2bqTV5ESVb\r\nvV3Bnu196/ksArGXCPWPYNY9x6Z8A5SoiDjzvyg1kifyfdNrLj5J3tG1jeN6\r\nQdTPAeHg0xpftR9IgHMM5Nta1PoUec7ukMBJWGY3H+XLX8HsvgwVxnptDd+6\r\nqjrDbBsNE8RuXJ/iKH4g+Nru6ypWz+HjDrVNA3bFdIMgWFtxWZoSj3mutkTW\r\nFRyALWxRTsCQ65nQZigxgWP8MycQYA7AHmTKqW+ywaF0Crb51fXCULcniT2b\r\nPcqo00oKbuQLXSCDzNkFosZYS/7sE7V89zuv5Uo0CAQhuEELfYXcbEmrtTMt\r\neUiCch2g/BbFGPvbrT4WhqtCZI0vwsR54rS6uZ+SJFlfTVye42Xgcor2w3jT\r\n7GWP1yix4P17mY0P+D2uYii31nwnlPqaJcI=\r\n=lSqo\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"9f85a58d51c15f4a2d1bcfba8f2bd38485e8988f","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.0-alpha-20230102083740-9f85a58","@whatwg-node/server":"0.5.2-alpha-20230102083740-9f85a58"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.1.0-alpha-20230102083740-9f85a58_1672648674439_0.9667152227677045","host":"s3://npm-registry-packages"}},"0.1.0-alpha-20230102083950-79c2f3c":{"name":"@whatwg-node/router","version":"0.1.0-alpha-20230102083950-79c2f3c","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.1.0-alpha-20230102083950-79c2f3c","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"8a76b63fef983245d695c5af7d2c8e58f2e10acb","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.1.0-alpha-20230102083950-79c2f3c.tgz","fileCount":6,"integrity":"sha512-lKIeWyNeiXU+g9hY0l4ZfLgzN1U/9yWmuPlCtNlUfkJquKnD28sW4p+pAtgleedREcWVImJlu4R7yoh8QFbLkg==","signatures":[{"sig":"MEUCIC/kw7CWjOJlMjRgj+44nWgpnaK7IuFkDYG7cJ+HXki0AiEA4WwEtmXQx8cL0toEG7nnEBPihI14h1KCH81dRJ8Mw2U=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":11806,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjsphkACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmqi3A/+MXegFEu5bvQioabpzZIS6At49bKw2wOl3i5bxhfaR/Sqfww/\r\ngjRxQGz3Oa9DbaA8Xy6FW+6W3GUrDnCn1hFvX7ItzlLycUYVFNfkVSIakWNS\r\n30/v56j7aFLFN6974cV5XG92xvuaGT/NwzTt+nus8qX3pA874yYoYfd002wI\r\nm6B71mUSlmlW6ZT895aVHXHwYeoibX8RgSKLYrLljReyVZ6gAZEiJ9uuxcML\r\nGwTTzyGt1pUn3peCq9N3fZ0j5BFwLBsS3fTTsydhs5yrSktolxsGCX4UyhzF\r\nqAp+0c886K1jIQwAkgNyYAAsNpESGwXBoNaNQAS8vpeS2u8Evgaofnaqpu4i\r\nwQ3uhB/KnvLmJCxMx+d3bJrljo1py9ulTUa39cfxUCsJS4D6Bdt4SDI9/I7i\r\nkwDXSBj12nsBtBFCrK+YlDgHOjOL2T2DYIxtlabkm/PQU6jULFuzIahwofeF\r\nh/atNSbLAM1NhZZWQS0gOmfJD4dskJnW0gDoanmpDMlS3vPzBlgI5xbOsHqe\r\nH8lun4ZpYLOjxPHNH05nJ4tFNuYNiGtxVcp8ppKsPGh5wCk7nZtm1YOpcY5V\r\nbAoIwNbnYCPnvYtd+t4QpJTSOUn2AZV/20CvXVAwQBdnBVzFEpOUPjKyMX97\r\nunLG2dFuicNbtQ04vq7RoD5pC+gCwesOtzY=\r\n=15pV\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"79c2f3cf4a13f1d9476bc7fd53751906707f6762","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.0-alpha-20230102083950-79c2f3c","@whatwg-node/server":"0.5.2-alpha-20230102083950-79c2f3c"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.1.0-alpha-20230102083950-79c2f3c_1672648803930_0.6828126899088822","host":"s3://npm-registry-packages"}},"0.1.0-alpha-20230102085949-c0d9fb6":{"name":"@whatwg-node/router","version":"0.1.0-alpha-20230102085949-c0d9fb6","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.1.0-alpha-20230102085949-c0d9fb6","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"96fe093664df9d6c92b255d43cfab440e975e807","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.1.0-alpha-20230102085949-c0d9fb6.tgz","fileCount":6,"integrity":"sha512-sDkjrxy/JPi9V0DBy4fAaaRqbSEL5NaNp6xM4+4yOkyI4OB2sDABM3w6C0fKSACIYlNcy/6K+8+hXWDeAVnI+Q==","signatures":[{"sig":"MEYCIQCHRVhdBk4xs6JlcZSorGgFtSnwjwe4VVSIR6JRZYEsowIhALSnZBrjxN8yUP6ecYehLWKXGhraosfzkzdxSVZ1goxx","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":11040,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjsp0UACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmojyg/9H7Q6cAbsf2aUhzdmgtTaDL/k5Su2v0od2e+wgVXjfe6YYBvz\r\nXuejdpS4R8/vMzyd2FVRbp3g9LRSAr7lxo/ZwvRo1vupDsrEo6OCCTLDnxvL\r\nnIM2UCjVZ9mbr4FwBXJc4kUjDD+5lknLM2JMU8xRoy9miI9m7dQ2rSISU8y0\r\neOiis+mowtsc4Nsn8lUZYBxyMjD6KwxoOTrQP1o/w+ElxOO5EBZDRMjS1PGU\r\nnNg+WkQAMNfqVY6aqWlZjLdF1QWfd75f++0Wcn/xOjPGoz2mdH21r4/mVDfh\r\nHqpJBkgOPcdVaqGBLAVUMSeYulvz+FQv7hEX+aTnDCd7cyQv9AomOkR+UYUj\r\ndIw6BBFABGreKKUdyv4fJKR4mJEV7FbWCNoMMo7OswiAhC4aPZiWtjfCZrDl\r\n2lnM8Qvy7gFh/tKX6Yl72ogTNhP42LmNibTDR0+vN3N5gL2MWGyCVGFYrTMf\r\nq+u/qI99oOCtlDp2dHa7VI6f7kedWUWKyTaLqa/u0Mma8byZz9Nfh+20NDFK\r\n3RhN+VGIscR37B9+VPksrA19/Te50VBj3Tb9LVRuZX+fQhXBnVoQrZdBV8FH\r\nW89n2+oPnHeOeQxUh7CkY22aF9TyFcbLrGZxePtIuuiE5Tx6lBN+W1AndOvY\r\n1EIMwUGxHGApU6yUm51S1eZMgbpGitNca88=\r\n=8NqK\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"c0d9fb651130a85cbcf424d239b00ec958e20783","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.0-alpha-20230102085949-c0d9fb6","@whatwg-node/server":"0.5.2-alpha-20230102085949-c0d9fb6"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.1.0-alpha-20230102085949-c0d9fb6_1672650004514_0.9075226880348981","host":"s3://npm-registry-packages"}},"0.1.0-alpha-20230102090155-ca7176e":{"name":"@whatwg-node/router","version":"0.1.0-alpha-20230102090155-ca7176e","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.1.0-alpha-20230102090155-ca7176e","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"f0e3f5798b6fde9b057c0e0d6f71df8a7950de01","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.1.0-alpha-20230102090155-ca7176e.tgz","fileCount":6,"integrity":"sha512-ef1x9Xp3PacFHhAeCwaS1O+lNFmpZ21UTZyPYVZ8u8jcBlgjJnvKMsDOliGCrDdYmIqazNKAjWoObheuXJIH2g==","signatures":[{"sig":"MEUCIQC5XG62GGU6EMK8Gcg7cf/WlVnXmtO+ZJjMAhT5xUV3agIgAv4cN9KD7j9jXJEim9X68xmbZddv60ZGIKqsaCcDROw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":11040,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjsp2SACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmpqrw/+NhjTDYbp6+qGpy6ddBIrBtegc9xgHmt/DNmKTF/o3QJ4LXSa\r\nYpLZeNbHqUSCpvtZUdQvNDas3ZhpRdw1dlYDoSpysDEnacK3zZAN0haK3DCn\r\np95zsO3/GHvXWLZfj8pGVO5klV8a4b/37+LiS75XpyLQnX3TLvj/g1pqMLSg\r\np7rnfgQN7PLjuz7L+HCzfyZjwaENgvlF+D8zBrd66nkVDQDhvYsbco6rH2fa\r\nPOeHVvYz3uvRMgVJVJ5lNwul7EJ3K098nrDKp8+GCipllzuEQWvQFQ5t8Fo0\r\nZ3Ny1BzkYdRH5O8OAfPcztTjagyQqfTMpocpNTY7CJbhxrMLskuZ1Cz1AeAs\r\nz1jbaoKXPL+3/Nm8KHgAV+TRi5vdqIGociLY1wsf4r0vLGwtAgAwRTQvMTjL\r\nQAtTFq3WcjPwNny6Ixbdk8rUH9MT+knM5SvgsFGRUIHWmgOL5lGMC+8UUb20\r\nf47rcnB3ReKSPsf3gMriVwaRfnYK3nRR2afRH7zZA2alTI/M+EKl8gmfgpTm\r\naFNzx+9fATrQPZbgMstuuwem5weCo73dDOfOE8jgjS8dY1V0c5h8losFy3Sl\r\nfJ1yBZZJ00WAYrCMhmQ8dkJq5KVcvs3PIujK9S0QLA+f+PYwqrdjWn/3X6/4\r\ncPy4k2X97W7KJzxPp3o/O2afQy3tSaWC9xI=\r\n=v1BO\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"ca7176e25638117a93bff73519b921f4e53679f2","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.0-alpha-20230102090155-ca7176e","@whatwg-node/server":"0.5.2-alpha-20230102090155-ca7176e"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.1.0-alpha-20230102090155-ca7176e_1672650130751_0.1294728401435743","host":"s3://npm-registry-packages"}},"0.1.0-alpha-20230102090436-0e536cc":{"name":"@whatwg-node/router","version":"0.1.0-alpha-20230102090436-0e536cc","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.1.0-alpha-20230102090436-0e536cc","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"93f7443ab2727c0e66d2927c43cfd5f9ab2bf68f","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.1.0-alpha-20230102090436-0e536cc.tgz","fileCount":6,"integrity":"sha512-xOn7LuMjUb0xtkc6iFvzVFUX2bX5TFCv80MG/nKiSf+6KhuSCqszgxYaat5EOKVdirgDkWGtt8tevLVUMIybyg==","signatures":[{"sig":"MEUCIQCHmf3rZAUjV5WtQY/yYffnW1WaHJRYlLBma3Jy3/A2agIgTLvyxvLakiTZlJ9l7jgZHcqfUrTOU3S+0CMq4ab6O6o=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":11040,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjsp4zACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqMbBAAo/IirOwN/MNd0kS2Kog8DQ+UxUW3xzY9ufwOWGApSTdODiZ9\r\nZWDAv4stzBDoGakKo5j3wtLqyrOh3h7NmIA3yexdJbK+DRU3aOLrBAdWPKqZ\r\n1gdPMLwqnJg64TDjUj3X0NCMVy6Asomblyz7W/Ff0SttIPK2gwXxFIW7tQ5g\r\n/FFiafOTYri0em+nqE6pKmWIlqLo/qa9/r0uBk+fUAA+jBEnzrjJsMiycAPq\r\n7jCrFrtkWipXZe5LfXC/BEtVpKzb4EDR8sasxsITJCzP0cukKmpercDJjmX0\r\njXBxQxycvPF/FQ9Tww3Ycz5anlJ5h4svx9gr63E1pPNIodbhQygCmSdsXxPz\r\ncar7VJHPyAqyxYd/PEMwGpU8kK5s9UQYzWkvgNhJh01Ahx+v0Tis/DETF/hL\r\nGhEJwp9zyJceIChfhbQClP9+FoNDZG8Ati1vbvR0nhFETz/+ysLUzIbLbvBd\r\ncIxaefG8vbyFaohBcP9qPLr6ZS9azs8VLfBYYGXOhDbD6lsklT2mIJ4fBbGq\r\nAXtcB/5HIZ2yu/FDJkT0ZHVSLWp84+1J+fVJ+d6k+QkSbcphZdnqGpCzCtI6\r\nuPGsyceA2UPuqN8/Haxcmx9qFsJ7yKOpACsWSKvtA1TqrxgMccxBFwI9GSIU\r\n7K6eav4TGlJ+O9s4VnryXkmZz43f0uCiXm0=\r\n=G6/h\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"0e536ccf4d8d96524f3770bb9e63780b3db11d43","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.0-alpha-20230102090436-0e536cc","@whatwg-node/server":"0.5.2-alpha-20230102090436-0e536cc"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.1.0-alpha-20230102090436-0e536cc_1672650291577_0.4655030082882532","host":"s3://npm-registry-packages"}},"0.1.0-alpha-20230102091529-d9879f9":{"name":"@whatwg-node/router","version":"0.1.0-alpha-20230102091529-d9879f9","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.1.0-alpha-20230102091529-d9879f9","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"7ed99468aa316b8ea9592a2b3158388370f2de18","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.1.0-alpha-20230102091529-d9879f9.tgz","fileCount":6,"integrity":"sha512-a4fOqsludaFBXoSvrAn8kYJiKXTGKbJyYo+Nx0fR+JoLfGtUTTpz5DlPCsNEle+tZnterasPg0yETwaTW402IQ==","signatures":[{"sig":"MEUCIQD3lSDFm0B56VoQLwX5SrUHC7IVGK7UT7KQl31RHvl8KwIgFluryQAc9kQGggoOY8hKBohQqKts7O0ZgZhJ0ZZQ3p8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":11018,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjsqDBACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmryEBAAkmhHTF90tuCM4AOk9Jay6rtcjAeil9j3aI8cow+kdBqtZqDQ\r\nacN6RzuQRSf/upe/U9QH8Zu09xLS1I+/w5/BW4AOBffxFJtZFZKABv59orpS\r\nj1r+5rJJ4tkBmUaxgo/isHcfvgQuhaEE5iiL6biIil1a+IFPm+0yqcA1FVLT\r\nRVyKpr6OtYKFIN8DY2QxkRZkVY90dfpt9it1POkL+CX8meBz9U9I2TepeM0/\r\nOJUMfDYuUGgv6yhMKo+mz04yIFPMu3C6sNFawhFTiG4C91TPR6km0xuE0v14\r\n3iYT1lfQHnn6Jfb9HRnFJpTQt/G+1dosTmgKK+asg3EEq60LFj1IVR74xuaK\r\nNoqBvKb+KUvlFU8wkqmBrypoMeCQ2gbH+IfjuXaJJGtoXveZJNtKDIDWzXzj\r\n7vqq9Wrz/We/mPABwa0skLKQIVJv0vEJIfdHq+W0JFz2gFNz0eJc3PDx1FJS\r\nB+RioFDPUIgMbSE1qFiGAVBuYZxM/wpLrrwbEN6sraXFJ1ghL5mg5Svw98my\r\n16xRNTWSOgajjShdWG8KJzRbN3OupLfVtOAP9oBK/KB12QflxWb3GIO+GSYS\r\nB5njwcBIcEfZvk1oJnS/Q2fkdDpA7EMAUpMkekwluUuiNokyeK6Kbhc0lrMp\r\nESH15dz2YmLbcSNI13lAXLuIFkC8DT42SXg=\r\n=1DXx\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"d9879f915999f2e488302b5117cb841fb809aa5a","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.0-alpha-20230102091529-d9879f9","@whatwg-node/server":"0.5.2-alpha-20230102091529-d9879f9"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.1.0-alpha-20230102091529-d9879f9_1672650945272_0.44070956156302254","host":"s3://npm-registry-packages"}},"0.1.0-alpha-20230102092103-b37f339":{"name":"@whatwg-node/router","version":"0.1.0-alpha-20230102092103-b37f339","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.1.0-alpha-20230102092103-b37f339","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"048199d4d23a6b2feecce1a731fb40f435bc0d1b","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.1.0-alpha-20230102092103-b37f339.tgz","fileCount":6,"integrity":"sha512-A24LzfVtFkoJnYPZbdwN+QELje98wbrhPSGGCn08q1U8ZwhJZ4SQqIs/2gthlPVeq9I42Ai4BULRIKHXU1BCBg==","signatures":[{"sig":"MEUCIDLadXvAKm3lzK5QYC+8H4BV238Dyp0/05ksTGln4Ll0AiEAszi5FHhPZ7aZICdZoGMq44K869IrXKJVgOWsnNk1EyM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":11300,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjsqINACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrK6xAAj+ygYnzbQN4c7Fz3DjhHR/pBksK01A0OJZZ0hsqWoMjHoEkq\r\n8bGd36qyk3kK3UfOOu+H59dVmzyVU9NMc9y04l7GpbTD6b2SgXq/0ixi9T86\r\nCQvlPTiJrqKexb4zkiJo1jtohqQff4gFfARGstWN9URy34V0ccOI+zQja0Rk\r\nwNnZwpz/y5LYHxhBqaS2eRxpzW/3RR41AS67Yd/Ph21pzgOWrhKf7/xDJ2ve\r\n0BhDQlX2QuKg/K+xg8qqmyxvl/SH6z+fMFqhTG+Bp3hho6KxRwybnZm3cXva\r\nWcl6c0To7WrkWaxYWdLMEU4ik6n6esZoyHcx0ehc77Rb3DX8K94GCGeTn5BC\r\nQV3lKvGHkTjY7rbXo08ZaCti+NHJ5pPNHkbGSSQJpjncUy1AnhkATjS/6bwr\r\nNzclySjwq2wui4XRHTEVN/+6AqG5BFn2CmymRgEWxAci1g/dntPYyLqzvU/5\r\nEPqMBzb1TB18JA+IPymkM/l9XN+QXlEpI4t1C1cB2VVFf/tXLK5EcaLP0pJp\r\nvs8f/fFX1Qf1z3kkI5MCp73za5t276Lf/Ys5ceXU5pRNA9zG8tdqYp4M5/yj\r\n8DAeOCM77WniJ2CX7XER6n7UKmiTi/4X/MRWFa9XBEFy/qsiSvsATnDnxccr\r\nP9irsSiz4KhKG2RpYUK8nL5ED9FCzfIqZ7g=\r\n=NzKY\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"b37f33912dfca0e331f7d765aa70de9bcc8e0b05","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.0-alpha-20230102092103-b37f339","@whatwg-node/server":"0.5.2-alpha-20230102092103-b37f339"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.1.0-alpha-20230102092103-b37f339_1672651276926_0.5940491513038564","host":"s3://npm-registry-packages"}},"0.1.0-alpha-20230102092905-2ddada0":{"name":"@whatwg-node/router","version":"0.1.0-alpha-20230102092905-2ddada0","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.1.0-alpha-20230102092905-2ddada0","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"069ece16f31b1a4d41513382448303a23412d0af","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.1.0-alpha-20230102092905-2ddada0.tgz","fileCount":6,"integrity":"sha512-4ccN3I6llmVa53SqSBu8bvv//QZJsHDuq6U4BmVIy7mkkGPe5d85U2amXpl/kn8+45DF5Os3nkmvtELEcjLxEg==","signatures":[{"sig":"MEYCIQDq5CZft27YhN2Und0ot1xeSNykAaenUY4Bwxk6MrtlugIhALLnJhdJ8KQGdvvEuuGFVi3rk6HlgXMJv/dGSdHCEkrp","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":11300,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjsqPvACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqrJQ//dhGmnUsZj3XH/Pqh+XkF93wrJkQ8g4jBk0m9yb/pdsvMvVpj\r\nI0Ay1nhAySC6HrbR2qa0K2yjBbbEEgVKytQI1l1RX2tmlyI+FjI3CkI8UUMz\r\nUF0+9IIIanukviPZGL4VpgcEPj4IfRxCi6V0BG/VL2ldjIDRBc5lQ0j2n8Fs\r\nCkNhG0+k8QB67C4uABV9+c/L49mQz/wv64KEUAqG42aV+jnWjotaTVIxtebt\r\n0vHmUS+s/dKNszbc6WjH+RLfSs6OPUQ+yJCsya1f8LjDipqBQi5wjgcESeiA\r\n38VjMsKFm6pbFX1AFxOXfNDWIE9GGuplmU653MVRduokZm5BrClvf4bnj3Fq\r\n4nDrhKiKcRYbvU1ndJlB24htU9b/1C1/y1iEPsu67O4AHoZUes5QRJQHlzr4\r\nGYnZWaXcy7oQkTO7wGHVMr5KEux/Q31ub3OaAuqDSkOAMbjLUN5ujRvbUgUY\r\nvCKcQSEzmrAEIlJR3u2wVjSEC87VN0PSYx/Ty/8VL2T0NfFwjzG9NgYAQPHJ\r\nvfKwmlrJNBTrA7mJsBLezlZLiCtk2C43QKKgUgpyIV+JqIe5DPKG7AfUfyIL\r\noWtXmBFT8EXqPFGxT1KM2sGc1tEnq41S6UwCXFn8pp3rlkFrjsI+wP15Xehl\r\nB8O4P/+hYr2rHZ5cT+VATH1POwbYzEesDbg=\r\n=O9TR\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"2ddada000632d99366123272c5dfdf8e7b5f3c06","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.0-alpha-20230102092905-2ddada0","@whatwg-node/server":"0.5.2-alpha-20230102092905-2ddada0"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.1.0-alpha-20230102092905-2ddada0_1672651758925_0.30545700172573653","host":"s3://npm-registry-packages"}},"0.1.0-alpha-20230102093209-0e66e12":{"name":"@whatwg-node/router","version":"0.1.0-alpha-20230102093209-0e66e12","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.1.0-alpha-20230102093209-0e66e12","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"ef9526462331c04b776202f4b608a78cd19e87a4","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.1.0-alpha-20230102093209-0e66e12.tgz","fileCount":6,"integrity":"sha512-RrwpcjxPglkWbHKVMCV7iBAk9VUeLeDqIkSrus9c2+1hCexBs6kiC1zv9rVcINMqCUCV95HfmZ1lc3xjQ0ADHg==","signatures":[{"sig":"MEQCIBvCCT9tUvwfduYC729DGQ80AShTN2ZCPsoiyiGI2g61AiBJs/n9nn1YvxLeTLghR2E4f4R3jW4BkqvTn7Gzb5ptjQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":11676,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjsqSlACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqZVA/9EyINqN7o+v88+BiPDsbpvK9V7QK4y6kcWWvvrBdr8c3Xlpa1\r\n/Y8WKVJwqUfrf4do6hU9RFvzEOxxycCbm9vsbKtXBB/MWJ8eAZw5doxRC9Nc\r\n6gTfWOpK3yn/SAdCn+G6nGmhue9qge12ZAf0dzOrUAaUPA00o6HEp13eL9WP\r\nhKwlE/N3fEK7EeHYHKUKquvHcsNPr+GEvBxeLvlZaRcuxSssP63xKFO5bKng\r\nJHmWRfCYNSRk26RluBVU93glN0yNt5iLhwbddfM3ubwZ1l49GwbIFmbghhqu\r\nbVgWW7l7owWovERRvavnfV0qFDDibzqBWUmDSwcMsWYgU6LK+eQuNniWhkZn\r\nB2VHP7QqdCFdJhA+YmlO21v1OkHds4AUbWu7rIRfQZy+Z57dLDb4kF1Q8YKw\r\nCasGbB37TZvqk39q9C2YIhvkTZfHUko2XVxgKPbawbrmwkkVL6t7Ur3qMQeo\r\nQnyCGujutwJXnMUfFTUiFPEGF1i5XNfhIpBr7Z9OuYAj+VPSrmS2GZdBhYpi\r\nMxg8YuwyiN72Ozh82bTcUIqt0ICSXeNm5Dn0H5ibUZwYc/kxAir3W16jOhLY\r\nUxFBVOZgIhOVafhJXH+rjk+meQp+hMiru6MNM6SI4cv5PWHx7nzKBLRrhlb2\r\nwgoyNBx/QtWCjed4bsRDH7woE3gwolJbbr4=\r\n=ogWo\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"0e66e124c798cae3eaf8a26a312b9cf904fe145c","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.0-alpha-20230102093209-0e66e12","@whatwg-node/server":"0.5.2-alpha-20230102093209-0e66e12"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.1.0-alpha-20230102093209-0e66e12_1672651941650_0.37694269093744737","host":"s3://npm-registry-packages"}},"0.1.0-alpha-20230102093752-e4b70f6":{"name":"@whatwg-node/router","version":"0.1.0-alpha-20230102093752-e4b70f6","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.1.0-alpha-20230102093752-e4b70f6","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"eb18629c1a60582c6a0de96f4ac3bbbe935940aa","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.1.0-alpha-20230102093752-e4b70f6.tgz","fileCount":6,"integrity":"sha512-/WkbtosbCTQE2ZvjKsuQ3pGyzVi9bi+eJ8zuIqXChmDb9sMEvEn9Ui1tYkKXPYllNE8AWBx+TtFtf+UAXiAO+Q==","signatures":[{"sig":"MEQCIFfhxrRfMzNA0Pga/S01WCd27d7BhAx4Xem736ggK9SLAiAVUzcZAbOsIXQtIOZqtxpZUlbKhBwvyMkYpIyP+Tnt7w==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":11676,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjsqX9ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmo1BA//bgT7T60Kgzle85kQ89yOHXpWoVMChH7BD3rJsOggTQ8wtzKF\r\nwweI5q4v52cOY08W7FwbV9Ys4+2uYe4PtSd8FoGTkFmnWDY0eZuieLxcLOcr\r\nBXDPKXccEULtbPYo7csrXzB+8pK/qRdlETS2sdKzF+1zSxe1qJugAn8LZuky\r\n5lb5NYSo+sbWUE1oTtHirDIRDkQ25VPjqN31XQLx9GPnU5hWKwDD4GjrEVCG\r\n1xCKbCL59D+ifQMDrPYTzSrJjAtFdFdOI12I9pETdc3ncIx0fU4KMZbf+U/4\r\n1WI5R2VLF5oiAE21Rmn+GZVuLKvrUacqgdvQ3ixFwgAH/bt1w5OUuzmAVdN4\r\n+BnYOtCq1wwq3gCjkqsBcOqOauOr+xNQzLpEEfyuaLN71w6PtqbGerpSyUeZ\r\nZJ3mqjlVR4Rx2FTB2gWa8EkOnzA5viwFeDWRk/VBLgF1PjnMKu3ks6ewAY7T\r\nD91ef7zf12246V4YVGFkpC6/BwgXkGvTDy9L4iUB3PavPo9c24hVoTeFwr5G\r\nUbEaI+EktO1gm3fe6sofP1js+wCwMtbfKS0k9BEB/jpgjDUYlYe544tP9nj7\r\ni8q8fk59OgDQJu+MfIsN13xe/h0g+e10YR3h1beoZh7Nly+oY9y+JJY5+2iz\r\n7NIcLPHwA2k+cH6ao1QautE6Qhd1NoDTRGY=\r\n=OOPE\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"e4b70f62f19935874bd38f8025d5a39974bb191f","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.0-alpha-20230102093752-e4b70f6","@whatwg-node/server":"0.5.2-alpha-20230102093752-e4b70f6"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.1.0-alpha-20230102093752-e4b70f6_1672652284900_0.6785041691290787","host":"s3://npm-registry-packages"}},"0.1.0-alpha-20230102094215-153dd37":{"name":"@whatwg-node/router","version":"0.1.0-alpha-20230102094215-153dd37","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.1.0-alpha-20230102094215-153dd37","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"7f332bb70afc9fda7b03bdf4bf4c6016a1b7a569","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.1.0-alpha-20230102094215-153dd37.tgz","fileCount":6,"integrity":"sha512-OymgHTuV6C4FdHO2WDeLotM2I1PmtU1gQG4NlR5XBYwO5QkfoH/F4E6TYHRSCzqUCE3/uP1gCNOrKDVFOTX81g==","signatures":[{"sig":"MEQCIGGfJCrL4D9pLalLVYaEiQZtTNIQwF/mOJlrMEX9JwxjAiBsElbXZf0PUS3lO6QpkhSG5C7jheBqxnB69Q6NVhh9Dg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":12200,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjsqcHACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmph2Q//RdTNnnRnzeDf0INlRLTeIob/sr396fqJ70neEhbOiwogu1BC\r\nq5Hvobg9YvAIQ5YOWb3Ed1Zyj4wNhZVZ9d8G77O+MW4Ii1nNXqzvegf6ctY0\r\nzfnbptqW9opBDrFEnDaw9z6pJlDuUi09YuPChvZv0H8ekcg8THJ1II2fkb2i\r\nsa1hxWsBEs2B+EC257hn8tYB4eZcbruIWBI3VbP0wq2TZpZkkjThAymloZNo\r\nycA7OHhz813yp9pDx0/VxOpwADPlORLeZGAOwmFjKQrlNT04AFQynHxZSYBE\r\n9gfChqcvw3UVcvZkIAYMzvPDXuSwB7JANbNFOnGrKeaS/6rIg5wHhu5/Fw7r\r\ncCUPIWr5QAVI+8fI0or6Rqzr85zzbTXjz0aWHVmu84Ke/aYIJDIkyQMGzI1a\r\nYkeq5YaE5rMgpSv8vyIJzcUQ6YoCJVbWk1P6Ban82ra6Ld4R2lQLtWdOTrSM\r\nBFC/elWPZ6U6dNqPUwv+j/iOVF/GuO+73xH9LDhow2knfIwDt5L+kcHea3rI\r\nk6BDiYs2bnTTd09EfPwruPLUz5o42qaytKvCCIOkgyEQK6ZzUWibS9QwBGSq\r\nznhiyyp4M33NczxjbK3ej4fCglrKeKmbfH0Kxu7aKpyuZmv2cEjAzvucND6Z\r\nmWMS5OEVGuTKoiUfQ4p83Op7kRHZDaQrlaY=\r\n=AgEc\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"153dd37a728fc3db69edbd8f1ff71cba86ddd069","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.0-alpha-20230102094215-153dd37","@whatwg-node/server":"0.5.2-alpha-20230102094215-153dd37"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.1.0-alpha-20230102094215-153dd37_1672652551466_0.31911467592556875","host":"s3://npm-registry-packages"}},"0.1.0-alpha-20230102094417-14e45e1":{"name":"@whatwg-node/router","version":"0.1.0-alpha-20230102094417-14e45e1","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.1.0-alpha-20230102094417-14e45e1","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"77eab6f5e28063e3b5e66ed04261798e23115679","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.1.0-alpha-20230102094417-14e45e1.tgz","fileCount":6,"integrity":"sha512-TU0nrSMbSoSz6Dwy6XZb3yICSQ47QnEEoowKKQyTCRHT/d0rAeiHph9xZweL0aYcT7AkQ3hyUNEVC80+ltsi/w==","signatures":[{"sig":"MEQCIExMJEek5jYUvutpS0Pr6AGzX/D5G+owm4/LzRMhRMrGAiA3LEEdSxS0qlAzyX8sYaVf3DkVHfQQb3OrcJwADiVE0w==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":12200,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjsqd/ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoIdQ/9FPq+bbHZhNx/ry4iuJLc107ZgvsSq9l7hZgOG4YLU6cmfQ86\r\n7eJ3SRrjsXWKPmvmpuAGkcB3XZSVyxxeytsLwFKLCBuTQPJyDkr2YMWt/4uN\r\nYKUSJ4DFGEvtRcNPV0tq3C0fF/T8mjGJwnv1k6u1eF0ptvutywcS7nUEWeRb\r\nkXS7y37lfIhOWubQUymekxdxtvJGxK1fYtoe7bqhqvigzMfKHWBmFkQc0SwF\r\ny15wcJsWafRHAz8f9prg3XjTmjtsLEt5uVv4lzLPIdO9N4ELWe1xyZTmZlf/\r\nCp6XLGCs75blw9b43+7+M8jChhe2PrceZuM5+Q8dNQn8EIlfVr0s05Niq15x\r\ncnm3GbaXf8Djxyu00atslUVb+8VI/0WHWtmJ2/eGxFRp61UzDQRGbjLJFl9r\r\ntik4aitMoJbR8AHqbnHH50nZDt8NBSbU99bu76stAQD/kDNvKQzOWqyNZs8E\r\nCgnbc9BwSj+4xYrcdq9OIWBCwFiRfqvY/NnUS4VM7h3idUWesg8P7QNnQtxZ\r\nImCcn1vvXawBbSnk6l4DKBETg886mj8Eb0dpn2yrEyuXulTkmQFcxz4vosKi\r\nWWQ5FU6QYr7iwiu/EPbpfQllq1kZ3HeuGUmJiUMBfnQxlO4m7revN8xFiZ4L\r\nPmiQXxOZ62v0F+HSRf3C95e8qRigafTz/SA=\r\n=nyXR\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"14e45e103df0fac29fd68e5c43dd97f4f115abc1","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.0-alpha-20230102094417-14e45e1","@whatwg-node/server":"0.5.2-alpha-20230102094417-14e45e1"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.1.0-alpha-20230102094417-14e45e1_1672652671329_0.7971639009752567","host":"s3://npm-registry-packages"}},"0.1.0":{"name":"@whatwg-node/router","version":"0.1.0","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.1.0","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"f9050f72dce958d4bef8fb4e945aef31f3beaa6f","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.1.0.tgz","fileCount":6,"integrity":"sha512-PmU/7286yWFhmPUIHncVoGM3kNMQNCeH3Kf5JmxARLSxaFjeziwrDcLR9xO79Db/gqBB43T8/HXDc+JvvZCAjA==","signatures":[{"sig":"MEUCIE/8ioEcGeeCafsyl4sGIIzqW9yt/B1tPFDiUBN0p8/GAiEAuMDf6R1YgSZ787vJNyS+mrw5mjEGYnnf0ZGQkxZxUFU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":12113,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjsqe/ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmr23g//b45GKzxu2ONJlqWv4mO1Ql+KWZjsnrhU5+VdHuQ8jGO1oAih\r\naoIZxfHQ+0x+1+oeO9HCm8MdCSqRaOTHJKIUuST6hKdrkQDiw87EG5Ot2bZj\r\nt6gWE9Rwfrj6Qhh51/+NgMRs6A+KNAP8kwd6TMKFJ9wFFRLi6rFobPIMs+Rv\r\nVkaaOTqxtrGHkLSpHCSCWNFSBSaqhUOTr5GEIlYVW7KQ0xTKvyy4v10JvOhl\r\n4nDgsuTcYaCTcuP+O2TbJi6NGjiK9vGVgbOuDzAmXogbqLJvkZaqtOmkYqqQ\r\nG7SQoNBi/SGqXGET8c9fK7ryHUz2NeZEoLYVWRYrNfU72ozPi5BLjydOvodd\r\nehVED9DI2MOlW8nIiQm9+sJzmY1XgkatyLHRB9IYMoA74G2NBipyTvNIATwS\r\nycLj9VCaTGZ19eDq0gPcgzjorBoZJi7xViUrLrEEw6lIpw2pf/kmhoOeLwLp\r\n+cWynKzmFCG3za0vHp8OunknCipqjuMvCIONzdZZTQpQ/cmVIc0vwtI7MpJR\r\nOjXRYijBHBN/+TXJix0vgpO3aarytAkvv6u5zxqz4SPQOl42f/iNYj3mpX+V\r\nhKDEV/Yb9UBlDuGdOZ7VtU+mliQl0dAKxu29INPwDVgG9C7Z/8qFvlpcqTbM\r\nxMM7+qguARGa6J79ypEXLvBKSEAcuPo2PfM=\r\n=YU2t\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"c4bb71d0db94f5c2b73dfd0eea6817ee76cc0014","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.0","@whatwg-node/server":"0.5.2"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.1.0_1672652735224_0.14228855730781342","host":"s3://npm-registry-packages"}},"0.1.1":{"name":"@whatwg-node/router","version":"0.1.1","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.1.1","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"bf8b90f93570a243195bff2e0a275b69821089bf","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.1.1.tgz","fileCount":6,"integrity":"sha512-eI814JjEU8h8U7MhkUII0goQsNIeJ4gId1GKPp9Q65mVlFzIn2G09MmL6/Ao/BmJz8dc7aAD9aN+onQ8Opfa1w==","signatures":[{"sig":"MEUCIA3GiPdTyrzMmW7xXEEQrjgFULOWxYP+zGmcQRcV2MA1AiEAlZAZeDyy6KPqTtytK4uSdGyv6PrLF/1eSTkdnVTigrk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":12113,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjsrBpACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpFNQ/9E9qeCSiLrpXFztH1YwR6iFQRmQorIJR0Gb0gByTA0aCryQ1l\r\nU2B1gLogF+X0bf56kI3ERy1w9Y25A+TuyLlIWyyGhrzgIQYCOEdTNxglTVD2\r\nSi9G1wR1JdCboqibXLew6FGe7HLGT7WuRuuKBQOwidID5hrMn5LjKeTinDnj\r\n0IksMWd+2A2tdt9DoUac6Du5e1XLwOslvsQqbwu+VOSNEn0r5L8m3euYPxwl\r\nw/ZiVLKoQlBObe2352Fsf9o6asd0pdajN8XS2p84ips+fbdrbLKswvS9VUjZ\r\nzbkMJ3BSHETZjce5pzKfYVnIXkiwXg1FIQgx8Ycq4+hVCyb8TlUj0r5+TYMi\r\nxAiFjBDIso7W2oMd/fk0JzTBAbLSNIaqK/KfbirwjUoob/qKdJ3vH6+bmGSA\r\nwAoDf4k/mQIieuSee9nh8lVqu3GKLR4djKMtjRNVf7r8l7JWER38NhwP6vSn\r\nvLLjSXfO2LF4jQVJ2lrG3onzShnLpAHbhVaT3hVKHd+d56zvxGubzPnL2ohM\r\njyZhKZKVtYCsTifdMsEEyRVQ2kQV2L7WWbIW7flGB4jJ1c4gU1Ushub4pEXF\r\nAqyE/L/K32GiaCCmp3R6QSChEPhs6lSS1geU3H3uh9b3C+FAfbyuyXOjYGZ3\r\nt0FSkK0BEsmuRiYGWP6I8xGenXwsFTmufFE=\r\n=L/gZ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"d3c03c04aeb5bfa39e042dd9758fdcf3f5dfa0b9","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.1","@whatwg-node/server":"0.5.3"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.1.1_1672654952905_0.7002070250458863","host":"s3://npm-registry-packages"}},"0.1.2-alpha-20230102102521-2e7c4e5":{"name":"@whatwg-node/router","version":"0.1.2-alpha-20230102102521-2e7c4e5","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.1.2-alpha-20230102102521-2e7c4e5","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"769d486a8adcc259983e3439de78d3906696199e","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.1.2-alpha-20230102102521-2e7c4e5.tgz","fileCount":6,"integrity":"sha512-jrcFchG+g5wnA2sf5LxGJusBvDay1bL2/3t1VlBB4R7KZOfG80OsBs15yvJlFgpHCVsbqryWd21lWLei+f3I6A==","signatures":[{"sig":"MEQCIHZKAuA4S02TavWMQisAAi3Kbmpp00N0CHG9eWpEYM2yAiBU3ch5VdlEEbHF/I51PxpW/9kILZ2yDiF9/eSEeGZBYg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":12200,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjsrEgACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqH8Q//WcOB7J7WMjnuDOIdYrvv5gdRgBQ0m03Kn4rOYJMwKDqivLUE\r\ngX1DO1TNDgDhxSRw5mJWcqHpSRZhbf6yKNwW2Yw44h7x7QEjkdXBy0hsVS8c\r\n68R930vLX4JCUi+ofnSavJEA3vGoyYl51qx9ZWsfE+1A2PTpbGoa9SfQ4vl1\r\nNUqAvnKxhYwgl7PjJ1keciUDb5zCiBl3XCV+9bgcBtwXT2l0NHB9OpA3ANpY\r\nnXikQhR7waJCRcfB3F7g4X7TG4pQJyQxJkWJ2SZMxvlCSaAzo7Xl6fiyjZRf\r\nPXm0RlzM8zSEQUTB6xcWNAdBDfK+rJ0Pzsx771KVqZqQ0clcgfTuWil2dnrp\r\n6gmoCzOYUxbtU2eRQsc7VOoyb2eeDlftZT4J3lvJBz75M6tUOtNYAdZWdgFC\r\nlQzTroPTMODP6OPmbhRUx8Lb6uXd78E3cQmZdsQ5M1xvLSjLmUD51/Q5VWPR\r\n64gR+j21sOp6eArIg2l0OntikWt+JHFONqJcCLYDSmpQRybd4A+hGBDlXg/b\r\n0YYBP8YeajXkmnY9CH2sjWLt4gbJ3tdLWzP3emt+j5mXI49s8pRZWLIRwvhR\r\n40jXKD9QcGK+kAjjV1bhKeqiUrfOS6OvmJZiJPrFvNbbadChNPAbkqleyZkN\r\nmS2FwuOIHR6JHTKQpCT3JYJKLqSGr0enmtY=\r\n=RHOz\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"2e7c4e53580f2fbdceb0b546e8b32e31931c364b","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.2-alpha-20230102102521-2e7c4e5","@whatwg-node/server":"0.5.4-alpha-20230102102521-2e7c4e5"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.1.2-alpha-20230102102521-2e7c4e5_1672655136614_0.33259155002049634","host":"s3://npm-registry-packages"}},"0.1.2-alpha-20230102112342-8d6524e":{"name":"@whatwg-node/router","version":"0.1.2-alpha-20230102112342-8d6524e","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.1.2-alpha-20230102112342-8d6524e","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"4523178fc2b482972c0315ac22a7691f6fa56965","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.1.2-alpha-20230102112342-8d6524e.tgz","fileCount":6,"integrity":"sha512-ugan5VQBoQ8wpJW0XdX5aM4wkATgsiti4zLzncWWi7Uj9WDMWzNqbDsNMia3eH4h7ksgQwvh85NgYsk8LfKNLA==","signatures":[{"sig":"MEUCIQDzHYnRyEHhvCl6rQipe3/xVdzmFupPTODqkAS+DsXqGQIgGG7Z9lWv85uCw1IZsatYx12w/BDRfN62lT7DG2DMCz0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":12171,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjsr7KACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrK2Q//UQdwAjU8MhNgVgrgF1FGYIGB8gKSc9Kh7J/eeFsSU1+nC59r\r\nDctLduAmUs+8ZNwGVnu0doUUmeNsUtfUbJ+DWA6JHgjDbG3Z9i6qnsbmVrt5\r\nQw0tXK9WnUVrml8u2mrVbfIR85CHvh1Lz/FlCZSVl7FeohhktKBdz3IUllxv\r\nXjTRxl+Tvz+xVOgvCtbVxjE5udfHJB0IVdbs4JCNBNGPX75f3KzIsyIH+W9X\r\nhG09IGLz21whpI599vlSAVJUuoPkIb8wrlxCdJL6DxFIhH5UACyQeI3SF3WX\r\nmJUG7nj7VLWUGTO79tXwOkEta+j7sNwPIX4X7ux5zeg/NFWh7IzRKI16L0Qu\r\nP+tbQ2DFzZgG6LVZtSnlAl38Mmmh5EumNPXVFP24PRobiNFt1u24wlC3BAB8\r\n2NsEa8KgVpDII3jGls2cw9etj5QpWTHaf0VAoiygl4UWhjwQIId3MS3ADEor\r\n/1fhdjAW5YObOhJLoI9Zek8klBKMAUPz2oi3pXxHgGZjpy1XnUxf31vtmz+6\r\n4vO6Y/OwjUwTHwplnuSbxjdePH7Q30cGsOuqUTs7AEoTNFZDFbcgXgKl/qlr\r\nE8TVgYsYgiB/7OCdjqsvSLpM+8GqlfooxvBcLsxmevbcaNm+9qwLVPtHFQv5\r\nDDcBKovKrHnM+cuwP8FozqfRFz5Bue6Alc4=\r\n=SmQt\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"8d6524e94b9d8e9780c548c1b450d9900533ebec","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.1","@whatwg-node/server":"0.5.4-alpha-20230102112342-8d6524e"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.1.2-alpha-20230102112342-8d6524e_1672658634779_0.8067235231948919","host":"s3://npm-registry-packages"}},"0.1.2-alpha-20230102114041-59cec65":{"name":"@whatwg-node/router","version":"0.1.2-alpha-20230102114041-59cec65","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.1.2-alpha-20230102114041-59cec65","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"f8e01ca9b0e136067b78911b9abf3a279fff6093","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.1.2-alpha-20230102114041-59cec65.tgz","fileCount":6,"integrity":"sha512-QYn8E7Xue+gFbEwWW3ioPmpVgQzJ07CWV84PJpStpnpbPQd/68p2pBhfUJ6tEeF2d5AXYl6Dof5yLE7q+UcOBQ==","signatures":[{"sig":"MEUCIEFQklta8ExkzA65oU2DrpiPQpvIiEQml2JO5+02YKnqAiEAs5qlHp7FPj2siV8T1pGAZXZkhH+h23j3NFlhMZPomXk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":12171,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjssLIACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqjFxAAgrk5xqZC7ecs73IpS/Ae+9vJ/R4Yc7bCCcpcg4EJpZNuGS+A\r\nDd4Drvw53SvT3EPuRcgvCWy1oYhA7wfqHBoTwbOgxqfP5nv9gVdz231h5/0V\r\naLbNI7s4P+5jLJ21JEz+8W5tAhaUhwaTNMn8eGQj6o2fHFPs/tvoVu+7J4ll\r\nbJCPQ8QsCtoBqiZhcV+vG9NmMRpxFzcTFY8wLeFA3aka7EbbuwN9DFo+1ldn\r\nNEXiaHxIdP9iuv1ZalC4C1H0Qm2rewPrFYQhzgvQJ1etXlhhJHcz9y1Ohrdh\r\nHb5ntMbrHHuRmNeyQiV7kEZl0y1duzv08eqMgL3q4bVnrs2D9XZmNEUDutR1\r\n048zVJegOxdxoJPN/Iw+hFFCM0zl7zB3JSMTqZxInqPOP++eobEzfr4DUh7j\r\neniPAUvOMOikdU1ptM8EWUSbzzjShlMhLXlHtR3I7f+nx0AJKc/vKbpuu+M1\r\n1DC/sYjjPT3Jzjk0M++kphXJlmJ/+Wn58kmVh9qQEujVplCKyzu6uhrgThZn\r\nhxgkVbvUfB1Dkd92EWf3q+3Ga+mbmL5sUYugydHwfKt9CH6en5oJAgwZB+sI\r\nnOlP+gRXCg5xtpuRkVy4MSusWfY13FewX7ktmBEE9OV0QQTpyRELlwmV9zRa\r\nVgCT9ASdbEGRjxdOn30IIr6ryuyMcdCRJ9E=\r\n=T++y\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"59cec656ec837181c8ab863be5f28a5bb478ee41","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.1","@whatwg-node/server":"0.5.4-alpha-20230102114041-59cec65"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.1.2-alpha-20230102114041-59cec65_1672659656042_0.4928493056893277","host":"s3://npm-registry-packages"}},"0.1.2-alpha-20230102114250-2497755":{"name":"@whatwg-node/router","version":"0.1.2-alpha-20230102114250-2497755","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.1.2-alpha-20230102114250-2497755","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"9f249240fbcbbde01141ce3d162357ad0bb838aa","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.1.2-alpha-20230102114250-2497755.tgz","fileCount":6,"integrity":"sha512-QpEgVo7tE0vhJGKgRJPQDF/N3zX5WmbWRr1k6VgkriaKJAeNmgeLFtgNrYIqr1cBBOwTmRp2B4QQdlH/gq09MA==","signatures":[{"sig":"MEUCIQD2JDv3ofDoJoyc+5jgnswjV0DUEC8kGP/P6jPc2wYgHwIgXCiWMEkqVa+Jrp8Lpo1vtpDQSdBkYX9ZkfqsrETJ8wM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":12171,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjssNJACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoU1RAAkV0RKb3TZ5SiVt5791zX18ZWD6cu2Uoy+uxKHZ/5Ji3u5kIw\r\n6LkV+XX5qsq4gOsD8ZceTEOom4DZ7jewWbb6dPYaCXVCFkBuP/k4BhsUMcCr\r\nt/X6zUUlAboFgAscByvC5oVAwNDc4NFWLHrr0Jq+h8V3dkjJYz/av4tFKMjN\r\n+MnoOraR8IBG8GjzDfURGIiN7hFCfK69uqEEAVy8Ikq0vp9aUG0yTkuNNVkE\r\nFnUhg7GxOsxIs9PQAh8/S6864Ut9hGEqmjpwxDvoh7Yyg5fZITdAb0gZ3Mzz\r\n0w4Q9CgVWB++Q4BY69ZVMlgtdL7rRQmGgxG2fY29IfCherw8dsP2GBs2GxYv\r\n2pfOo0UMdEeaC90opSCJkThLqxpBDnn4rBcehyN5KlWSJMnmFxfzM0rak561\r\nNGdat/Tr9rP3ngFeRCNAPAvO7/n/UffWSQuLFwKnCR37Z58/Fjcn8a2fq2Sa\r\n0g99+eh3UON1J/lm0oeSE6dM5m0RYdxdSXCT5TRvQDg5TdUut5m5Ut2PgZIR\r\ndLcFKIOc1eTqwjnLK45pJS6njIVv2XH6YX2rPhlxLbltsNBy6jvWl/W5VZUk\r\nc7E1tLLu6DLn57knoCJMT09Ut/oUodi+2a8ZjOSbp759Vfz5U8qEwh4oE83/\r\ndVnqhnEGmxijei7a6m10097kBkIxbW/e7Jw=\r\n=bqib\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"2497755b4fa8f1da4f70c7ba096053b04b39fac4","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.1","@whatwg-node/server":"0.5.4-alpha-20230102114250-2497755"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.1.2-alpha-20230102114250-2497755_1672659785782_0.9707102860452355","host":"s3://npm-registry-packages"}},"0.1.2-alpha-20230102191116-e4ff740":{"name":"@whatwg-node/router","version":"0.1.2-alpha-20230102191116-e4ff740","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.1.2-alpha-20230102191116-e4ff740","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"00e72d5212b0ceefdb94c57fd7ad868a8bb9a821","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.1.2-alpha-20230102191116-e4ff740.tgz","fileCount":6,"integrity":"sha512-vBUMkqwniEVvqIRJg2fmwOBRd1Bic2Zaod+F8aZzP0dCrVMB2fdIi9blEFwWKuzAlAOTvfKioRy7vttPt/oupA==","signatures":[{"sig":"MEUCIEA2Gek3T1g2/L0Td5Rzj8ga7l+NAqbgfykSonks4CeMAiEA3mIXdqWs5upPAYYFJXfx5WrfZkWVgnTphc+Oxg2Gv7s=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":12171,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjsyxiACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmp9MQ/+PYlxLlVHjvejMGTLtbK2m6y0kizTb9dtRfy3sGt4FJEjvs7t\r\nSBreoBcl+8IY+8rDdC9wjsn2R7VxfrOucjryE9bAoFt52b2gUqpcLLncDXXN\r\n6pZ/asgNi3aHsluqDMQEVGC76Ke1nEzZUcFiIOImv8G2OcZxQ6GHNBtrDx9I\r\n9RWOwKwtb99S2K5OqvGbcWzSFKxbt60/Ds0c3ldN0QNntTAJeeo+/tvW7VoI\r\na329Z2UYMiKKwWWxtf/oci2/idbytOh7jAgQcdDeQytqTKgC5WR7W+keeR8j\r\nC7tKg15c/fa6COjN9qaOqyJhliDva5teVx/mcsLl2iLBmhGD+oj+dtVIyLSU\r\n9rGkjcAY1/FZdV5NcpUYVXsv0vFimaKUB4mCGbiqRNA0FIEoGme24Dr0ONuD\r\nhS7DBJMWkxALWX1/4Y4AWTkJddyWo7tTnPGMl4qS7Yq6yFNDMRy7iW/pkCOy\r\n7Yv4uPz/oUWwTvm0SEKTaPFA7joOc7AlUAaHA8/FhKZAT/9fA2jtIRSLrSe7\r\nTkszD0KZCUv2ZbBsINl2bg1Ru7W6l0BvTfSEx1rALqmqfh2XJhs1Qxrrjzan\r\n+WHmSFsDdygMyAGXl9rQNpOpor77tLSBqwVHl4Fjz9SWFiOpPKHLxjWSbzny\r\nwnZO5ojpguG40ds2rBixYjCNNz/jd72Yfus=\r\n=Xxvn\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"e4ff74016046d03b2bd090de5656939debf98c91","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.1","@whatwg-node/server":"0.5.4-alpha-20230102191116-e4ff740"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.1.2-alpha-20230102191116-e4ff740_1672686690121_0.17599126308399238","host":"s3://npm-registry-packages"}},"0.1.2-alpha-20230102191119-d592bf7":{"name":"@whatwg-node/router","version":"0.1.2-alpha-20230102191119-d592bf7","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.1.2-alpha-20230102191119-d592bf7","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"35408638a87a4263116a703cf9e8b063dfa410ad","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.1.2-alpha-20230102191119-d592bf7.tgz","fileCount":6,"integrity":"sha512-YLHhKBoa8JjdEIy2r32PZJTIxhUVx6NOg+9LpnV+oJCrcugwIe6KZHHkFGBeNx51WCaF7y1M5ykm6IpyNLQMiw==","signatures":[{"sig":"MEYCIQDX86d50JWRSMJTavaRJXnPZoNaRemA27AkB6R5yVjcmQIhAO3+uYmz+j3tUVBoMQEsh1oT/q8CsOf92IZJHBwkNKcU","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":12171,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjsyxkACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoLzw//SGIgN90mfZKLVprLzUNQDKfUBJ00b8ErQo+06Bg2dabNFdOx\r\nJLa2sWpDnBb+juJj7syi6LLCLtJdqa/IjZzP9hTBr/yV7v0B5nKk4iOjUhAg\r\no6rubwoxiEy4kABHJx1e1chPNmzqZh1RofefiSwxpwqj+8qANsjWaw53u2DK\r\n6ZqOI5LSiSpykq7Ju9AQ9LLJ9QXwCu3vtF6NLo0Je4IPxHWcLgyQDeU5ZE2X\r\nneJBcUHBQxxydEaxsAMJI4DpyYC981Yqj60hp05JbT7Hc9qGrt6QjPtF3g3X\r\nWsAUIc4L91okgXRvFx9pmhypvLFMxTFIZcpxr8QMiM0v4/f8a9V/q3IXE10+\r\n1zX0whUnQcSLeRkxJgpK6FZ4FwcQZNY2eZtsEaYAN28sS7F5d6qsEWCiIf48\r\nlYSRu6nzAg43nabno6sbAon2bYoc/uSyCWaoXGzTLW0jUW7X+/Ish5+ozDwD\r\nfgeo5E4QqIf/lQaiAJGV3hjVzt/GqWuML1GB+Uies4Q9Pgg/uf1nr/oaBpDY\r\n7JGeueYNdN2xOs4BsZ1rGUYKj8yb0yG/s9XShJvqmtWrbdiMUJn4AM56A3dK\r\n0DeGmIwKUhp0Zm9qGNssE01EKEXtkxPlAPammeFgewC0z+Dh6AOB4UTfXaxJ\r\nvV8fgzpg4bSAfFoeZOYIoYQKX3PZr8II6D8=\r\n=Q4DL\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"d592bf7e4367db2d82ee1475c9a9409c4e899d07","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.1","@whatwg-node/server":"0.5.4-alpha-20230102191119-d592bf7"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.1.2-alpha-20230102191119-d592bf7_1672686692219_0.3548106441139167","host":"s3://npm-registry-packages"}},"0.1.2":{"name":"@whatwg-node/router","version":"0.1.2","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.1.2","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"a020193364fd005fcbbda02cc9231d0e8ea0e4e7","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.1.2.tgz","fileCount":6,"integrity":"sha512-ysg/2BvjdAPcpIsLxqltd57bCVVxx0PHzdabJyNWxl0LkVV+EgSim6i2TSLKOMlNRJjACGCkNXzw1bS+Fla+5g==","signatures":[{"sig":"MEUCIGhCUmE7jkDfLTGwPVLgz5zfvEM+CPLkeT+UvR+w5uCeAiEA5cyiT64qPEMk6WrCpwrDLuEWXXmjBpP/MlPJnYwduTA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":12113,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjsy3/ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrPaQ//RIRZGFDyJvyDqN65B6OU7t71lS5mITj8mXY71T2XF7GoJ1Ob\r\nK8DSbAm5RGxSBbQp19+hxl4uSDonaqvT8nMv/VmPhDUjyfscgNwMsxpe7b0d\r\nPW+rBKj3zwrWeBd+EXdvsRQmHnM1bUC1EhB5cdWUIaX33Fs2AenfRRSycVM4\r\nK7TI8R3UHveuKaSXSpE1tkj2i/ZDnfLNoxhjNSbIZU4Fmc8A9AoH/1H6yD5h\r\nNyLY6Vd1M++ndnqzlE/7JvhkoBVb7cieytfKTnaG09yicKtl5mB7UmvMmnEX\r\nWEKdeFdT+OuKxyfdDD9uHqyvc5cvwkEle8mt0lhS9YeIqgx4y4Gz9jpkuB2x\r\nH9QjqKv4ZpOdirMoQzWZMYRZ0q1uvcuU425Vzdtdxhv8jpuTYykZC+OnyDKL\r\nFifDVSeRZhUrW6qeRDsaZPW/tpRltvG1vSh6oiPEBpalP0j+B1zPRN4J25Lu\r\ngIRJgbYIzUZ9uyOazutzIuYxwTbUQ/IrrpcCC9CzuMQhNkaQ7W2ghy7VRbC/\r\not+BJesq6L2zpMkF5z2BJT5ZvEmfTUiZ/vPoMCEbQIPA193Ua4k469nRm66U\r\nWviXgmjRxrQ8lNgOWoOz46qQeIPDPmTBnvIHxKRFOa32RQICwnkzkNdINldj\r\nw1HAcDkxIBZnNXpf8h4+xHgNtSFiCSYOHwk=\r\n=1DYr\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"f95606adc9671ef6f5f1d3a1777e6a9a91a0cfea","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.1","@whatwg-node/server":"0.5.4"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.1.2_1672687103520_0.8944083158445326","host":"s3://npm-registry-packages"}},"0.1.3":{"name":"@whatwg-node/router","version":"0.1.3","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.1.3","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"1c84f327d70c8b4a7af90bce03e5528fa2dc4d16","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.1.3.tgz","fileCount":6,"integrity":"sha512-0b7eybVzQqYrON0zQMB/dowbAfCbNG2N0D633NecBZ02kmP3P+q/IZ26icKwTJf0AMe4sNJTYIE1ZxG9ALyZ9A==","signatures":[{"sig":"MEQCIDIqFKnV+SqZ9nza8qHJlm0wAUXqiJBOmqZBiu8HaOIBAiAAly8Bgtpu+aG/zJ1elatFrt2eesUFxHs1ahw1RXZW2A==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":12113,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjtAxXACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmosJw//cKbov7Bj+ZJ0lY+Nq4fTnc/RnAJ7iCal1edzPkdZRsvc2JCM\r\ni5VABukOAue4Wh6Z5DJmbdWpyOR1YaYBb8gud3weX4FuwzqTLW9JBwo7AXfk\r\nuuiDVwFMlyfoTxROXTwgKb4pQnSyXpu5V4Twn9ZJeThqzRXLT0JVP7RoVQrP\r\n0YUa3ynwuUGBtffuXFGqVGHGhpYW3op8++u7swF6XZCnwxQc2OA0q975UAj4\r\nFI5EmQmlfAtw6IdWk2jWrdCzwRcWkc3EFy65vJad2YW2rt7EbcX7FlrZynDh\r\nd27UM8MOtx/3hdwE2T9krPbxLP7Xp5zMQiAjFmTds+0YupBwtwvAOsjEeXOI\r\nVrVWj3Np3Z4l3A2CUIayrvTv7vqjzNxYWYO2LV7DZgNUsjHQX9ZvNJEBDlUV\r\naeCLK5IbzEDhtAR55PfWrf/n8sQm/+co+fFNjswh+O87OXNI8Kzqjeh5VCfx\r\n1Q8d5fiCMRwx5tRr2Z3j5OgVvT9CaNjScBp/Hxy9utVyPJx8DLrVv/bWU+hd\r\noQCQXYKao2fY9DtkMBxUuq/xGl38bpqHzPFT/J5dbk0lnq5VcSQq5ygcAfvz\r\n7xW5h66pgoUZr2HYdGLujwLZzrUhd1JPjWE2jFBFOt4MkjbuI8qC1Nznmx35\r\ndrcwumbH9/SOKB9gTlW57VXXU/OiRDmTznk=\r\n=Scup\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"2a8992cc6f1d352ea0cdb4b019fa67a70e5f0f4b","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.1","@whatwg-node/server":"0.5.5"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.1.3_1672744023549_0.16806752675867442","host":"s3://npm-registry-packages"}},"0.1.4-alpha-20230109165738-8edf269":{"name":"@whatwg-node/router","version":"0.1.4-alpha-20230109165738-8edf269","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.1.4-alpha-20230109165738-8edf269","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"6d852a2178b41078d7ca98d67b5e0f4ba196660a","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.1.4-alpha-20230109165738-8edf269.tgz","fileCount":6,"integrity":"sha512-hfnUjieljsFjQv9JQGwWe+M+jUxDb5RcPTMD4n9GGumnebaYTprojsbAbteE8II0cAVMrC6xRUSta49Ak02C0A==","signatures":[{"sig":"MEUCIQCI3DVlbDF13FFOcTRrdHPk+wHD82WpNSeUKuNwveGW5AIgewHjbuKsVKMwNJIoHYqyJJYUU2MWEjv28C97Cr9LVFU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":12200,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjvEeVACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmo6axAAhZNMoGKubwjs5BdbMAJrHi4YRDi8pSRH04PAEJlLh378cNJ6\r\nvGjaJoeaqNsdJwLGqnoNfSu1w9RwhC/GLE5gCvfNeJiLqzPlrCAVEaD3YQ5k\r\n9n8sHpu1AbcdKdfVZVsa8uNl5e3IE1KyT3h/lrzJ0VII0Kp3EnJCLhjHD341\r\nfYhAw9CLbRpu+4Hh7JE6Wl3tRhtd6l+wH/ZpZukouzhiXJyH0/JSsqJFYUWL\r\nJ1Wut++0YsMNaHfyaXjLIasveOusuctyFDHLBKslxd2UxqIb9frGUrxTp8y9\r\nJ3jf90HqbQhAJ+Yp4ODJEqgVkz0HtV7Jsj4hYWBt8qwT40l7ZzHmvxPeVoZt\r\n3sbA9wOh+ylqQSxuknPeb7tp2x2ylKWEHTWtTOSJRMZQ8+/7p1Oz4YIfJt3X\r\niqyRzvhXDVKEDCVWlS6+73s2TbFczl7pR+DL1jIjcWXBz4JowfjcHkQSfcv+\r\nnGMApbOlrcDt6N2SCaiwfU5yY3YoNtQds+m4BygxcleNnhvB+EesOrmjnlA5\r\nieMYTUxaXKNJzKot0EMPQwLvDosX34Eaha5Md8wpxIoKwn/ZQygw/Uy5UEt0\r\nTc3sYS8YVUj+LE3ZLPtdEAipUeyyGxKB8aNflIsW4HL7Eqga93tx9FvVi9sl\r\nQGjMdmQZGqKiG9SMzmD+67q28+mG2SUFabw=\r\n=14rG\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"8edf2699e7beaf09428fd4b925c72f323bf049c7","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.2-alpha-20230109165738-8edf269","@whatwg-node/server":"0.5.6-alpha-20230109165738-8edf269"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.1.4-alpha-20230109165738-8edf269_1673283477279_0.33182813536497147","host":"s3://npm-registry-packages"}},"0.1.4-alpha-20230111213850-946da63":{"name":"@whatwg-node/router","version":"0.1.4-alpha-20230111213850-946da63","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.1.4-alpha-20230111213850-946da63","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"acb42754f91f4fb76cd1bda58450061d0ec8f9a2","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.1.4-alpha-20230111213850-946da63.tgz","fileCount":6,"integrity":"sha512-H7TMdolrQxCTR3D9ODEo6hxtXqeGgakoMJvdLE+gdToBYAtPLUgU16z3dwMuLbY+yr6AHnesQaBgnAkS4jXDdA==","signatures":[{"sig":"MEUCIQDvdrCqf0kKCAPWXYQCFroJwcs2SFR1fxvPTLLEUIQJWAIgWq9XK5F5aui7xZ3lD12IiM6pRMTwx1OzV4hs5J1w/uU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":12200,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjvyx4ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoGrw//Zn5Qsxe4fm+v1TWJOvH797qwzfd1VTHJO9MULfVTvDJHglAw\r\newzC/7oNhdw7MILLBYq852JPvr1lIxpEw6UjwpiY0HPsr//Gq4oiKQa2jqJ0\r\nT0C7dmzQ9NCO4ybUSGse0d54CyMASfhc6vA9WUjdV+To8EItTfYOWTjnKQ5q\r\nJg4Zkc2ppUfkYlI6F7H/xryEvHp/58B2OXd9FSSJOK//K5iaZDpdSQRWCBdx\r\nG5h55uhLa7fn+DGKnBjJWXmH/EC+SDY2p5q65VHvdxvg2aD2yUtCSFDbyHYr\r\nT0K2YFOaia2K/La72HxvYhDhoSJq1OYwZENxVM/rbzXYdotIMkdiFH8N5usL\r\nXnL/0uiesYv5NAqoSyvVrZxkFRrQIXiORw/caM9ioP7sJOB949EANMAOhReY\r\n8ZZxq/K0jYhXapLQ7ugqg1PZPgYvA3a2LGj3L0DLMpoDcznOmteaJvt7apIG\r\nr0n54LIl990Q6/OK1Ti1TspazsjU2GdZSisaC14e2uowIlrLy9OwtZ3NJ1k4\r\nfvhP7/+pb//GCB+G8qBdoNZ7vfP1CEaRwFQwuCK0a0qnvetkzbfEGfsyd8Vl\r\nn7w5842hVbMVdt+PwYLFz0i06H/9JmPmqsAxQmmhwygomo7a4Hry7QVVGW68\r\n0mtz3RySuzdGvUVVg2aVs9bxu8Zn2rv8TQg=\r\n=waBN\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"946da63c0ddbbb3478b2bb76f042a4dde7cabb22","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.2-alpha-20230111213850-946da63","@whatwg-node/server":"0.5.6-alpha-20230111213850-946da63"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.1.4-alpha-20230111213850-946da63_1673473144003_0.18068508403674222","host":"s3://npm-registry-packages"}},"0.1.4-alpha-20230111220448-f74dc45":{"name":"@whatwg-node/router","version":"0.1.4-alpha-20230111220448-f74dc45","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.1.4-alpha-20230111220448-f74dc45","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"122f6b4edf650abc66237f0bbb90bdbd9cd66b0f","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.1.4-alpha-20230111220448-f74dc45.tgz","fileCount":6,"integrity":"sha512-GmuhIoLKg+vr2EthOhN/ErFARBhSFhFJvWsEFpK+VP7RwENpS9pbKg2Ww+ztdOnRJfh8JeVZLMCVxb1BT42AXg==","signatures":[{"sig":"MEUCIFi8OL26JwKr5MIxb5DiLTI3uflihz5uF04ZUFuIsbgBAiEAxOoSKkyG5ffWytN0cjH9/wQ5o93kgDo7fwq2k5qwbOg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":12200,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjvzKQACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqJTxAAjmp/Z9AVgbiwABzNv8rObilEFufKq9zeNZs6mAjpPU+BMKDf\r\nLfnoXStmMmEHLfCEBkNTyxjKWjzni8X7AFK4JnRXjRbyYe+Ew3UTd2nisq07\r\nEFOleh5AsRf5WSAuk8bKib9H5jFvJNuJ5KguipDX11k8+bJcl6tLw77zGNHj\r\nuU7jrlW5cphcK0s90vUpjRI/yexU2WUL0Tky7kBSAQnVoNM75s01NxNyL5rP\r\n3nWttqv0RR9rdb4w2IhR9lB4OSw79YEdnauWBZjJMZJnPnddsHalDPUs/hQx\r\nQldV3125IAwjg7DaunNrjjghMH61fwMtd8OzCvFt4B+A1XnrrjKxQ1gJ/m6u\r\nL/HOCYAV/bnrRrzqhbOuH+JDRccF9VLQGh0foT0AG2lFXiIZWvqAUxld14wB\r\n7m3NUsKun6Jvh1U81biikPcHRJ0KDajIpw8Ag1azF3MXQ4HtG68FyUuYMJJV\r\n3V0PP3jR0L2xaKy13A+EQf06M6pbH8hoEz4M/6qroR42aP8h2L8ayYzAHBzW\r\nWTwQRLkZtVzfbxcJc+kiljVKD3VuzwyNoCeeB6b/Z0XTHqZq3i+j97/K2tOm\r\ncN9ugCDDjedOBP5XN5DKE8YKIkyKbAasaHHC8ww9/xKguLEYcKUP0EjQ9sQo\r\nbfyVEEyLjImQH0GLA7tbJrXRPmuQzPEn5Vc=\r\n=hOzR\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"f74dc4548f9b13308599932031184b1a7b19a4de","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.2-alpha-20230111220448-f74dc45","@whatwg-node/server":"0.5.6-alpha-20230111220448-f74dc45"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.1.4-alpha-20230111220448-f74dc45_1673474704591_0.19868504148781985","host":"s3://npm-registry-packages"}},"0.1.4":{"name":"@whatwg-node/router","version":"0.1.4","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.1.4","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"bf31ec43173da4cc6d5dc292b6f9313152264a55","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.1.4.tgz","fileCount":6,"integrity":"sha512-4mDwkyhId5Gg7+iKiJkcFV+o6xrqwx8WIc1YGpP0aPi9Fa8dBtxuISk2i1ExEKyQilgqTYwnWUumG5Ego8eQ7w==","signatures":[{"sig":"MEUCIDCnik6SroBNMt8kXW2DjNmdGepaLFuvrfYPDl/1MQIjAiEA8GBhvrf46NaO1IpjluUHrpLxWoaOVMncSaT7VFpqB5A=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":12113,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjv0jUACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmq1rA//cqnU3W66cweYLn2mGrbQxGcJ7dIPCAdOekMWbIjpTRiYRkPb\r\nqiKuhlNtyHmriCzB9gGnsxX972zJ9L9RE1kejV8ppZNCydaJqcu9UrOvOFRJ\r\nbGt99C5kBjyZtXVvELHwXe5vH62uLPYYtov51h6hltQzCLDeFFDX8hVpthKV\r\nSVmfhhETy0qU7ZT1/gX45WIoENf3p8aoqs80xl4bsTaQYw7u9wRbULhQLIEe\r\nVxVKAu3qjjwUhOE2tthpTjfKiOeQMpT2Jau3J7+heCdkqacO8rgwIQy8MRIa\r\nHB13OYLhBbPiK7XMrQU6gsVIkMN94LaurOvLLsA1hAr75A1ReljDj/Q65OpI\r\nYGUonK3ixTq8vqt63BGU7viVNd3v9M8Tc3IgOy7Nb3wVSWLqPlU+5XS5xUjW\r\nJjUK4W/Lq4ihEkjZBss2u7aCeshrdb+dHCnI9wdSwlkow4A1fV3uN5NFCaIJ\r\nFvDvoVMFcztI8GBSSFbumcSi4qITC9Duw3+OkvUkzGwMda8YUY5l9ENwvbmR\r\nnD+9YuQaJZY53CrIQxDku2+1sLuJ7WACl0EDAW46qS+35oJJhYZwRLi1YeqI\r\n8gIMIoN+TUeSPysMpGNBckpvcCpxoCGPMnrwxccMO1/xoPXSIYjHnOb78E69\r\nmi3rz8ayxUvbnwPKtFbhHn7zeEikQwAYC/0=\r\n=UTq3\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"bfb40202b31b585ac780712c9538f3c19f3836e3","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.2","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.12.1","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.2","@whatwg-node/server":"0.5.6"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.1.4_1673480404553_0.06816154876885583","host":"s3://npm-registry-packages"}},"0.1.5-alpha-20230117081522-969e299":{"name":"@whatwg-node/router","version":"0.1.5-alpha-20230117081522-969e299","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.1.5-alpha-20230117081522-969e299","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"fb617121961f4595b8f80b976944b45df676867c","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.1.5-alpha-20230117081522-969e299.tgz","fileCount":6,"integrity":"sha512-ZX5EaTtPQF07pMQ3n17hiDkHShSvAa9Z5Yo9uOLUm9vTigv3fAjBaD1mfkQfyYh2jQ8/wMUz/jv8xoyXupg42A==","signatures":[{"sig":"MEUCIQCkliz0E5VEtpNPV4FofTcFNtbDntImM8rAHE94U9qacwIgOJ11pItfyNr9pEgo4TxcqC5PFHNjxFWz6ay5NYCaJeU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":12200,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjxlkoACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoAnA//YDBvdOqj8XvUVN8Zb89ftMsiZliShbzpU6c7mq41wYS8ywsM\r\ngjUWBBpdknLOnTONBpEp5IHsxjDtUiWlbI+YmmSMTZqnMAmeRsNL5HVWsH/V\r\n992PkYi9R74LMQ1LvZCAcddbu++a5VhDx/QfRR3PA6r/L8IGBScE7fWqLSKJ\r\nxbYVgL+6bP414rNPCuJN7q7G+M8ciG1z6vHexue598nzmgdXrKHjnuYwhBoK\r\nw/0UmD6ii/kPW1Tq6giECIobXVZ/p8rFV6u/yprrWDwADq8T1C99Dc1FfY8U\r\n0nuUCRpRhQj8YZ0exWdKSd3zR24CfGM9IGU1NFYkBc5ACv+9uJer8eMQkHQc\r\nIeHUtl4lDY8w4Y35S5BWbtumYmAVTXJxH3Dgu+MV0z/hX8HIUG8/aBMYHd0Z\r\nHfilucu4QllZ29TEiI5drxKs2yEJ1x2dJVbH/0qkTQ3AyckGLEH/2p47+qL3\r\nYlOt4SaghO/5UDoBqm+Gwu5d2CHcB9DLs73lVjq40HCrGwHSwEt6VWS+wqdy\r\nFi7YmkUGvdkFC836c5UoBsiJi+xdYo/cLuabD0q0BG/pbjAJnfJc+ETFoYZj\r\nONHrQAdF36Ehz018UQLcbVHmPW6AU5+Usgv/q4n0ft2IXjSPbhOKcjE1mHpX\r\nXQqP8pD5HVs7VJKdE4PqhV0liL9ebyKnqeE=\r\n=fo3Z\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"969e2994da6a4dd89c8a32e3333a5c9cde4df491","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.3","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.13.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.3-alpha-20230117081522-969e299","@whatwg-node/server":"0.5.7-alpha-20230117081522-969e299"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.1.5-alpha-20230117081522-969e299_1673943336448_0.6500970195570748","host":"s3://npm-registry-packages"}},"0.1.5-alpha-20230117084928-a052439":{"name":"@whatwg-node/router","version":"0.1.5-alpha-20230117084928-a052439","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.1.5-alpha-20230117084928-a052439","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"8e451b7ccf8f0d92d1bc9945b47da754d1ab983b","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.1.5-alpha-20230117084928-a052439.tgz","fileCount":6,"integrity":"sha512-ZxnOAmEc5DtU7I9O2P6B8G3Uu17WuyNaHxg8F6vfPoqGEUoZJYp/5Z70JB9uEzintoA/nVsVKixxEXXd+1286g==","signatures":[{"sig":"MEQCIBRKgPp4HnF0PwwheKlQPqizPE3P3UTb1/mLsZSoWblvAiBMjOJLLzVe9DfqyWx683BA5ymfXOXPegByksxYAVVu9A==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":12200,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjxmEmACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoI8hAAljKNa0CdOit9H27J9sJHY7wjkTq6V0+h/3q1hzXuBs+bSZJ3\r\nAyc5H+uXZVNyNy7b0H+LwL4s9O6Bw48Qx+/0dukADGieS51cWp8VaA+rSrC1\r\n4jb8FnZ3OOLbx+F2qJ7G4ahqxLyIBWPDogQrnlHeK5cMwFepTv+PUfoDb5YY\r\n09EBFp+EB3fLvDmtCZS25+8jRDBt6gRLQfOwNpGx/sM6WWFbP9QFZqeccyCh\r\nfXnaIy/dGa3Cf7Od5hHkt02NJf5wuw6vQbN2xHRnb846BUWkBOaAw3kHrZ81\r\nLJ710iCY0l/QbuH6tWgE8YUMEZYCAowrDPUAWLkwHDqdOCD4EA83+tmG9kGf\r\nbnRIdSNwKOPENyAl7r8WDkkOjSwm+E4ibK2xymEkelLcOT6+G3QHMtbQYkkI\r\n6F5O5+1Iu/X6w0qHjmWGECe0Gt28sb3ahl23KS7C4FIRhXBdUOmM3IsVL/by\r\nrxw5s7lEaExv9Bvj9tPkR8H7YqAiyuqliYaply74W0xIanrlpyYfd0jUz+QL\r\nIpocJhKkUCJvYrItxTn+KtXgXaXZDK7zQSnG6DEzV+8eSb8rIg53CrFrO6p8\r\nLMkoAtCs0GGiOmBNz+raEsQsHlLmgchCaOrOvBesheg0Gxck92SMseX5FYqp\r\nhKOHDlFi2v2dQFizOp8bEGOZOTGMFng0xAQ=\r\n=wH/p\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"a052439ebc2c6eea95684060444f0c140cd0161b","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.3","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.13.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.3-alpha-20230117084928-a052439","@whatwg-node/server":"0.5.7-alpha-20230117084928-a052439"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.1.5-alpha-20230117084928-a052439_1673945381920_0.4749004352091435","host":"s3://npm-registry-packages"}},"0.1.5-alpha-20230117095738-14df726":{"name":"@whatwg-node/router","version":"0.1.5-alpha-20230117095738-14df726","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.1.5-alpha-20230117095738-14df726","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"d30cb8328ad37e06085b6d85ab12aaf55e1bd7db","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.1.5-alpha-20230117095738-14df726.tgz","fileCount":6,"integrity":"sha512-/2xzZa4CrAdb+2ONILJoaUi54FDhM+NgQruWbX6h8DP58xmTyrrgZTpcVTMMm7lGPkbUbulffdIo0qucEucszQ==","signatures":[{"sig":"MEYCIQDdLWJruse37enm6xqplcu4wzQXvP/kGxZnPYM3KpLHpgIhAOFuOTMpAd0kvtMNgLAI5rb5Cn3Z4XG3o1+seAqtejij","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":12200,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjxnEfACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoAZhAAm/SrFm6uOhxhCwyfnG7ojGdyGRLGTB+vPr5/I1mQh7kUaQVM\r\nk2Qt27444qtLDQrCJrQMdfjhoSxt5ea3zAq0DG5s6qtifv4bObpLpEH5horG\r\nMIRD2S14zi2RNu8NT17irGqHeWShLILuGAPNk/c2NwSBXgym/E4EhD5fA6SK\r\nVJfHqI25Mcs8vIEd4YinFkFFYrpn5lo/QnHToTY8On8n0pHaUqO+9gnd4r2A\r\nE/0hwAy58hXuikv5tCD25Cx3hevOtZyEXqP21E00+gScTasvuZ7zBfFdnbqY\r\ndtIQx3zJefbwsOn8d0z1O6NwCbA5h+8bp0SUsHW2Y3vi7MSIhrMD49SA3i25\r\nO9eSnX7w3+Y7++O6/NEfGpU62qI7b/BQGeqCMpKn1MOyNA8sD3Vka0rwmPVc\r\nHVFW98tpbzv38CM2LBsek1bIPO48T/rPso8fjX0wFNHSMz66ez+l6fUtOFvG\r\nOVTwidEiRSIoewDoO9sJHyRs9XuFIRNRRRowiIKFd6U1trOV52+s9ToM3j9y\r\nNjdsIvciiTsUtqXVWwildE0fsXYD9E659yzl9GhXmo6/0Ch5FLoh6jyxUXpG\r\nSHxD2DFpeoN+0hfgEWqnBqUC7NP+QiPI7ePmIl6fWyvO/DrPjB3NI6dx8x9r\r\nHFvRYlOdwAOcWKngvdFSlO5Q0H6evQSCWyE=\r\n=zJ+Q\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"14df726a9aba9c724aca7f9e5054bd956d142fea","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.3","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.13.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.3-alpha-20230117095738-14df726","@whatwg-node/server":"0.5.7-alpha-20230117095738-14df726"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.1.5-alpha-20230117095738-14df726_1673949471714_0.7809095287651127","host":"s3://npm-registry-packages"}},"0.1.5-alpha-20230117102027-734f015":{"name":"@whatwg-node/router","version":"0.1.5-alpha-20230117102027-734f015","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.1.5-alpha-20230117102027-734f015","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"39ed5f2abd5541fa0dbcc0ea66c0e5d1eb988c18","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.1.5-alpha-20230117102027-734f015.tgz","fileCount":6,"integrity":"sha512-X74Jugcji/FeoAZ9bCVRquO+A1mYj0LOL/InxWBxgf0NgUqcu1xHYVNebZWR0rUFNQDsUnFtA2qTcbJHnilTlw==","signatures":[{"sig":"MEUCIQCpIet4o1GICSg0Upq9L9vUrETnSPUZS30A4o3iqnDM0gIgC8m/zpGM771Jzpcj1hhqmr+wCvvY5a0ZNXx/2idthxo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":12200,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjxnZ+ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrC2A//YlmVi0ky5ZTKTvGvsYtJoBdTHltzvC/ha6+z/I2SMDUgKqNe\r\nQgN97vTlTtLY56Qah2sAjw0ZFw34o4HiKZi6p3CSybRBZn5eqyFKXq8HojtE\r\nVc0Szjc6dnkSYlOvaRs569Tdw26GDmrjEajA9Db4/sG0L7dEksSW3xnuUGIo\r\n+nlvUdgt/gYW1SswkFLHk6qK+L3Ru/XU6KzgERvi7Oo6KKwAHOdzJyimTDJt\r\npTjKgLYYCAY63t7pYRjAILZtGvzohH2E7EHqo8/0lOMKCw6isk+dMZa4d4fC\r\ndctlXL9vi0zlFHiaVL4gcfHpTqRt2D/YQrOnwNxXiuRETGpenB//rEJt7oNg\r\noe9IHZ80EKtT4FyYoBCBglZ+W1s4v7X6uMJ0ljGfUCB8+PyJlAN8n+q0Xjkr\r\nIFPj16ZzwodVEqGzjaoYZ+f1uvGjl07o6kXbR49zweCg/EqgiCQ8mT+43wve\r\n4cxi5FfJWzr/+uVs1RwvXOjh3x33JTRmjv4k0cUWIoC8lN/DtMhOAUAACUHY\r\nUu5xFFlXzyrBNqXlB6s7bULa2t0HU6/oHEbVc1stQD3g1/DvTzaie/6dWS1N\r\nb/cRTSJBO1K9sU6Z1bk34lAI0NYndFe9Vm/SJgf87SVo90lzCnh55bsY9oQ9\r\nqFagIqjHj1tEgounEGiafgoHL3UH3xe5Gts=\r\n=3M5c\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"734f015a8ee800de64093b406a226f67afd3488d","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.3","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.13.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.3-alpha-20230117102027-734f015","@whatwg-node/server":"0.5.7-alpha-20230117102027-734f015"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.1.5-alpha-20230117102027-734f015_1673950846237_0.5434746474814043","host":"s3://npm-registry-packages"}},"0.1.5-alpha-20230117102108-86636f9":{"name":"@whatwg-node/router","version":"0.1.5-alpha-20230117102108-86636f9","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.1.5-alpha-20230117102108-86636f9","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"512c793eda825b968129dfefcdec66847636ac0b","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.1.5-alpha-20230117102108-86636f9.tgz","fileCount":6,"integrity":"sha512-2tPw4O6DOtPKkTLDKDwQWKqWj/Qjhn0wpOCH5PMdX1cvqSfSopFIu35QyRELJhWFoJnMKt5iqIfyVNf9P9CgIQ==","signatures":[{"sig":"MEQCIFTGs2DW1YRBIE1EZKdeUaGtzI5ZXouBl4lLYlb2iyuiAiBYsvfB09rwOru/OU3nFk4bHAbtQAObKgvwlHebul0aDQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":12200,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjxnaiACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmp0nhAAjWzoX7mIMtvbquVzg2dgBXqqme3/7dtiVGIEPGbBSXz0KwU2\r\nLWz1oy4bCsDCg4nlg0arD1zqXyk/BVA6Shu578D8T0aUhg2NMi8J9z14EvN1\r\nGBCj9ziBQsA6g6J1I7q3ydYOhrFwjTUVjQIINXCWvKuWgadINSlKMtRr7lx4\r\nmbJ18FaxseOTilDuUWCm16Xvkntv919b/wix8p9UsNAjCbxIEB+Dvp9d4ivs\r\n48I8ENqAoV3RbHpO2lnuH95fg75geG9d/FghVEW5GdP1rHAOJQ8FgYUBpm/t\r\nySppfix73OuPxetR6RIs+BSXr9RUWopdRY4OLZ/+xwhVpeHvHB5AQzRdRTyf\r\nuGuw4U8w5VYqK36JPdw1gkOJGeuPyIiCH8orSV7RIMpmPegiugFbx7t0yO3F\r\n3EfGg576uBkt5e5CA6vp4Y37a+eNOgodAop0Ha1ffN1dAgbsftQfMmmsMxdo\r\nRBy6SkqUtcE7JPLPK1XF97pZbZpaS7/1+bd40XQU9AyUfBh8PysG+ZcRseyB\r\nWs4WEsHIIq2cOSLSBLtufskdS1VMuvOjsqJ5YmQ4U6qOU4Xa9ZhZNFKx5DiK\r\n/2TyyErKFHpCDgofq1mL7XsCF1SPcWwvpJwHAg05i7XG6i1kbd7IPxn/P8e4\r\numYpuooDEmFvgW9U4mgow3o58Keh8E/CGDk=\r\n=qonS\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"86636f9084dc8cba910df9a68fb9dcd2e36dbc43","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.3","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.13.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.3-alpha-20230117102108-86636f9","@whatwg-node/server":"0.5.7-alpha-20230117102108-86636f9"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.1.5-alpha-20230117102108-86636f9_1673950881950_0.8882173477192146","host":"s3://npm-registry-packages"}},"0.1.5-alpha-20230117102822-72dd4dc":{"name":"@whatwg-node/router","version":"0.1.5-alpha-20230117102822-72dd4dc","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.1.5-alpha-20230117102822-72dd4dc","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"f6d5e5645a3ed4ecfc55426ab70c6f8cb4c008f1","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.1.5-alpha-20230117102822-72dd4dc.tgz","fileCount":6,"integrity":"sha512-8qg2mFH92Ruqy9R/O7XKr8aO8OzphyPPgn+qEPDL/qs1kAdrIyzk8I6xS79kTd9tBbh0HphFLNsNNWimLdeYcg==","signatures":[{"sig":"MEQCIGACQRc6imdkyNRXKXdotmQfmWxWOMbUL5/y9B+M7ykIAiBStFmOFJ9W+yFsL1AekWCitS+qZgwc5o298DhPRZC/hQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":12200,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjxnhTACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmq/AQ/8CwpvpwXo/1skwHiO9yYNyOCl5ZXpASi2bg/HNQyE1IQm+KDQ\r\nUrP6lN3QlCmUOVHI9IOYOt+k3f33oXCrBoJOkOEFay+X0oGvQ2Zc5loUXy2T\r\nBUx3cE9ul47EdUoKki6YE3Q+GEpwDjVtKVdEdY5fqStNiVLCIclkwz+laA8U\r\naLv9NcF20zrpKqTxX0o0x6KQjI+rWkeu+W1Emt7W3gDGy7V6HALPzHHErWWw\r\nIuNJ4IvXEQIoGpDdVW/2gr8Sr4F3p2F3ekwwml32mdV/paLj8H5D5+Kho74S\r\n/TkTtuBUKZQDiykXMmv5f5v6//ruJFd7WmNWwKJUJ5ursYsEoPehaLtyZ9B2\r\nHdZnhGHdVNeRgeGyEjjDWdmDYKj3GerI+lTAETyvRAJhEBlvuC1ZLsZ7ppgc\r\nQ51kVu0Fh01Zlgpia8CqE7b18HhKb+IRZNpmKsalOtLsy+xGemIQ2TkFD/bM\r\nXI2LxI7Kj+fSlCJdgLqE2HXyYwUw8oPnKvb7EsGDyxl0SBBbNV0iiMIorjAc\r\nY8Sr/VbSq8ydFnhTk3VDiAZObzudExOlS52p7cpo1g504j8AYN6XBivGBTvC\r\nGUU+8zJnXue3lqyrbieyTa0QosvzrSDsdY7smL9E8iOoHoFAdzNccbaYtjkq\r\nNg9JhPPOioQBNmJ0iJ/UcZj/P2fsKbq3lKE=\r\n=JboH\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"72dd4dc8b76e756cfcbbaa1b94cb8b2cd20e0efd","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.3","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.13.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.3-alpha-20230117102822-72dd4dc","@whatwg-node/server":"0.5.7-alpha-20230117102822-72dd4dc"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.1.5-alpha-20230117102822-72dd4dc_1673951315434_0.4049920357340977","host":"s3://npm-registry-packages"}},"0.1.5-alpha-20230117103221-bf2adb0":{"name":"@whatwg-node/router","version":"0.1.5-alpha-20230117103221-bf2adb0","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.1.5-alpha-20230117103221-bf2adb0","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"f8262991624c7c4a199b08d99b0e6fdc101ff712","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.1.5-alpha-20230117103221-bf2adb0.tgz","fileCount":6,"integrity":"sha512-IBx1yOwLRja5O9WZaMH1Z/f6p2KKkVzGrz8C2Vo0S5laRSgqvubGtjtuObzWc/rh8LD495lqZHuNUO4xWuKXGA==","signatures":[{"sig":"MEUCIDzl/XMR/UHps21ZYNvS69TnvQ1F7WaimZWW/XWDa7yqAiEA6qbqLda2YFRlYtO1C5ukQorlIiiCqwP7MCMxiFXpN/U=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":12200,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjxnlFACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmp7Ig/9ESCH2TpPdx7iGw5HH5H8/qyvSF9spgK1kktC7Jenst1TWQMZ\r\nziTQjhyTMpBIcPK7alaGzenOAfGQRrT1c4dIWa3xPtvKEA/gCQZIaIeT1GCD\r\na3qyfu5NVN0cOHyEtbU2s6ZCvl+ipVX1cLrutoQAej0NPbn/NB9TRHH4+TvU\r\nUmC/7oxvVb4iN5W3YHi3jLeq6m0D7tbS8h5cbxcxqijqJ+gQHChiCOnVPYhy\r\n9SX1sUI/g+Z01D+rkjv/i4UKAc4fJhvNXw0SYk/+g+GmgRVlgavrxQ6UsVqs\r\nLrFKoHJi1IfT5BbIRlWGZBKYtAPTrNbEBNlLCGCeh9Anz/MdA+XdmU5EZFql\r\nnKV62qNBFKtjSQuDJahubLYd0PIsSLLzsGyWF7DRSoqmc7gCthHJ1Cv2pqgq\r\ndlcc4vWUwuqMoRpNEOUDIAPcy+T77GH905knou4j0g4DqQepPIHref09SYml\r\n7/JhqcM8sYUjzpOfnXBKMkZR0haYgb7ZMXql3Ukm3ePJIU69bwR20A5eXRM9\r\n6ARna8BhboS+9Jqqprbz9bURVG3xDIAAfWuo3QlTiaU7Wz0nOPYyvP9k0u+y\r\n2uIECGGckNzfE090wR1lIpBphSXObGnBN63kOCHduqghrJPruV23T+K86zZy\r\neald2HDCavXkDLQ/ZOvJte8BYhbbBOuIfn8=\r\n=jwuI\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"bf2adb0ade39976475d314c83ffd61d120e8aa37","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.3","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.13.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.3-alpha-20230117103221-bf2adb0","@whatwg-node/server":"0.5.7-alpha-20230117103221-bf2adb0"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.1.5-alpha-20230117103221-bf2adb0_1673951557625_0.852084549370042","host":"s3://npm-registry-packages"}},"0.1.5-alpha-20230118095720-6a2d2f0":{"name":"@whatwg-node/router","version":"0.1.5-alpha-20230118095720-6a2d2f0","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.1.5-alpha-20230118095720-6a2d2f0","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"95ffe3aaf4f8e1f70f3aca0bcab4348c3b5aa1bf","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.1.5-alpha-20230118095720-6a2d2f0.tgz","fileCount":6,"integrity":"sha512-PhkxWIaAgbbVqmU02aC+4W5gHvUYhYitzu8clwLd/iie0my7e537Nft51f3/0VzMoNmwZj1w8MR0yLMthQA7sw==","signatures":[{"sig":"MEUCIFO1IEwAgLSipNk331hlorFTTu6AmA9obfioFb+k83ZVAiEAgvoycNrXD72KnB9ikZkmgzscfA9uZtc+oYNrKblN6CY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":12200,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjx8KRACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqoORAAo9F8iXrU+ceakVJmSulkQbTfVI/din0W0FRQdwg4RZaknS5q\r\nb05CqbB8ZOKX9y7b8JGJqPoyhKn43IoWVOmTu+0lRI8FP3BapD90pnz8tVfA\r\nvrw0Y1kyMXVll3PJ1DHhRyRjd/rQb9gNTPLtzRFgav2CqvFHcpS2qnGS3GH5\r\napjnJ6ZQngSHfo9+HMLx+QuzgW9nu1uYkCs1iOU8cET5E8bf5OktXf+k2YoC\r\nOMENs3r3n9R15b12gCSHvSxhXGhvpb0wKPIlhGsdqAq+/7Jnt/m8moomYR6T\r\ncbq3svzSl7wDB0thfZA2NNLZA0qt2bpu8nRrN10bIGiZpnTLVvToC/grlsEL\r\nL1WCNckU8ouc+NlHoONQctcmPfNzFfxGJuJVbezv9RU0I1JcnP1jHH1DHalg\r\nOFu2fE21jOXzhNpH15JoGN8NPwFZD5/w7GmQdh1KmqdlFeaG0dZL5qNU3sN9\r\n17fwLaPBdfEYfj2+NznQQc4OYHvNM3UyJzZj1J8CAPDAmAnQCUv0YjscNaiU\r\nEDQ1M385vaIwGfSSjK2fOp2LjZrpZTkWJYuvI4Q4idvUo2sg2RtGluJTx4ex\r\noq74V3O8E2IY4xJvtQHHoW2M5xnxEZ85Q3oOpXfrLgNfFJG4JmSJ9o873iRw\r\n3VyJr0HFm0WpbQ8DfvYzf597s7nMQCDuiYQ=\r\n=io/a\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"6a2d2f08da58dca1bef1a2811c5794e458fc264d","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.3","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.13.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.3-alpha-20230118095720-6a2d2f0","@whatwg-node/server":"0.5.7-alpha-20230118095720-6a2d2f0"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.1.5-alpha-20230118095720-6a2d2f0_1674035857485_0.8320062525252387","host":"s3://npm-registry-packages"}},"0.1.5-alpha-20230120130300-bc9d705":{"name":"@whatwg-node/router","version":"0.1.5-alpha-20230120130300-bc9d705","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.1.5-alpha-20230120130300-bc9d705","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"add44d3a745cfceb557240942e051075371632dd","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.1.5-alpha-20230120130300-bc9d705.tgz","fileCount":6,"integrity":"sha512-dJX2qfibzb3glbpfz7VYIIbkTcw7HgTFdSOlqnWee8iZ1cWBy83ABxSSBeQhy9jMcvjez/PTVxVAp/ERlDMx8A==","signatures":[{"sig":"MEUCIE9xXJTyWsQSeqJh07e5rcsm/GV2O9IxVY5/YcZLKInCAiEAoZjRfigZI9E/MxQZiL8XgO4S2hicgl/5J4hEBkIP6Xc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":11684,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjypEQACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpkvA/5AG5XbivtoH+lngDrNvO2uWtF8uV4PWqOTdxJSvMsB/NooC/D\r\naeQjJsM0lnVhkU/DiyK74RQ4PMeCZYmu5dQQxBYlE9qlKaGUYe+oNrn6RMmW\r\nYLVM+ejhp4z7KdCncrAbZFFXaIeIeyXaSZcIQkX9IS0yWTUoV1iw2yiMBblw\r\n9n+Bn4zo1WZgSYnlN0L4smtv3hpUq/k72OZ243mO7sAxxVTs7KyWi1L9GI6v\r\noM4rVuDg5zpXpQjBv0G19wwx9qzKy2osiQOAPAcsGBP090iv8i1aUKEMq9rJ\r\nkGu3PLAd7ap17Ex3PKpoSuZtUa3TjCdKW97Vt/pvcEhNm0BKD2WyCpLqg84G\r\nIumjsru0Izay2+4VcJBe8zNeSMugmch4Tv2GKLItQjbxCh08rMdKfzLI9Zfe\r\n1gd+YCMcwaU2tp2YpgWUF3FRMTjvb3TrpsfOosYQF7aQdU8/tit4yiyWOyC7\r\nNJN3uJ6FLesKJnQYL+Ip7TPflx0PzU/x0qRkA5MOLhiNs0y06TTV+CZvnqcH\r\nNL+vk8F/kDdXBHnp/CxqyqrpZCOQxYSbMEZYUQd41A3jDjJX7rCgK3fh4LOz\r\nQz5oIlrt/6gOSCjUcOnULKNe76HhjxGqjLIdDv4roQtJldPHUiAVkwFn9ba9\r\nJbQIq28/cnIr0aHK30jawGLOhU2wJbcTajU=\r\n=ZY1f\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"bc9d7051160c547c7323fd36e94c83a2ecfe76ce","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.3","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.13.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.2","@whatwg-node/server":"0.6.0-alpha-20230120130300-bc9d705"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.1.5-alpha-20230120130300-bc9d705_1674219792202_0.16163302226282972","host":"s3://npm-registry-packages"}},"0.1.5-alpha-20230120130512-94ff6e7":{"name":"@whatwg-node/router","version":"0.1.5-alpha-20230120130512-94ff6e7","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.1.5-alpha-20230120130512-94ff6e7","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"a1195b31b1d3175ebdd1cbdf3b7898efe1950440","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.1.5-alpha-20230120130512-94ff6e7.tgz","fileCount":6,"integrity":"sha512-IAP40FFL0GyvMkvz1dnA7q8BTZixqzVIUUGHUPLyXVK+dDZwfHbOSbgY5AzHYH+clHQxX2NHVH2hABnXcob1og==","signatures":[{"sig":"MEQCIC/RFobXIiKqnKbb+kYwg4xJG2POnjgL213g12vMPDlOAiAHRsR9n4KZzmVzVJTklVUtQR+IgHT0T1IcBNDusMn7fQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":11684,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjypGVACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoPBg//Q7KD+z+1SZiFdh35WQ+zh7jb4C2Ezvd5K5r1rF53zt0GZzMO\r\nG3aqtsl8vNhwlKbVt3NIRf5pa00CQI618zW5REOaeICA83Spn/X+hClGqey5\r\ngeQqAPCqcSBU+n4DSpbomqdzPQ+ILXhSinvni2r0T65aFGic6QpJKlHQkMaI\r\nmuQ7hgDmk8BTJj2byxzMBI41fDrUuSRU5o5IYPrpKbxPsQgksuNsE7oJwh9G\r\n8Cw3mV5ZFdz+fnQUJ8ZiE7OwG4poNVFvazplrdX8GoTeqvYEqhOw3qb30ZHP\r\nsXnQbzqOsG4+RYzxrN/5s6w32Ib/HDYiJlAYpUpCWXmxD60DXtDQsQG+KCCY\r\nN1AKJRcEqIrJHU0+LSvFfbkJX4jc0NnwmgYFSL3gqSpRbvkNtoIddr81imCz\r\ncTYw5f9XLolD/ZkqONeOetPOnTr4z5qQzznjhW0fVOqX7eeBJz6SV+ZUOZY/\r\ndNsyS9BCx2YM6k4nSaM4eX0H9lcpZ9X95gfZqjET1IJr8mTercgeC45eiAhp\r\nF3P9pNYgknZ1b+t0CRozosKHAUpD/UOkxL+9Av+jYa3TfLzNiI2Rjb3dabM1\r\nnYL8PfYvqmpx4UlpmwYAphFzXRatnwfy1UEKghJKNEZcfgWn7F2KgiKawXTm\r\nehZS8/3uahsWstD3RoQKj6xzlP/WTJiRBs8=\r\n=ki+h\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"94ff6e78dac0a472f79fa3d75bd5bdb34eb4b3ee","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.3","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.13.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.2","@whatwg-node/server":"0.6.0-alpha-20230120130512-94ff6e7"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.1.5-alpha-20230120130512-94ff6e7_1674219925512_0.3510613129119773","host":"s3://npm-registry-packages"}},"0.1.5":{"name":"@whatwg-node/router","version":"0.1.5","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.1.5","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"be2691cde0d9b883a4157bbb52bfde369804aff1","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.1.5.tgz","fileCount":6,"integrity":"sha512-5064FsIKYX+uvcaBwj4mniFAzTAaKsBXpUBIAdWkjmWxmZ7u0A5gkdKMqck1a/4/ViQlmZubXcpK85aoUtrg4g==","signatures":[{"sig":"MEUCIEU7sAoMsluzxhLJfAE1B70qLEhKxIoSJFMgoaHD3PsaAiEA30PmeIGjYbNBMP91HIFcodcEU0t5Z0VgL9TU/FMt8Xs=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":12113,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjypIqACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoERw//c2Dxm0mqMvJTLWIKNkaZdYip09w77MOswSP+97M7/95ljUuj\r\nUgGNBYcVM2o+fYYy0rchFWewYMiT5HRuTtQNTWLBmhaiSLHoT6rxxip2jmLT\r\njfsqDBK2VHyhsXVfh9O9ZRnVWkC9HUrG0dvObxQbMYurR/A4u21qd4Lio/yn\r\n2YnSXplqaJ2Osq+j4O1CeadUuNW5fYYx3lA8Llb0T9qNEDUjtOqgcTc/cZLS\r\n8bxKHyznq5sHKa/7QxOHygEbL9kiJqHm6UnpXveSd5GpAgofJtDae6Qqa1Qa\r\ndeMFIJ2q4qs2DchQPEY1IENaAP2CMFwhvQZ4h/8oUS5H4KGKZEEm+evERhjx\r\n7jZAox0SqMQZLEjGYDU5DDI3ZzDcEXy+BY+yylzZ1tp/5Ml1CuDuVFdSz4x4\r\nA/EOyPaXGAHmqWu5EGKM22i/m7b1Et4zkBrGipO2gsr+l6yELp2vDKRDMHOX\r\nVSTRXM1QjuMByvpzHIFs4gFtJRD1WD4XqdP5WE77YvCuv2jJeLh541rkTQYR\r\ncvToHrMdg2U6o5PkWvaPZqST6hs6LVUoNXTfnKZBty8nmHUh7sZJRkQBjotN\r\ny0GYVqZqt484I3QjkkPtJ3ocgcWg+NFqsT6zOHsao0FT3GV02uuxO4meCFSd\r\nU4iUose8Gfw1EpqErtg5AYyqmWbg1tQfvt0=\r\n=ySIM\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"77c1a297747a849097dcd40121affc1347f091c3","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.3","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.13.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.2","@whatwg-node/server":"0.5.7"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.1.5_1674220074484_0.8129400221155223","host":"s3://npm-registry-packages"}},"0.1.6":{"name":"@whatwg-node/router","version":"0.1.6","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.1.6","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"d5d31a85e5cf8763096b3a4256b452c4ed3afbee","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.1.6.tgz","fileCount":6,"integrity":"sha512-dFi/QA+fHDaVXRe2I+rH3MRlN8EU43RT+LLky/P7SwsIbSdJ0JvyiOzoLZxuuKLiNL652c6B2Q/OSrxkXRLDTw==","signatures":[{"sig":"MEYCIQCxkDEVIqmqdd2+/7YF9k4JteLGoDhO54AHDTjAgCo+MwIhAMHWit2KLwcDZSHegYAbnlfTVFImbtFtsHc5PPU9ZNwu","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":12113,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjzrp0ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrRFw/+MxHKE0XR4XoBkyES86TTJjAhy2p3KHlYJgLefJV42DC8Ht1M\r\n9fPRohxBbkOXA6atdYfRhguj5RWLZpVnXy/H9523ccT7Em6JY1cZkWL65nra\r\ngvFdCIAO2w1oantWhYok5IVGpjLihy6mx87ThLxRsi+atK0ZRxzbZQy7lDq9\r\n/hQckJ2udyeidnm6N/UK1xPfRE9ltSXGIq5ndJuJaVfPnNsuomGeFWRGJWX9\r\nOChyFX7PMtfGa3Ey9yKbV2p6gjuyX5tIrSYhB1wy9xvq7/aVnnvIS5YEFl36\r\ni/1/V8IxvpWMD+9dyX8r7LxIDZzSwDkGxrZaUGIO/b40SHgrwbGqJHHbHts/\r\ns18CzwKIvbtjpdEljQWpRRYUWj9KeIbg7fC3uom12cdzcr9QnnwZcfyolFQl\r\nazpEpwCauLGfhfw8GcY3mbLg1zlK9D4uklV6DGqIRsB91xUJn+K94CNDYA5f\r\nD8qrOyLQbadD/xGeXSXS9azPsFV+L7xG+lpBLwP7jw8TQC9DKUFj9p3KNe9c\r\nB/rOYVVyId86/GP+JOHYgbUo0FrcTrE2W5gSWmryHWnal9NlbpMltRXeQ5nA\r\naUlZCPvC/x/czZkQfRBjpvmM0PVWCOkVVZnPAHx+jqIqEwrUV8BzH9Ej0LF+\r\nGKV6F6W+inqqv0+d3PNL5doJcjMVSqieabg=\r\n=ddJK\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"58e5afb841e804b466c75ea596a0a158f756a6d0","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.3","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.13.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.2","@whatwg-node/server":"0.5.8"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.1.6_1674492532507_0.15169930244811747","host":"s3://npm-registry-packages"}},"0.1.7":{"name":"@whatwg-node/router","version":"0.1.7","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.1.7","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"89dc0dda4fb0e73307ee783464fd505d8ddd41d2","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.1.7.tgz","fileCount":6,"integrity":"sha512-feBvOqGMNnX4oC1HMbIOO/buxIuDyHIpQY2E0AhrGdewZrlQk4AfKVlaey/1vJRhx5RLPwEFjlzGA5jjdQID+Q==","signatures":[{"sig":"MEUCIAICwD8jryys3kv/I9T0Q2ATeaPNJeREDp72pceRIxcPAiEA2lH9MQxQk7ARfkLuSdj7+yzqkiBsXzOVy7SqEX+xHPo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13047,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjzuDSACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoJ6w//Ulba8tuyqt/awNnr/Dj8GTBwWTS1KNksBeisIJs2W7q19U5a\r\nEMUhHsbwB0l9oGTz5YNUCO/WRxsIZ5N6Aw/2TlgA+37+/Z8BEthD9FDjKJbg\r\nVuzDjY04rJkixFa53ZoKn6FCfS2khNLVhGDvizYbtc27mSMm/bSDhdKAPHx1\r\nF0XlURh75CDnsNPmvV/godknqDL90YZYzFgW9UoQzRx3kdk9skjwpIEKCS7C\r\nuBPyu6lbhSZmqnuviHgKC8xbx66NQakKbV8N0fv7BeXAtFQ4DBwSSeQUt79d\r\nyAVicTnbj4a/tk4NgWQTK2ZfiVUbydS9xHeTlXCCjuI49zcfemx3QeA+QVE1\r\nObr2NlKU4MX0z9csvAyaSnxZE1KIDOpiy6EaGVtvbuyzgDyV6L5rzRZJ/LXD\r\ns7tJhx3fNQHCDoNBsKPKYLf9GnU2VxNtwAe6lU9SxBj4CAQ5y78ZR9jAbca9\r\ncJlT38O50mAO2gaq/SoLrUxtVSs8afwnI+7LOywvm60OCv+ar9qt80I7vVvT\r\nXhrR2+s9KR1dD+HlcSp1M4jykWxDWPkhONKpSmXD4JqtdRGFCkTZbZxbj9pT\r\nGsrLc3WSJGr0RhuQ5Z74TSgrBjquyNSwtBFPax5sni3ZBejsq2I0URwavnxA\r\npvspV7gCAU8g+5uecln1XC0uGOx0WALFfMM=\r\n=7KlH\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"2b781f31f6ff7bec1f655607e2c7a013736edf38","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.3","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.13.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.2","@whatwg-node/server":"0.5.8"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.1.7_1674502354551_0.8367251791473971","host":"s3://npm-registry-packages"}},"0.1.8-alpha-20230126122734-e16acbb":{"name":"@whatwg-node/router","version":"0.1.8-alpha-20230126122734-e16acbb","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.1.8-alpha-20230126122734-e16acbb","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"a1021315160dc029fb668a13ada573f819616f72","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.1.8-alpha-20230126122734-e16acbb.tgz","fileCount":6,"integrity":"sha512-wHH9cyQ4mKem7WtVxNNSBSf7h7TVJlI+lvU6+YA91VJ3p5impBlzKa2t7wPjS9elvEbY7h6zTaOiiM0E9PNlxQ==","signatures":[{"sig":"MEYCIQDCmkICNu6jZbQypPh0Z09OntsNdhPVo+fbZ+y9R7hndwIhAKYr0gmkweTL3YOZYM3ZYuUSr9xSKzmF4t+Y1CwfMCCL","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13134,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj0nHFACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoK3Q//ehKfi8Xr4e/yyTqswAvxatYzcD0F04cojMO239cZ4LHrRVuF\r\nZEHDWRcie6M411JzjTA9wLgYMAd7XqL21NyW/cY9gk2WtfT2betfUT3Kr1AX\r\nbdgcaWkF21hejXeyLlsUYGntmi6hhmXT/Tvz9ZAHw6cMm1z+gUC3tVbNYmZ1\r\ndIOWS68l8f1zZz/DyVe875iLNQ2OIvUM2UnDMz4qdWLr26KzfSHBhIQIwWU2\r\nQLvC39zqbBrRw+92JCE7WcjNP2uhFf0ybmTFFl0SpkCkjPn4QwXw8zZdBnXf\r\njFwG67vA4wfpjcs3FSdUJS8ghOoriSismeoo2wxCXNHGPisxftTowUtZgUtI\r\n7TAVInfaxAqKtXd2JEI5ZZb3TVn/YUVrtt+M0u5ifmDUaiA/aybXBLJi9BBZ\r\n+D6qIYYVbwTv4QYABMvYvVZ//pL/Vfwn7qOrr3zi8J1e0R1YdbhhcVXhYO4L\r\nNSaqfrtj7qf7y221PqXkzbunhu49iCtgnvkVOsu+tulnFpUPNGWJkS8/CQWm\r\nMXmCMGz6KN9Qb8nATFXGlMzQQGW4iQQ9gw53k5NfXYnog3vVSCMp3Lgj92Tj\r\nvzLSAaEv1rTcgQNwr1kqnwPgciireoXQ4Q5o20sQ/WW9TntgSU7hkercob8l\r\n0R+h0+RK+5Mv3lBe4TFQU1Q5Ekf8z1FaqlQ=\r\n=Tq7P\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"e16acbbce9741f451bd0450340d318ceb6f9ef73","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.3","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.13.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.3-alpha-20230126122734-e16acbb","@whatwg-node/server":"0.5.9-alpha-20230126122734-e16acbb"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.1.8-alpha-20230126122734-e16acbb_1674736069039_0.33219571052928987","host":"s3://npm-registry-packages"}},"0.1.8-alpha-20230126122900-db01245":{"name":"@whatwg-node/router","version":"0.1.8-alpha-20230126122900-db01245","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.1.8-alpha-20230126122900-db01245","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"ef20a7e04d450ab23a48852f8580933cda8cd010","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.1.8-alpha-20230126122900-db01245.tgz","fileCount":6,"integrity":"sha512-KI2lmffQbLeHmsCdHvKink5iACHc7k4wMiftMz6LlNd7fkTvx7uCC9djGkHXvoQuAC1PRg2gsFv9GHh+6K9P/A==","signatures":[{"sig":"MEUCIQDyOpj1UBl1N8nmeNuMqtoOOLS86rkpXXZ10U6fjYht2gIgdMc8wyJaXdWxbOqnQ38CdAhvR4I33f3hl4A/PR30tKA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13134,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj0nIeACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrxRA/+KaJaLNtWrkiseNDeEQ24fPS0ijiIMG6d+uKfqNfXZ6XDXlGu\r\niaJ5Z6D9hGMhICcb5voJEqkfEKrkdzdSEAWpupcdvgzIcuuq3AYTg2aOBgLL\r\n15KcGVfPEijPAFA3hVFA4Ya9GldoM/GBgp1UokdnUWljs/N83Ity99/0wjmD\r\nDQEpgC60H3AKKPZ2275Hp/G7pTMPoOtcnlWFg3ew+RDuhmIoKIE6bgo8jhoo\r\n4mSyvuOwyi/BLGb64MOrjad7D97gczcEeCTn8vrP4uV/JgMZaLiEbizfkdPT\r\nTq5T4nHcZQfrcVMG+elie1q7eymR8EuDHP4GMfcnKM1PNdiTBPShSZ03mBP6\r\noIO2YRS9Zr9XX7GEjNZebswLuX1thChwZ30VCV0BJBpHN7Nuw/Y3V16leVSd\r\nzaYXv9Y+KjUWisrLJvsSOnIRkIKIMm+2VA/nC1XFuCHQklPoAjU8U7zsZOEu\r\nhtRCva2mcFul6kyAleGRqiPLl22BRc0aXnmjmBGrNMTGcGT7/C/5DMRWOoqI\r\nixMxsbtfAXcoyjzjvLqEklLff6ESVf0kelxprDKyjrEiS2499d0799j9joA0\r\nhhLGcUi5xTQEu2/C7flLfKqOeSHUxzbkE9STFHqCqE7oHXf5oH9qSevVu64a\r\n4aU2mkqeoeiGT1qmUK1AovokTT5QrAwwTtc=\r\n=AIRg\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"db012454ae15cb17f3120e3a1a8d5e24a5a55c60","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.3","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.13.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.3-alpha-20230126122900-db01245","@whatwg-node/server":"0.5.9-alpha-20230126122900-db01245"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.1.8-alpha-20230126122900-db01245_1674736158636_0.5939971426024793","host":"s3://npm-registry-packages"}},"0.1.8-alpha-20230130162825-1e02017":{"name":"@whatwg-node/router","version":"0.1.8-alpha-20230130162825-1e02017","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.1.8-alpha-20230130162825-1e02017","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"920e2c015162ba5cde6de38b92b7a7ccd881e5db","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.1.8-alpha-20230130162825-1e02017.tgz","fileCount":6,"integrity":"sha512-mlwuie0xnUeXnHFAa6A1SdRZ3Lswp0fh6kZDc8hiK8G9GHVpLYhixTzDGh7B40WWTIoCYJ14m4ttB98wfkWghw==","signatures":[{"sig":"MEQCIDNu1nygPCU1vsGF+jyw0j1q01gjRyLJ96xXwrW7XSLhAiBGdJXWnX1+kl7AivTG/+b2S3LSd2eRJssNAstKbqTyWQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13134,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj1/A5ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoIUA//TyoHv2z5iX+Ypp48d1aBnedxhDoLFW9gKVlf5/B9DlLuU0Ja\r\nDrLwB8+FTWPTCxvUgc/eIHqFIlIiPstTNpLAZHGmM0FeYSLXR33HroIuwbzA\r\nUZ4COiFBlNuwjurarx2fZOmxXzLO4cL2ec+m6/HLroCgw+eVPPwGQCQWf5Hw\r\n2dMUAkFwjS7ghjxVRYl/XplQIknvGQpQ3dfJbQYPNwPjFcbf7Y14fAP+bCPE\r\nqkxI/b0cwnIEpvlxFoqubYuvDKebOva34mR0E+3xyFjCaOrrlu6aY2V0P6Ya\r\nkM8yzis5+Vtgn2hFELkpjDJZBfdHJG/GpaY7cZjTtZfcR+J5CBC9U9ngPkxD\r\nDNUblAjQgWheI0G9BvzoVHv9HxqbEc/rmp6TUrP6zCmfmKNHmIlzzcgfMRyQ\r\nKXiQZXUYMr8bwEcKd2QzFO7ltyisnPWVWei0xIloPhJh/F8JcIcX+kdCVoGj\r\noQE4GsgZfBVvqv1cEYnZuJVuMHzGDsoGKhsPTuSKNh4g0uR7qwlQE8h48B3H\r\nRdmfr80vMij8P6i+PYLaqI9r9Eg5965xh5zIomQvU/yJKCwY574oZcd7NrLo\r\n6WQNyUd0zL0A/cx5pGYuGebzdbDvv3N1DxlS6h7EIqN3dYHv2t2R1ivp/4Nd\r\nU/n5RJ9OoxG/AqV1wFeK+b5iDIxq/5r0cAk=\r\n=Qc19\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"ERROR: No README data found!","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"1e0201779b834b7da34072a4d64b5edd38b47ea3","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.3","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.13.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.3-alpha-20230130162825-1e02017","@whatwg-node/server":"0.5.9-alpha-20230130162825-1e02017"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.1.8-alpha-20230130162825-1e02017_1675096120824_0.33597587566382914","host":"s3://npm-registry-packages"}},"0.1.8-alpha-20230130163402-dac6604":{"name":"@whatwg-node/router","version":"0.1.8-alpha-20230130163402-dac6604","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.1.8-alpha-20230130163402-dac6604","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"ab20182dd53e40c0db954d5392d8fd8812dc77da","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.1.8-alpha-20230130163402-dac6604.tgz","fileCount":7,"integrity":"sha512-iOXKLdOvABhZ4sFuas+ie043cSehFeoKry0qakQvlp55LtzTedrQc0YkxwXXhc2pphF7+6eWvK00eK9on0pWqw==","signatures":[{"sig":"MEQCIGP4ZaJAzsnRO3BPrf1EsxhDqZ/tL42BuzdB4J5WY/uFAiBOHriE9M5on6zEo1+0oJIR+MJoJlrZeIv494F130p6zw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18800,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj1/GQACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrPCA//Q0in7geK3mhLVFpmVoudojbZJaVTFu0jV30hpLWpbQ2Yunad\r\nW4Mggb17IDkG+jXweoPB4tojzE05LtYpNDzU3FQZt6a//sG2tTXoHxuTS88R\r\nhXMcZ8apwI3H3sY0Rv6aCiseQRmTTdB8mTwvc/dbCwC3s41X98iDW3cYIMKM\r\nlEZTk/ODFLhVp99sYtZbOS8762M8Fo+XVT9g18eLgWFRIk77p2RasULn1Kph\r\npG434cDv3HFARmuHOAxsVwuVvb5QLAlSlevl8CXLjbFkXVVf7VDnd6BBGlyQ\r\nX3a8su1oiaDRDWt8XutMhbr6S0uKzuRsiaBXBDZui/cydQux3OETmLiMZvuV\r\nz1bpXowqC6R9EENXxzY+q3P0M0SddtOLz0pMmiRi1tzANsiA227h9EV3kXoL\r\nFzf3vBGEcPX0hixzh+fpnNH/Fu9TK0CJJB3UBRVXeKXKyCeyjf7+i41fGiXO\r\nvnMqM0HVT7ZfXB4ElZueKFwsCKK++qod8FlbFkJLkdJ2GoFbaqGUvkLz0+fR\r\nz0wl+ziCEMEQu+bDTJsIpQQHA4ANJyMfd9pqSwS8/PH01gk5uAZa6zqtXO/R\r\nicUaZ/c868NyMmdkhMECeo0mdDdBYrMu/h3BZ45Fj2EtLdAyucdz0lpyoGTE\r\nF4TiiB1DDRdfFKMqX6sRld6LvQ+eJA7Lskk=\r\n=u/l0\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => {\n  return new Response(JSON.stringify(users), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"dac6604915385dae6e0cc134102620fda7605088","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.3","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.13.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.3-alpha-20230130163402-dac6604","@whatwg-node/server":"0.5.9-alpha-20230130163402-dac6604"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.1.8-alpha-20230130163402-dac6604_1675096464006_0.5207625719596269","host":"s3://npm-registry-packages"}},"0.1.8":{"name":"@whatwg-node/router","version":"0.1.8","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.1.8","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"a65836819d3bfbb9e8e64fa1ecf1a1a8dc8c92e6","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.1.8.tgz","fileCount":7,"integrity":"sha512-og1aYOJJsL2qhUk653QMXX1DtyB1ISI7Fkh/3LuSZ1leinM53V5iSf5pG6/zUmHtHVWhvfYGWksMlOnIuoqLQw==","signatures":[{"sig":"MEQCIHhTKfXGOuIHm1Q88fXafbKP2sU4oxyjbFCrBmEoHqIkAiA2RmIzlFoRQGWWJA8p2II+UZRpt/afCbpAm3a0X9CaCw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18713,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj1/RkACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoBXxAAnBpVOFFldlwg7hwJw4neggngV66h37ajRwDjcD/mda8sxj9P\r\nIe5w9VBHIzMVcx/IyUm7TuaIEk5KG6zZ334vrMGT8SsmXDFKUkdXWbr1BT4H\r\nwC8A9l2877QT1Pwp7XPUPnGjdHy7q1v0bqfd366zfbce4+BBaALGrk547ttf\r\n+1Ina1YpsziUear2V+n79PuWMnQYSS07dPunEDFtwpO4niDWqXZZvZwWucG+\r\nDQgz0CNmQRUF2aEI92rLlegRczu/um1GMJm0CPR6Av97m5cFvhbOgjoX1uVC\r\nH7UifQJpV5aG8aFl5q1WvDqlpNsCtC0QuXUWr4EuspTDbTsc79kaK8gxXDtA\r\nqMhG9LeIIm6R5BglYHJ+/WO181T6YTmQPSUHRxjRIkq06SzZcCpczbfd8pvl\r\nfr0btqenHKk9Hh75C3X6grF3coaWjjGYQAJHBoJ017ofhsrJeEKeKq+1aO1h\r\niSxa33F918NLpxL1GcU8Kl1eGhgANz5U+BpbN2rULlOnrRzdb0EvVTMaNr8V\r\naTYz1UYvJZYtgsH00uVuHN5ozd3EMKS33GtBaN4TO7WB6TdogtLl9Wfqtjp5\r\nJ3pVdErBqrpF0ETXRF01mPBckVdruVRTCZ0vSpAj+zdZfxyGTZZKyYDxmugt\r\nMO9W+XsQxLiDGpW23d6suotGsg37hkBbW1Y=\r\n=bXZG\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"0646ac95269255cd9fad8906b313d066b4edd54b","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.3","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.13.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.3","@whatwg-node/server":"0.5.9"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.1.8_1675097188362_0.485060390159032","host":"s3://npm-registry-packages"}},"0.1.9":{"name":"@whatwg-node/router","version":"0.1.9","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.1.9","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"8b24cd64abc9b309c6d9cad7655813b1948024ef","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.1.9.tgz","fileCount":7,"integrity":"sha512-ipofTqg7BJzb7wsxWWy+4mhsWblel9k2jYbE3m5YQCQcGGTmiqqhDmcYjGeF/LdZBt23yWmGKq+o9y7ygU8HVA==","signatures":[{"sig":"MEYCIQDbruWFQA6tf4Q+vSwqvFF3y3zpciJwGMu4jjqwtziOIwIhAOYn/L9Vl6SZWSzMND5wvDi3b+sH9eo7G3Bef3NSrBMD","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18714,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj2AZhACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoH5Q/+J+21c4NMspn8HRJ7ksso6+qAZhDWcpF0brd7JpOfiUQ1Ec5B\r\ntNWgGrvchuk18F5ZbM+yWNZEVUDTs8FEXBkPIBDdiBkvyyVzxrAWYVj9FZqJ\r\nyB5QH9j6U1rtfwL3uUGebPC/9ESJEyI6PedrBsT5y5c4/x+4i+Xoh/Sa5a9J\r\nOFXhGl9EbnJsvdJfilR/G3QKIm/YYZRyZru0SMdjD6JtW2Jdu8avzkPjnYE0\r\nONC+FKYEw93YDCehoS19bCLOXGeOnNeELIS27snH3PaCIlmzug5e5VotwgXs\r\n49pez9kZIOZp7iz2d13By/kj9cg5QRgBGUngv4j1eiMUC9mMKhIJY7znbPp8\r\nkgZqW3M2AYFlIwmhlVBvTwa6DdFPeraXUQXDQ6pw8o7EfSEdj4cq+QA2Q//N\r\nZa2s04jg4G9S5h/DTlm8yv66T7g0Ja4ILaC4ggaz9lIOB2RBbH8Ty8uNzIUl\r\nLH2s/4ixNTVwr7biBYaulUyBejR8TNZp96yhXTVRWEuJNSJ+KT0CZmZmUGen\r\nlcM/3uEt7PajddycyeGZAOJGU3buIO+t5NZ6Ug5xpJnz3PQKwy1zNnsDTUpZ\r\nMFQ1OyqWK4cWS3qsQggvgcIoi3W3l6rYrgwYfiLBhKywErDjP6WmwTBNwGZ1\r\n+hxs3f6SUms7ry9L6d3WJKv1YOW2eJnVqpE=\r\n=gAn+\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"ad9703f5fb0dd996911e90e6bdb730eedfe727e5","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.3","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.13.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.4","@whatwg-node/server":"0.5.10"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.1.9_1675101793782_0.9146604012615078","host":"s3://npm-registry-packages"}},"0.1.10":{"name":"@whatwg-node/router","version":"0.1.10","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.1.10","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"715d4aecac35aa7715d880cb1c5a866c9df95a2f","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.1.10.tgz","fileCount":7,"integrity":"sha512-QsUWTNb1z8Pl33wJ+xyKviK6VDqjyijSHPZF1YOZOImE3VEGE0gWk1DCLyqEHzKBjGS0jgFyM/Nmhnvbh/GV7Q==","signatures":[{"sig":"MEYCIQD/uxA2MmiecOK/HbrAhq/PzCaQQbTuRx84QykzVpZGvgIhAJrPCCgy+ClEZ/ivJXdsNX1QPQq8F0bVSjYei6vBXet8","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18715,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj2AmtACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqzWBAAm5Tk/3/jPCHOLcT0d4UmJrY3VgjCQmZ98iRww0uKAM0zlIQD\r\nrV5HDVN7leLVKWTlmFm2YxlHG5lZShev+T8DYazTLmJ9yBlNsFtmEsZ1DnEb\r\nx6JopSuyPYYqf+9iExjRZ8wfyPhl/3o+xhfp1sFitYrDtUj+G41nzWpaXMuI\r\n4kMpaNNZgEUSxdgxkeft/gFVw3bmLGM3/B7hbayoc6ldfJTsRS5KEsh6uSbE\r\njO4QbgBh6onbhnnRKc0sq0zf+rNaaNA7RCfFyAvTDNmH+qREiBK1Zfdz3X85\r\n1fsc70ig9SKxzAnOhvx6/rKhklyxr7JfwiAlcLAHqfgna9zuoqjjMHXI1u3V\r\nomfnh/xKAOoodSvMmZ2Plg3ANMJiaflvvgPwehqSB1o4cAJLrcvOCMfHK5pK\r\nHK6YEC0zKeoyHrfHhjug7AaU+8JsXRVyzX5x31PpV+aa+g8zJjB0UHy8/CBb\r\nBVnlzEt66xbVkTTQzV7IUppNwY3fPDz0eknM9Uht+nzRFJEZYWulCbcaMJkW\r\nTnnsHf21Ia+34nBcEh4F/8p4dYkZixzFE6fO+YW5xgLWfH9jVtuDq2wquDZi\r\n4x6YMVOWQt7kAuYwiLh9Y7+FbHlHf6PzFh9HkwK8L6RHMeUTeRhUa6Lq0rdP\r\nrjfqzDUQ9n+GyAMqnd7C6tJsCK+cOmPlpLA=\r\n=yMBn\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"2ff5bc8634f8cdc193915440060eaf6cb5096b7d","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.3","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.13.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.5","@whatwg-node/server":"0.5.11"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.1.10_1675102636779_0.058531448636965244","host":"s3://npm-registry-packages"}},"0.1.11-alpha-20230202080931-398001d":{"name":"@whatwg-node/router","version":"0.1.11-alpha-20230202080931-398001d","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.1.11-alpha-20230202080931-398001d","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"42a96bd970c16632b5d977d3b6af4588e5757181","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.1.11-alpha-20230202080931-398001d.tgz","fileCount":7,"integrity":"sha512-w3uVdvfpeMQQ6bYceE/ciqgmOggOmInHKxKxoag1rkoNg5Psy/kfx9fpKLluKWvoqrhsPvMswd2SUZj4wLR3BA==","signatures":[{"sig":"MEUCICbOkU+M0gnvR6Jb8Wj0Dyvm1YIMTgfqtC/5xdBf4i/5AiEAnYeBbnfgdsz3hPSYMQ2xqEuye1LMWUn2XIgBiQKZoLQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18802,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj22/OACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmpl6g/+KHWj/VcjyZQb/kf/iCbd+S3iChSVpSVN/8B4hzsilHrQ3fiE\r\nGYrFqXPFS3zpax6m2i8qAi1DDOcU0BhPxnVV9qzcf5r9tK1+YGp+eV6xHr0d\r\nVJF4yO8nXS9b/4Hh/zfy+MDH1HxNhdgY40eBc6VcipQRL2v8p3lRicRbx5WH\r\n0rwGS5eR9WMIVn28RuxyCXGUeLpxZMGU6o3tyfNQiGmKhmbPGilnRtsi9SDM\r\nWHaPYrxFQRLOeIBr2wiobmq4REo7t78yFn7d+FmbsnZxDQTcgmVaGVgJzlyW\r\nXkU0cjQ11ORFQSmgK06GX1ygAMZIOcUj9uqBlArPM5vIKeGAJ5amNHQWEw6d\r\nB2gj/imGoJ/O+mSZF0LNbEYst9x1PVbMuCAVb/LEh0Ms+qC2fSqW5fvio7+L\r\nh7kbDTYKEUl3pEuNdaELcjp0EkZnVyGJC9ZdHqqAocohYsNz9tbVPv9lUDnT\r\nB13Kx9bqUDffZAfeJhfU2fakffeYV/IWkVkJTIL3nOEX3IJ+9Ns/YFIPe3X7\r\n4eQzlvm18bOsqYeGPjj/edm8ANDzYlV77EdiOdTXMhLiQQEelRLADK6AaYL3\r\nCHlpVrn7Fwhxo6L5kXUzzra+Wgup5QhO+AtBK57znhrR3OwfrUm8067S4TRK\r\nUsrynK5xq+yGDlaCZmokvXSZc/15Mzpj3a8=\r\n=S6An\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => {\n  return new Response(JSON.stringify(users), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"398001d03307702fbfbff09ee4d8010b9dd8130f","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.3","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.13.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.6-alpha-20230202080931-398001d","@whatwg-node/server":"0.5.12-alpha-20230202080931-398001d"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.1.11-alpha-20230202080931-398001d_1675325389902_0.870458187362088","host":"s3://npm-registry-packages"}},"0.1.11-alpha-20230202081836-d7810ac":{"name":"@whatwg-node/router","version":"0.1.11-alpha-20230202081836-d7810ac","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.1.11-alpha-20230202081836-d7810ac","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"5da74ad5c1055e0b1a36eb71449dd935f8946b42","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.1.11-alpha-20230202081836-d7810ac.tgz","fileCount":7,"integrity":"sha512-b1c93LOrcegWZ+NU6t0tYPBynJSZZ61UARBSmPfHKzBRjJcbA7NoqKTPv4K2JIFkpr94iEeJOC7Wu6LPvl0y1A==","signatures":[{"sig":"MEUCIQDtlQb8E3/BUcgSwXbq9cyEM1TWbJavTNTbbHbiyo0UsAIgJmj4NNwT1APj+zf9JNLbuWDLzu29Wj4tkBw+4thZ6Rs=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18802,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj23HsACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmr3xRAAm859UAWoMOCWRnGsbSXBePtND7cd3KKRA6Z1S/8Rm0QyG8VP\r\njocNysr7jfLnCtWa2VCT03YVS+OUlqNJCZt/mTrClgILci+ohaDTG2usMVxI\r\nDAUPNmliVUCxC9VqdGr5it5jLQ8nAQhie8deCghWFQxTy6CdtELKFCKN1i3g\r\nxK8ZCY1BPje/d83vI++b6JCm01NCfSmfCxe6kw+5JRPIQ2k65w0ILvEFGaNL\r\nFFNs1oYADi7aMaYJQ2eu0fdUgPG72ImhE/Vkz3cq0EWoUnFzZ3dn4bTYRIeT\r\nfI5cCt+UzCPARD7CoCbNkxfNW/xOO0wf+eEaVhKBghEqnBzD/ckXZHNfaTyn\r\nny9m66NU7z5vn/x+kF033HuyY+xa7QYjJpFIH0atGD3v4qnyLWZsMD8D3+3u\r\noX5BHno2qUVBFTsrViRoOGfwYOjMM7I3a89TBsgO9jC/dWUuFvONYQ1hkR9M\r\n1NyQ58XqP//guOJ2q3Xspfv2k9Jkm43gI4zWR5YTp1BKEm2ek+GcuSfOBBvL\r\n3G/CNWhrpS+/7t8rmAvl0wgPSHiCnrFVqPx9nQdrk1zWZMy0cD9FTuZjtfn5\r\nOFSNCVCajxhCVThMB3PnoVXMLqq9HQNIaXg+uoScjRcQYBxnvQovtcTcMcvk\r\nJqfgm0K0TBznHlJYu1LmTG+CpliN5ggyAbU=\r\n=GCiq\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => {\n  return new Response(JSON.stringify(users), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"d7810ac49abacc4bb295069487656f059bb430b8","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.3","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.13.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.6-alpha-20230202081836-d7810ac","@whatwg-node/server":"0.5.12-alpha-20230202081836-d7810ac"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.1.11-alpha-20230202081836-d7810ac_1675325931897_0.6330829800975584","host":"s3://npm-registry-packages"}},"0.1.11-alpha-20230202081906-5436414":{"name":"@whatwg-node/router","version":"0.1.11-alpha-20230202081906-5436414","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.1.11-alpha-20230202081906-5436414","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"6a0030a7cdae330ef5e6c4d60a92f341d06eaca4","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.1.11-alpha-20230202081906-5436414.tgz","fileCount":7,"integrity":"sha512-DIV224Lx7vWVtyXjd6QEdtf5Xbg42IWPFg7Ecoq/SJg3y1zWHu4xXtewyJTt+Mr77VHOJPaVldwcDx2+caDs0Q==","signatures":[{"sig":"MEYCIQDQ9KPO+Phpwb14LjKlObe5e2eIOOXGZ1Z66K0syZA7SQIhAOeUZZLCaDaqh6s5RLGunHoyXaklTZ8jn9eUzC4KFOOj","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18802,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj23IKACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmqdlg/7Bg6sHGuIbi+VZ1KR6F46S70xLB/vFlosAO/CAIajVp+jPBZx\r\n0+rRN3X0nzWjNU0PVePeY+ANZjeh+GU+Ue9tZjQuqy4DCRkrzqUk0Panvwed\r\nOB40ddYDR4j92HMq5y/NsJwcu5ycn9PPl1/93PDqrwJzA+AViW9pVQMyWoYw\r\n8tJPZh8mWnn5fLie7rIoGRO95JWeHluBPoUTHxmbdAr8JZoYvzs5/5OuEFfF\r\n3hFuzsnM3yGeOafxyYPK/YcptRSGuGc0lqMcP/tZygY2b+xK15XF1bsXrhUk\r\n47aEdcgZ00ArP/feNR0pyP17nOxFqtWmxDA4HfxS68l9Pe1TCBE1jnYNm01h\r\n1FjNHGk2mh5s4vwZMhrGZaS0DaIqdbHQ5d6f+JurZpJFDVF0C0BDKYjM3vRC\r\n5Utveov5Nbv49i+3hmjfgoDhln6vcHCVQ3B2Cf8uOdJQzLFDQ4EqCk6bHC6s\r\nE9OK8WMaHO9Tf+ZE54it/9g+8iDYH2drksOVeUYkRy/2DQafxPrsmf9ZTuuv\r\n5+DswyG8iqjuXBx8cDXBU+OzDFi5EB+Pnbf7r9YWelxQomDKEtYW5XJoIsqp\r\ntIZ5U3gtycwoqQvLff/V/n2MAiN4Qy+2ZI5IJAoDwCmFAFL4wVa/nn6euf6v\r\ndmluuTJIxETubfLoiG0PDB8lrPVSw0i8ZLI=\r\n=8MxJ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => {\n  return new Response(JSON.stringify(users), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"543641484d14eb05d8e4611173ffad4bd016f37a","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.3","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.13.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.6-alpha-20230202081906-5436414","@whatwg-node/server":"0.5.12-alpha-20230202081906-5436414"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.1.11-alpha-20230202081906-5436414_1675325961829_0.5436684475457314","host":"s3://npm-registry-packages"}},"0.1.11-alpha-20230202120346-11ebc77":{"name":"@whatwg-node/router","version":"0.1.11-alpha-20230202120346-11ebc77","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.1.11-alpha-20230202120346-11ebc77","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"2c5deb3831696e2b4d2099dc7452782341d7125f","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.1.11-alpha-20230202120346-11ebc77.tgz","fileCount":7,"integrity":"sha512-xoT811QPr33P3Cg9MBZuziK30EsQwiynwT4rpcbh/Ykx5TPnLmBZS21h+E1iXw76EzwpzWhtXUpso+vbwyn5uA==","signatures":[{"sig":"MEYCIQC+xzV/8uI/S9uu3OQmu61CtjrFcT2OUCN0e1GoTPQrHwIhAIKWQJsDQyoeG7XJA8suCAFDI0iKyaTrl7qGf8/ZY5Fk","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18802,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj26azACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoopA//cT8mf3Qqdh5xVH2Hc3I6G/nXwKoqXs8XL8cTfc8xk9wR5JAv\r\n8zfWfsZ8a4mBBhTAkq46s0wJFyzjTmPrAQdHHO8LqwwsvyImMj+d+9+EufnI\r\nIeeS6uLtsZA9zA1WMLG6kGTVVsicHOASA75xyvZYLMlnm6/OwJMgHpUCPXnR\r\n2jxmVfzSGQ0eLO+WL1fgp024P2KnMwR7V1RTQ6WVxvg9ElAMr0xif/iE14gy\r\nSPIygXC7+XEDWrkTDK4hmr9AV9eP1aep3maxVPjA8GNeZ2Eyfz+EPvSrzH1O\r\nIsNibc0JLw+mh2WS3TFBzYvuFTxqAfxnte2mO6woONlCJOwagS9N+A93eYyP\r\naALf2TlG7P+8A2R9D5q6zJn2c8EZ5Ba4g5pC03ghHjGeghAHescRVJI5ftcx\r\nIneTwYB7iTUEvF8FsqZQxa8wucygo8zTZjqq+Z018kSCIKnxjs5Z9UAN9RQt\r\nTrd3fqcdXn7LQqCqJo7Ohcqwns2dauUHc1SHaGhOhPa3YNvC2oVy/Cw6Sd47\r\nAfO7fpSRnoMwYiXkrGr5CYf/kKxAHbbUss5Vatb0xK++j32tZMlN4gE1UeTs\r\nztZ0Qzp6P6uyotLOJdKjdbnEENv4zJO1JdNi0qJtQYToTtCj8e/qPU/3Xlfg\r\naUvmchwA2mqe93zGvgVi8qzRzWDPd59i9oM=\r\n=rT/0\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => {\n  return new Response(JSON.stringify(users), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"11ebc77741d051c1791ceb13c1ab355f919b96c1","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.3","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.13.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.6-alpha-20230202120346-11ebc77","@whatwg-node/server":"0.5.12-alpha-20230202120346-11ebc77"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.1.11-alpha-20230202120346-11ebc77_1675339443408_0.12749037710391686","host":"s3://npm-registry-packages"}},"0.1.11-alpha-20230202120635-b6521c4":{"name":"@whatwg-node/router","version":"0.1.11-alpha-20230202120635-b6521c4","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.1.11-alpha-20230202120635-b6521c4","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"94ceed5b2ed19fdeab1a1e2e0b29dab0c7229637","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.1.11-alpha-20230202120635-b6521c4.tgz","fileCount":7,"integrity":"sha512-4RBV39wwD7Sv1ythyo0IiW+RF7MRZxjkkfq7HibKYf5tow9K9lzJGi7eq4ns/YydJOXtjz1EBfDV/ZmvE9R72A==","signatures":[{"sig":"MEYCIQClllNmFe5w/7MDZRjBAIfwURbMy7nnH3+wDREZG7+UvgIhAP0+0gqNf+5N75Vs3J8Qx3IMpaiTpuJsKfeKsubM/qCS","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18802,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj26dcACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpS+xAAhcAP8ZZdJO2isL2PhuOGGKg8YWSSu+c0e+g5+QdOIu3VnoUn\r\nJNq2jbfQUSfD2lhHBAUEb49nXB41/O7uox3aauR6Q6zvGaZyWYYQvuk4qAHi\r\nWpZbi9tz2na7inAp680J/dMZgO7Rn+EF+Ha455851v8ASM5bV3CSnpMOWCwa\r\n+E3iiEUtsKOnp1KB414gOm0J+ShZtxssfatteT+06Z+VrUOMiFv8RPchjkg5\r\n74LeiprEzTX1FKIjFQpamgNm6skJZg6jD6rw9gdPtIkCTSH3c+G+akFpWCCZ\r\n6xOJvE2VrJAAqZb6S/0oeU5DzV7FkRmbUdIcIOPf3ui5gP+q+HW5mcL1Yorw\r\nBkk7UH5QCRaZ49DIqO6EF/03RnBKqCSPwiTPSR8G3kvvExWylpd9P0KYL8Ay\r\n7OQdcKXOabvqThgbM50zPZUwvwIEMtIu1KbNPQOOKij07/iB4ay/jUT0Ncoz\r\nL6vNWfOErMFpJv6kN4mwP+eYCJKNrxUAONo/ylK04mvSxMY4xJzkA3k0DkZm\r\nl2pLfh76fTmOUzZx7GBk7FzvNApmaJelJtYB4aR+PN6Tn6p8uNSLDdUnSZK4\r\nca4CuxjDg/J2GeZ6qilO3Z1KpEpJhXWk2vWdk4xVV7c9iihrMyzQJVK1T9Zz\r\nrIQO7/GBKOEGdk5NbA/fGQRciJCyxLyf19Y=\r\n=ZJAH\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => {\n  return new Response(JSON.stringify(users), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"b6521c4f996a10d1350ddaeb8eaf2f76ea4c1277","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.3","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.13.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.6-alpha-20230202120635-b6521c4","@whatwg-node/server":"0.5.12-alpha-20230202120635-b6521c4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.1.11-alpha-20230202120635-b6521c4_1675339612804_0.889839045013872","host":"s3://npm-registry-packages"}},"0.1.11-alpha-20230202121242-e83ff5f":{"name":"@whatwg-node/router","version":"0.1.11-alpha-20230202121242-e83ff5f","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.1.11-alpha-20230202121242-e83ff5f","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"a7f1b53d5b91069babad31bbba7e9a4e1a786f53","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.1.11-alpha-20230202121242-e83ff5f.tgz","fileCount":7,"integrity":"sha512-AjSoNmezQo3JbTSNKosGO7rQuuX/tY0PZI/l9mvtPbQgr86azJ1e8o1BsYqiUfLi+5QKf6HO6lxJ5nJ+VkgijA==","signatures":[{"sig":"MEQCIBnpKmCoFNKs16pu5Ov/TW8lEmDoujEf8+DD9oWlYxNiAiA+8G74Vg2B35YukSoYFFOjhy3E0OTbVZryyoIkur4XfA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18802,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj26jJACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqWPxAAlq9Ch9J3DeKDPstXp0B4FccdmGmcvEqr3Fq2iy/ai6MRDJPU\r\n/oMU+BixbyfTQNX9D1L6++qqEIlygNtJjJ/Ji3KFPQCKxraov70KaOhrT3TJ\r\ndjlbfQTRye6FQiXH94uoWeCck6u6ftHojggLjiHoFcTJ6OKrvhIYRrkoGN+Y\r\n/0HXu2G8TKZdwfBTJF3Yl6IjkgBVLCtG+vZcBt/4vNFIknzZidzttqkqeLa1\r\nXWMdYfzKan3gi7FQZ6aDKtVifChDbofTU3JVbKhgUDfT9sDPSyCAJEvHSsmm\r\nRPUEGyvu6GUtYwSgQIzLvzywvFQRaEsT+R7ImPXnYTqzHV7kRU+z9TGGESgY\r\nnem48Mzq4hlZSKn7Psgwnh9VDqSV/6nwG3fhQvCUIkEfPJ4M47mNOSIxZxrI\r\nW8BKdxIR7bq5XCuqHqGqt9bP/xotv/gv5luKOfaUB89Q6O+cZEdE0V11w46v\r\n65gJ1NBtSgL/2jGbsMGKvzANmsbtINPPQJnA+jLOi/GDd4PSEOEih45n+dgF\r\n6pNNPhaMn0r0on00zZqm+SONexY5ZPOUqk1UBxV8HH6TXsRhvRZ9jZVy60MH\r\ndG71XLxwXlb1Cq5TTVhKr+48qwTBr9rRRr0kQiW50UZHNzTUlisIp+4Fa4n+\r\n6oZF3jl/dmg5xu0gY1Y6rfo9B9jQqZEb9wo=\r\n=wHqH\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => {\n  return new Response(JSON.stringify(users), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"e83ff5f571933b8e6c4dd43afd6766e74d92bd49","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.3","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.13.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.6-alpha-20230202121242-e83ff5f","@whatwg-node/server":"0.5.12-alpha-20230202121242-e83ff5f"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.1.11-alpha-20230202121242-e83ff5f_1675339977577_0.6073153236163593","host":"s3://npm-registry-packages"}},"0.1.11-alpha-20230202123533-cd68953":{"name":"@whatwg-node/router","version":"0.1.11-alpha-20230202123533-cd68953","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.1.11-alpha-20230202123533-cd68953","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"9a22bea54a19307c1fa6ef7a598a8e3527d9558b","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.1.11-alpha-20230202123533-cd68953.tgz","fileCount":7,"integrity":"sha512-dNdQWn7qI5YZs4Dus4RJp4zvW6c5/yTOXYd0smAxpWL4fYZf+EQzJPt5IjJvSyNktuMUa5pFMSZtNmfsAV4L6w==","signatures":[{"sig":"MEUCICmliFUOdlxfX3JCuYoDWxBKPzhaHUbsaz4VoT1+FoICAiEAiqF8F4v0mi/t1pCpqc/YVvMGOAOmzuJUuNahQwdd5oM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18802,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj264mACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmotkBAAi0ozEUvcd1KDFDiJ+2FPmigSCB5wAjiD0xJP+rjotDn3hu0i\r\npaWQe7K5aERD98/UAGsQ85prcMQvj9Wq3hkzst7Rb2MjO1C35C8Pu763vajs\r\nu1c14jgh5La8c/R7/vbYZrvgMQXSxjnC/qIQagDsRFv68j69EccCCyK+k/os\r\nMwE+FwqmV+N4e2k0cOW0e/GlynwstBhJQn44rcqzQdMQ4gcPvcn274tg657r\r\nSjheNgtJncijvpD3oG/gEs/UwiKUyATLx31XCqr9CrARYK2ge+ToZ/vOJjXR\r\nwWkEyNrshhyYuu0Xs8so9TS2dxxITv9JaRBUvWH4CeGgATDCqdXCNhQOyYKh\r\nk5zbOR7151HgPrNltWFeNtTZ61Nc5U1oLAC9gmR3I166b10JyGJCrUQmp8r9\r\n3Pqcn2V5AuWxXMAEMNMo12OZQjVdloXr3J1n3HdPlx8VJfx+pF35CYnpW5Ky\r\npIovS4UrWcFAzEHUQKJrlvWyzUwL8mDBqe7rts18ApVM3jdNGGj0ruqZWLa4\r\n4KAvunCrKhOFvgjg8x+dXX4cmUNsVWMgHb6GmeuJnZn1H1VFAG3IK4lFWuZ6\r\nWPBlSBJRI8NrDkfxGsmk/gyVWIX+mdHiQv0ANBoMvMWdfpynqRKCozpPC/Wo\r\nSMCnzVw4FWL+oy8bQ15nDYhJA+/EdfIct7s=\r\n=UfNX\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => {\n  return new Response(JSON.stringify(users), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"cd6895387f865cd9e24c412d6ef3d622a4a1cf90","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.3","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.13.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.6-alpha-20230202123533-cd68953","@whatwg-node/server":"0.5.12-alpha-20230202123533-cd68953"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.1.11-alpha-20230202123533-cd68953_1675341350195_0.33987809592908014","host":"s3://npm-registry-packages"}},"0.1.11-alpha-20230202123956-d8daaf7":{"name":"@whatwg-node/router","version":"0.1.11-alpha-20230202123956-d8daaf7","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.1.11-alpha-20230202123956-d8daaf7","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"2a93bfb828d1c48f6154cd84c752cbcf991ae8b6","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.1.11-alpha-20230202123956-d8daaf7.tgz","fileCount":7,"integrity":"sha512-rKfmPsf5c3D15xDOkngCjXVwOUst/VdijnHNxrRuDW29gJVlkjXRzBNs8wa0qDvbscT+x7V4nbp4CCz7DHjd3w==","signatures":[{"sig":"MEUCIQDzzw1GRLsDWcn6n818pwtwJAWWseWTJMKRyZAfFVEn+gIgYymO9S10u5X9lSdWv4dGDBBa6iM76sCYNp6JvoFjOUU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18802,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj268rACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpVZA//dKjlZmHnvHZzsmrQsNPbnyts+mzt+N98Tamac86faPX3SKBs\r\n9OnS4i+3v10pjOZKprFuc8IXTSD1Nxtzg/HL2GHMVa9wBTFSSFAl2/VhKKJN\r\nu7O6II/pQDL7bPxA//9LFjsdb4oitDpRtZRaafAql84y/CuAFNneVwhTEm7G\r\nkuTEMbsOpysNhxHYbi139KfTaGFCoHcXrhiZtZu8iBHPTYtaqVTOtCTudyyi\r\nnO8Nr0mm+y9jQYpix+velgrEc7QMvGbuhZmR95j82sbBi4ekBTC/mkdKelQZ\r\ntt0syLgjeHhIq5u3Iyua5MNMCcjM60OfFE5TElw9oycYH5WJVfHXjfHtcH1J\r\nAoVf9W3AQQ68tzH0sdL/69rmjSapsfPPl3gGmWZIeCfq4TBMHgBEe0JQ76Tm\r\nymCidSgow8tvoZ2YxJgYyVlGCtnFNKDipb3VX9EvJu4b5MulIVwpbAERjxOA\r\nXKeLbrIfbihZF3vsg/EVAzomNz71ZQk1i2FZZ1UwrLm5C4BxkIA9sw3q5oSS\r\nUKWLYoHFofSyNDH908oaDXckG5ry2KL+L1AT6TaLSGkC7hhmYIfMWK95SYBd\r\nMP11QEy6ga/i5FpoiQJQbvZs38jUsN3v53A+ziv3hHBTQwcGGVdG4Cmjcoe7\r\n8dC7dbyH9tIJN/iMUSKHxRHySkMOU3pUhIk=\r\n=oBr7\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => {\n  return new Response(JSON.stringify(users), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"d8daaf71cb2d405dfaac2adc229ff26c0cc4fa45","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.3","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.13.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.6-alpha-20230202123956-d8daaf7","@whatwg-node/server":"0.5.12-alpha-20230202123956-d8daaf7"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.1.11-alpha-20230202123956-d8daaf7_1675341610930_0.7942670840725921","host":"s3://npm-registry-packages"}},"0.1.11-alpha-20230202125441-e9e7afb":{"name":"@whatwg-node/router","version":"0.1.11-alpha-20230202125441-e9e7afb","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.1.11-alpha-20230202125441-e9e7afb","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"4c59c394c56389732685eef9ad0664c2b3ba9bcf","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.1.11-alpha-20230202125441-e9e7afb.tgz","fileCount":7,"integrity":"sha512-5i0NwoLTCxzeVEWBW2Po9BlwyzHD8J7z93R5s4j8A54VGu6SBD2Ilu7+/O22IlLHeoHc0AmBuuBGxgDExjdpGA==","signatures":[{"sig":"MEYCIQCbmAjmavHwTM/yK0lv2TXC5fkDk75U6zbEgKiZHnXO+gIhAK9H93odkshZs16kSqqDZSn2nVntite28PVljL8yPzEd","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18802,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj27KfACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmqa/BAAomGsPkdlP8FCEHpN4mtayQUYDijpJxUWl8u6hWjKIoKZvVzU\r\ncOGADpmDD1FW9A3WOJS3XVcMsJcfXpEBfuy67xm1CGqbbaIDefIkc+xFwrrH\r\nFht47k+W6cdVq3EppXtsrgYW63uGB0STSyrzQ+KwOir35d+4Nl3pCfDJk+8G\r\nbmZr/wUAB7i/ycDcgPsW9x8KWmnZ0P0q1b6bLqH2OgHqqj+Nd5r5ijxDpGlv\r\nj7OzgRYD/2LHj6JFmymZCp/5cv+1IpgOtPzXYVqMP2VlFs5KE4YVTdI3/MpW\r\nnCt/4eR6l4d2MK5XciuzDkl48u9WvIrnx6ETO4JCtOTmG+NEhZ2e/QdCAcW1\r\nOHboIfiJD285tssWrCzbuX+GVIFOpunmUhAGK1KaVYsPs7berlkup2paCjok\r\nG2yzDj+t+mbz3iqmkiZbuEuvIshQtENAXYo7aNAAzG/5M4lpz5td07w/TQGw\r\n/rv7vD0gYXD+J99ZA1x32HH5MQpvqxfsemyqy533/nMeVATGP1M6C2IMTDaM\r\nAd6oA703VOo6YsfIZ8BUCp2zitJ1T4VaIWePcLhqQS2cAgfcvnJoazTtRRXE\r\n+5Qaatp9San/aBUGdxgbMU4fLLR2x6vkjWlX0OgORzIPnNeISUw0dhdS4TXX\r\n3VBokX5uPseYGjgY6cssieNgNUjNMo7xTLM=\r\n=tfHT\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => {\n  return new Response(JSON.stringify(users), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"e9e7afbb0e10bd67d10598a4d1e3c93703c72763","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.3","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.13.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.6-alpha-20230202125441-e9e7afb","@whatwg-node/server":"0.5.12-alpha-20230202125441-e9e7afb"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.1.11-alpha-20230202125441-e9e7afb_1675342495362_0.3330913620371041","host":"s3://npm-registry-packages"}},"0.1.11-alpha-20230202125732-7b89867":{"name":"@whatwg-node/router","version":"0.1.11-alpha-20230202125732-7b89867","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.1.11-alpha-20230202125732-7b89867","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"3a92a58745e62aec7e18061688a420faad2d4f2a","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.1.11-alpha-20230202125732-7b89867.tgz","fileCount":7,"integrity":"sha512-g3hGvdqFVY+e3o4bOTKFhN1m8eIchsDjRYQ5ObvYkTjTwHNeUOG2bCntPPUPBf+dIFUrtnWH0mCCRnYUIfptiA==","signatures":[{"sig":"MEQCIAXnh9VwK+C8sBEO/O2wKnP6bk/PedDSI40nutapT2hGAiAjT/1xq58ydZ8LW5Wt5j1vT28vBMuL2xR3g8qiOk1S0w==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18802,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj27NKACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqUfg/8C+RnlZLKq+0mM9H07LgNe/lP+cmcrdTRO1Ghlvek3T/U12K5\r\nSSq5FRyUxfQKEFv9qzhRdqiNBKJDOzF37O3IUwzxFxXfnlMkC2Z+fAnFWuWY\r\nazVa8Sv7fkyOO4ORDvM9F69IIPsFVlRTv2iNUHoDZKXOVjFdwxOECzgWsl95\r\nRh3/eIJ+pa7Nh8NCLwx7boKvNLdo5h8J3mDx7fgfu5As++oP9KWxlxr/qPz1\r\nssYy2+fJ5ymjt+tM0tSJw2TJvoOrrzPDEBtUZYSahdwXuR7v3InqgGXx6bfX\r\n6IhRsgQinw4x13vP7gPyyXUEQ8UlmJ4fSkEqQxuvuVrk6pUeuB+R8cmeKL6/\r\nZngBfaIetsM//kHsvgcUjzZOcFkVGk6/5CwbLgu8P+TQ8Mx8ZCK56dNozOUO\r\nfxmcr9gdiFmUEoPzKTwk9TsuWYkE4JMIwDtbMMuEUtG2nrDS1dTeBkF7Q79l\r\nLtH4AQ5yLSANlyHLla/xSmq1EJMMoPtgccYabQqeZ2ZeWZNLJJ89rwzSVPHh\r\nI/md7JgCHKtm1ohB69QzwhwRgr3youMmLEZRb9wzZ4CBWL4dId/OKptExphi\r\nqQ8p/YTHsd4dlqAXpQmclJrVS4MxA4boEtKRMXOMdtkPhikw7GZbcw83vvH0\r\nX0koxAfVDA/HCqezyK9ztuFChkLK00ctu9U=\r\n=R8Na\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => {\n  return new Response(JSON.stringify(users), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"7b898672d5f967e581a2a48641769135f00d540a","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.3","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.13.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.6-alpha-20230202125732-7b89867","@whatwg-node/server":"0.5.12-alpha-20230202125732-7b89867"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.1.11-alpha-20230202125732-7b89867_1675342666675_0.36201410401281087","host":"s3://npm-registry-packages"}},"0.1.11-alpha-20230202184428-e0c4cca":{"name":"@whatwg-node/router","version":"0.1.11-alpha-20230202184428-e0c4cca","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.1.11-alpha-20230202184428-e0c4cca","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"ea98dea36ebb99631475ceb0f7942d122f53c7c0","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.1.11-alpha-20230202184428-e0c4cca.tgz","fileCount":7,"integrity":"sha512-v0R22LGW+Qk7i9Zb8NWa2Whw4bM9U+TsXiLMFlqdcokz6Oz9ZgBE9ZxqLNvc+l5Jpdp0o1q9aAGKhg3nmdnQNw==","signatures":[{"sig":"MEUCIGuOvMuY99YC3KV7yX72MO8KumazirTJLi1Q8FHlgmn+AiEAk31+n39/g2QoImIXdAHGy00f0OxXg4GhMGYNN+yZTlo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18802,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj3ASfACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpW9A//dl+trSNbH7WjY+rpgmgZ5uSwRMIbgKSKPLA5dka9I5qNrUWT\r\n1cZegMvL82AyOdgtxxTz9fau1WW4xA+MXE73Us8bflrBJYmwL2kjrLrtA1mq\r\n6RJrR7w26vXukQcgvvBIzv37DK1uaZ5nv/HNTFgaLTKSPekay9qFkvvQJgFF\r\nF9cb4z2rSpd62IaOFxCDwy2fbvvggbLVjDv/8JKMnQc+TPN3K3cnypabiTIj\r\n9Q2UtBmNqhU2uIQIFimny8X+gHF6Hrq9IXy26VH6fvcXKgtdYxSvXMCgyoj8\r\nmE8dQF+YOsF/Y6kjOJIGpVSjpr4fuIfOR9nI5vqmpolmOWST1DQkIwzL9hi6\r\nTwAaIPEpncxdg61tRUPbYZimR2YDUCU+CwuyNHHqHmBAVrFmVXfZBIvPysl0\r\ncZ2Fq5w4LBAEejdThVM9ohLuWJff7J+idCGoIks0VMze+qN7A9EUxnHwIuwI\r\nd8up7Mg5Qn9TuyB0tCXu/YRdF9qhGsXfFn0gCinUPju8Jxlt/ErqNU3YSlVn\r\nYiaSFrg8GPHy21BFZt4Ev92bGG4m0RuR1CaO8CG/KukSEotpR7Sa97KH+i1+\r\nNvGhrgLmGFon09BjGJJAciKm5H4ResQKduT5kfnQJRx2q7ix0ZJpbqTfxnLU\r\naifQHLaNSuDv7S4JChTaxLnnZLEmz6OvlWw=\r\n=6+29\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => {\n  return new Response(JSON.stringify(users), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"e0c4ccabc29b206cd31e11b6af16998860009872","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.3","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.13.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.6-alpha-20230202184428-e0c4cca","@whatwg-node/server":"0.5.12-alpha-20230202184428-e0c4cca"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.1.11-alpha-20230202184428-e0c4cca_1675363487784_0.9056779464413234","host":"s3://npm-registry-packages"}},"0.1.11-alpha-20230202184911-724f9bd":{"name":"@whatwg-node/router","version":"0.1.11-alpha-20230202184911-724f9bd","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.1.11-alpha-20230202184911-724f9bd","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"e01e5c86e28ef71a760b49b96967ae4957186357","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.1.11-alpha-20230202184911-724f9bd.tgz","fileCount":7,"integrity":"sha512-4VUWndHC8K8OwWTiGwKInnCsvynOfVlchayFat9sxOQhMCwQuXMzxpyU+uyne+w2TP5sDUDSM96l8Qb5qFOMBw==","signatures":[{"sig":"MEUCIE4ftznqN9orU+0LoVwk/tsOGiHWF7ZTPB8rIVUTg8j/AiEAlwLflF7kH9P27QYRYd4jDuMCp/Pc5YaGWa5bedpBurA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18802,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj3AW7ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmowcQ/6AmbrC7IsP98HHUufY61kxIJ5hVDVLpbMuOws0AH5vsADZ4UC\r\nBtBAu2lfabw7J93pca2cQeQbkC7x8dx6gmzFzNAKnM/ue0gcrNCTG8+zz+2N\r\nCMGOfUJdGjYv6xZASTAzg28K8f5m3QfJgGhjtEzwJnsu8H/6etFkxpBwTLj4\r\nmUfIF+80wHU7d2Pcg9NY4NQN2EfGv/7WVW4BKKhgxu+l4YN1v+hP9/5POSGU\r\nfETOszjo1pBTUoQ6T7MXwCoiSSOpRHunds3MtwC8wUvyWrLsSVk/5MuPXMeQ\r\nKVgBhBUJqBYDPr7SMj6tSn6rqzm166qGGW6Z3RdVgRvtatUAQL/KOZMZKWml\r\nYZNUyrLkeUkUHquJIZ11x5HuI5dv/5zxh8QA/uOzC97lPwfg7PEceBBYwBPC\r\nubCaa1KNaXiaRr7ZQHMpX3SX9pA9/h4vnFxa1WBF0eqnDmQNZdYIHSQOXlp7\r\n7uMSChGu6b99c2OzN9+GdCmQ4jpkH1VEJ9ObuElss37nRFRLH9CyDIOMi4O7\r\nLfxebHEoN4gtr15wJN1JSJolaopMZRFpeNwz8W3VnRBEhxUvMsrpFCngRc4Q\r\nFq9RHxCtsTs8pHSsjEcsQ/mSV+1yOAfkiuP1pH3kTTP1tJLUMlGR3wpfqIa7\r\nfIUenZfhhup7s2Ka/DPYoukKowTgFl0nUmw=\r\n=W6nN\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => {\n  return new Response(JSON.stringify(users), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"724f9bda85236e1440834aa8a79155019e5d6265","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.3","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.13.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.6-alpha-20230202184911-724f9bd","@whatwg-node/server":"0.5.12-alpha-20230202184911-724f9bd"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.1.11-alpha-20230202184911-724f9bd_1675363771233_0.801920084393354","host":"s3://npm-registry-packages"}},"0.1.11-alpha-20230202185216-2aa5539":{"name":"@whatwg-node/router","version":"0.1.11-alpha-20230202185216-2aa5539","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.1.11-alpha-20230202185216-2aa5539","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"6ddaae037a0387294c70b9fba990601c06e4f540","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.1.11-alpha-20230202185216-2aa5539.tgz","fileCount":7,"integrity":"sha512-bV36iTLdnnPBlMvYI61pFkATt4NVOQISj8zZOZA7n7XMdMcjTWxayWGOaoj8SvJ5BXBBE4FWNofj9q0UvAoLaw==","signatures":[{"sig":"MEQCIHk1LGuiXaznOB0vfv+ReTF86eSWreykhV7WHo5bvaNzAiBhYvW5vHjsAQivzH5W5FyqzDH/lMzE0BAUBl8gLZARhA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18802,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj3AZyACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmp3DxAAmMhupwhX5WyXw/+H60pucEMzlKkwC/si17XQsZr/LP2YVFpE\r\ncnCw8SRwGogIHqVU+5uOC9oc/08FWMVChf0NVO9+bafdzIZ0o5dN3G3rqq9M\r\nl1EoFvy1DMXMvFWBm48qh29YM/ptUJ1qwfwWDKN0iFJNPnjWAKZnI3IsKjcg\r\nVQJZf27oTmBqS2N2mHWLkBvWiy5PRF3DBRSypiivTKluMV+Q7yt+B70sK8si\r\nu+PTXMBCl85D4HHvr/mb3gZvGkyyvzShfpyV/jIFbZqFM2VGHLH3X9MTO570\r\n8UPTVE/NmGAAqJh+nSni4bgcUxhDtrVpFbzWrRwTiRJup9aX683N81rbw6x4\r\n2xzjsMcLBbDYHM1C+ZduNjfEDK+dMsLkjBaV4TtwB/HjBhnsR2PaC0PElnh0\r\nv1ADgVCq454gpCtbBiFcNgavoVCdCMLrn2DYuPeXQGDkiQ9bkl6c3yR/l9sK\r\nkhUsCzlQPMYQSstI4oK/JBERF/jbmHIBqDw4BWGnPcH7G0vVmeI+UaeCn8zV\r\nKTPa4/FwWmhVMzZ6HkPcOWz9iMWqWeiNORfdQihK1RZ++XXN+Vnj65RRzV0+\r\ncoApbwDv+1umeV9j2/Ic4GReID1PZ5hWIEYilNi4PpnplFO6WFv1VyMqd82N\r\nSlWDLSqCCuyevzgOx+wwDPhH9GUJoVm7J/4=\r\n=M4SN\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => {\n  return new Response(JSON.stringify(users), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"2aa55395781632966ef5c76217e7ad8ef00e6f8e","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.3","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.13.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.6-alpha-20230202185216-2aa5539","@whatwg-node/server":"0.5.12-alpha-20230202185216-2aa5539"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.1.11-alpha-20230202185216-2aa5539_1675363954703_0.5793904810817461","host":"s3://npm-registry-packages"}},"0.1.11-alpha-20230202185231-82dd436":{"name":"@whatwg-node/router","version":"0.1.11-alpha-20230202185231-82dd436","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.1.11-alpha-20230202185231-82dd436","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"e944d56117b6038fd130073adba10f3f4f202b78","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.1.11-alpha-20230202185231-82dd436.tgz","fileCount":7,"integrity":"sha512-MLeoTRuzzIHtcQJ/UnW/CYCU6LGfCY7RnElDKO7GCD686Z0CgC3abQ2qJz/w//c/WGh0YgYgzQl54MRvn+NoUQ==","signatures":[{"sig":"MEUCICiAFmzNRvTLochGNlwAaKjfgnX612rRyr4q/yG9Xe8KAiEAscVBbFL+jUNWfStk7hWrOQAgGPpxExT6wsQFhex77XY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18802,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj3AZ9ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrArhAAiwpTQgJipZLzovMk0jWmhx2eoaiEIQ5zXr8prNa4M3cCiC5Q\r\nBqfUb1iffd4EBMSc/W5Pqb4ZQjUHwAkhmd//ygI/gKNzvVsJ5dTXlPPb3lED\r\nG7O+ONvEkhAJslmXdT9HEE2DTjxR07YivH9ddHJVNEoCGwacmVC+rlH1mzgY\r\n4L5SKI5Asw4PM3eINnezHgYTaW8VQle1orJwo7cVS597i+zAzJGyizS6B6wF\r\nEh4O14a2S5ErW8Fl6bEtrDhe9a8dydSxoHFWA+WCv2FpYx2nvgbO8PGogFw9\r\nrIRZeEcTwb5eQSOuYfTF8Bj7PbaENSFWTIC5kLFjQR0vGAZdLro5Y2NxqQt/\r\njzzl/s/V/8mO+jTK4I1mx/eaNcMkQHs3i6O2OE6NNuFBa9pnRcvCBDJrHfWS\r\nj+92ItSrGJf1JXUBGLtZR4gJYBkg20ZZ/jsx6Ma7msSzEXqBnXISTvh8Orc7\r\nKrMaZ2FCYcYQsZNBE3qcXDeVhSOdy8wVmpq/wHZhY6VS+6oDlZn4hW9YiZ5h\r\nXcntNdin4tOmuu6zVRd6UWWWK/bTYZKPLmDTAgEvxQX6pY0Mb6z5Xu4m32bf\r\nToANHcyXfEh+cbpf6UhZ2w4Jlldf2gpQM+tlRSMuG/Raj1odNZtvx5P6OTKm\r\n9bkpA2er72aREjTVycZpon/NuL/OzI1MkhM=\r\n=tjU7\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => {\n  return new Response(JSON.stringify(users), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"82dd436cafb06e55c4947e5ba6611d5672b13873","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.3","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.13.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.6-alpha-20230202185231-82dd436","@whatwg-node/server":"0.5.12-alpha-20230202185231-82dd436"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.1.11-alpha-20230202185231-82dd436_1675363965047_0.5341337667437991","host":"s3://npm-registry-packages"}},"0.1.11-alpha-20230202185611-a55ab16":{"name":"@whatwg-node/router","version":"0.1.11-alpha-20230202185611-a55ab16","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.1.11-alpha-20230202185611-a55ab16","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"afb0131528c0d36312632c4d63b5a8de51e2036c","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.1.11-alpha-20230202185611-a55ab16.tgz","fileCount":7,"integrity":"sha512-MLBru1swkMsPVsNEaowoxD7tgO/v+RLd4b9BaPjdhqwV+vIW36nu7toTlx3fQa6NwaDOnpRwq1QoKOWVP/ut5Q==","signatures":[{"sig":"MEYCIQCKcHzlirzFEAM2wO46+wxct11D5+PBtzZb4mL7Es2AcQIhAOHF0f4U5BeOh22iALb0r2bzA0euOd93HaVM5PD71Qbt","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18802,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj3AdbACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpPLQ//ccHRYKWa8p8Q8VEDxdQF9nXqCldJuo0xlqUN362IotMzVYFZ\r\nP4sBm7Uu2qBzzDAe2UY7kSuQfLFaF8eal4XgqT1Te2RpWEgdn26r+fpzzFr2\r\nWzmzk82g9RyiX455aRbBTiOqkl1DSKXwkxkSlHDi7YFrJtumo7o2PUc/jDlf\r\nI9W7RwyhQdidmNIGHVHL4eDsFu3QYRe4lfRhTOo7MirZn7dnn6A7Rr7Bknq7\r\n/rqq2fjItiPG6SrJivQS/Sn0d0YpmwuPzpX5xLy1cHHLU7E0dbXnKTM3Gn6m\r\nQksZmREXcluOSlZQlDGHaSA89bIhLl8WVjv3kn/n4uBJud4GgdaA3CeivXMI\r\nvJM+wdPgFRNOa/jZsv1xmvgQW0s856ySZaMal0B66e/VRzrI8iqedYutEgPx\r\nq+sJSqYBPyZ7dRE1UAkMiqMyJRJ04zI9dejzTTdA6zlmbphCNtfbAzRuoMxe\r\nENjbSZJEsDrN29a2BTfFsAJLUjCqpWKpIQAfE0HCYdXyV/T5L9SM3uCuR/T2\r\nHHQhQdXpE7jKzeHBayGxuWIxX7raTSNvcTpjVvtp6+vonFcfwnjb9I3E2/2i\r\n4Xuah5p/j/lgQjRTP1oyIl5eDLwH5YsF+Hq29690DdZ8eukkv7wtH7bj7MgM\r\nRhX3iO6XiN6XumXkFsAYTZuYawJ6fb3ruYk=\r\n=8aS5\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => {\n  return new Response(JSON.stringify(users), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"a55ab164fd761caa88e028090b7c32b9cab67aa7","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.3","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.13.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.6-alpha-20230202185611-a55ab16","@whatwg-node/server":"0.5.12-alpha-20230202185611-a55ab16"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.1.11-alpha-20230202185611-a55ab16_1675364187086_0.909565681694982","host":"s3://npm-registry-packages"}},"0.1.11-alpha-20230202192735-c9da64f":{"name":"@whatwg-node/router","version":"0.1.11-alpha-20230202192735-c9da64f","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.1.11-alpha-20230202192735-c9da64f","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"103cd57220696c7343647d177b1475f5ac673dd9","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.1.11-alpha-20230202192735-c9da64f.tgz","fileCount":7,"integrity":"sha512-VAyCJbf2S142uf2oq07fpE/s6Wib9rtTg0POaatNevdfWSsLNoDp8bLWXIozyVxIqiJRdqt6MKFAmDvt1UJZ7Q==","signatures":[{"sig":"MEUCIDztr4iogtZZx23Z8Xdnqa26MZ15R6fvQm61lUmelFTeAiEAh4jqNSKZpxyJ0TkeSybfSYziOTfPSelaQXjYir7G/mI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18802,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj3A62ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmqu2w//UX84OVDV6sjBPv0gtJHFn4X3kcbABXJBTXxOjnuHn/oBOtlk\r\nWKJQ/BZc8dsKWPRxGVsNj9oAFqr3/bwGHU14IX05QdPmwf2/J1xQw0ik7YJa\r\nCHrer5E1H1lLL/8mQJCWU91e+ofrEfZ415pOEey7UIC12vemiN6ehRwzATqZ\r\n7CTbQyP35ImjxZbC9APF6RKZTL+3vrPrITAe+yuOE1Be2dcPA8xT+uZRkHBV\r\nrOl8RK5zYawCPuiuvqdHKXlM6D4ch0JHio5/uQnxuZtWRMjLNhexmQ18ZGGk\r\nbAAKUDEAjxbJozxUESyLdJ1R+7Yl6YRVs39UFeLgpqlU+ZSGuoOhoQa7GIyi\r\nuy3tDpoOD5TrQnq1GeMP6RiBrJx6KuGfMV274B/CSZPMdpOFqDCXrS5BjLzT\r\nuhd6MQc9RJqy4ap1JAADqnsEsxAquV6auLv9WFTgF9MqochnJb+weQpCuPbV\r\nD00yy5/xVgv+WIH+ntv/LZ+ehfirnG/KPrS7bpz/MNq4HtNmW4Wvd5YMr1Et\r\n01mHwyPWOOQsUpMqFfEKJSIhJ1k5Vzxl964FZMwfZNHgSJPo82NLOg7N90gS\r\nS9uL7BGM11m+BNTtKuBtvVSqBu10YDS0WDbUTPde4euC8OF+m6MYrZv6jFro\r\n4qVgDgJ3oTN7BPQNhSFCav06vRJyktX8DMY=\r\n=sZdY\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => {\n  return new Response(JSON.stringify(users), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"c9da64ffc269eccdc3428e3a833d78bf6e5459f3","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.3","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.13.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.6-alpha-20230202192735-c9da64f","@whatwg-node/server":"0.5.12-alpha-20230202192735-c9da64f"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.1.11-alpha-20230202192735-c9da64f_1675366070635_0.4369283292166717","host":"s3://npm-registry-packages"}},"0.2.0":{"name":"@whatwg-node/router","version":"0.2.0","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.2.0","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"5bad8ba5161371bedcc1238cd24e1cb8462ae26b","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.2.0.tgz","fileCount":7,"integrity":"sha512-AFq0Km3vvNDwJz2AUOmjW6OAUHAEBGFRIQ597Nkoa6QXtpwZ5MSePMbnCNw/hWncgh9zzSY2AznrUnoYarVUfg==","signatures":[{"sig":"MEYCIQC/Qk4tYfymZgYBzdE2eBhC5bH3/ys8ETN322Yt0oW4jAIhAI2Gl0nuWkHAq8dMSxFyjFhUT8zdv+SdUTqbaywXzw+B","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18688,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj3PGuACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmo6VxAAhcKJlToSLDXDtciutXzFAvym0zurgH/Pybu+EA2FQj8WFrK7\r\n4Z+m+bqQp9gfje17Jo2Ex376f3R6ctO8/OrzUQmbPK3MnH1s+sDaBCEajiIR\r\nGSvPXyWasbwcAexpeo2XXcrmzifFcATSQlJ72/vBXlJIt9hDmVZfftkQqeO5\r\nGVH+Xc/Ciy8v998Pb/+U1JZBd+MJyLTLwfIA7zfnJfDqL8jS3N1ruWoed3hZ\r\nBvxB3QgFUdEZPBo4REyksOOwIaOLzofKESLgxUehJh4WwaH19JRPImG0K7/y\r\nwTT10blrBFOSIrBZIyn+w878sHCTo8QUiGLF7W6tGAP5SIPzpd7TS4AHHLCG\r\noXxoOJit7WoKszEFN86y91NkSpoDUf++1RQmkvKGSVwbO/ZJi+uBpuNVfjI2\r\nzEz7raw+7AnUH/yijP4BXOfgXAlJv2xj46d8fMMIa1KyLYL0ZOK9MdpGC9K7\r\nLZzXtZqkCmCOKNXymXG2UND/jnBikObnYG6/hvJlsY//cuebtx/W9j9v6s29\r\nIUvpqDtHFUT4L/lAP/IMzBYhYkNEOZxKr8u7sIadHucMJtDDvRz3DQL9nUR7\r\nyj3GijbzJcdpiBtbFKtAx7SRhUGVm4S/Le4wtf8Us1bJ+mlp33kR3P5gj5ia\r\nEcH5KBTkU0b3djPeSWdKyNaTYJkCUZstGnE=\r\n=rDno\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"dc30f08a32ecf12d8d04a66394c2158be846fc8f","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.3","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.13.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.6","@whatwg-node/server":"0.6.0"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.2.0_1675424174663_0.5657281634604057","host":"s3://npm-registry-packages"}},"0.2.1":{"name":"@whatwg-node/router","version":"0.2.1","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.2.1","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"7a9abeee6d17a50b40803c32b6e41d328b7341f9","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.2.1.tgz","fileCount":7,"integrity":"sha512-gfDbNzqAkzUGsKg0HgnoBhJ+PGwYkknikIoNJ3QQ+pG/gY9Odg2XvDbg/nv5IKIhd9LCgGJd9z12CctXfIJnLw==","signatures":[{"sig":"MEQCIEAsGjLK8Twr3d09surLUF5QWg0mVyOIxgCAIdngOy4lAiAqA8+g77RnhhaLlWLtqmucWyEb0yybkBJtUCN+1wwiIg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18732,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj3PhbACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrQfg//VE4gEkfQHu8pkj0POthYRbSl3ILvGvNFWoJs889uaXkhCvym\r\n8aqpXIhG5WxvlEDX0TJffiMpI13LM38B5no46dxmyZA4My0+GB/XuDvgzubt\r\ne3cmrodgYjJYlAtMPpj7byV1xKCxPdtrs+haS+PCFshsMeJLVRac3RdZMlE5\r\nNitGK4GHyl+/gejxW65LgR+B41LDkZV/TfyVWFtMzVoE42PECiYqBDv6jhu0\r\nFjax+B6leh/NM+3Qb+m9zidudmQYHAMs48lYurP2MK0Pv4NmEQUpXQSzA6zN\r\nQ/y2TE2mGt9ZUNReLnsGSXzCpink9OeFU03IqRpBxVhI9UBvZA/Q63H9SWUp\r\nIr0cwbL0nanFNebXkTqNDNrgziTJVvwPQiLUP0+qC2Y8E0k1ITMv+RSpmg35\r\nlQ4Oyr6uQY5F4duTBG4vI9BA9Dc4qSKZfpROiH76MvrscIiZQgjOo339s/dG\r\n+NJrp69klPmz7/adEMrYzHRs9F89MTMzRzxzrkuOCCytqcsipiYHui4lEjBx\r\nJUdMDBOG6x6QlTY6OnNYbxdpGpiz074gdeLFyKmpFMYGJ+tvXUQPt2koxWA1\r\nZVmNGoxxh8F0onjfYqie27CMY+S7zR4dJw5lgHBuPpJCHqt/XPxR74yt58uJ\r\nLEnk6rgym9ViXAsYx2rBZZwKaHxVNoSG5RU=\r\n=QECu\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"776cdb87ab7bd1ddf85c4b54431f2b7148958dad","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.3","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.13.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.6","@whatwg-node/server":"0.6.0"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.2.1_1675425883159_0.12781018177541714","host":"s3://npm-registry-packages"}},"0.2.2-alpha-20230203144149-868d6ff":{"name":"@whatwg-node/router","version":"0.2.2-alpha-20230203144149-868d6ff","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.2.2-alpha-20230203144149-868d6ff","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"9b1c42224e62e510c27145eab2a144c3bd5323d7","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.2.2-alpha-20230203144149-868d6ff.tgz","fileCount":7,"integrity":"sha512-1+NvfIxHWSUamI4WL4/vF1uhvrvuY4ZMTRSR9L/a1TFKD5Qw9tVtG3YgklOW34ICEWvgkKAJmbjuIMPuIQ38dg==","signatures":[{"sig":"MEYCIQDyLSAohMKGwWyu+CVeFXYUhGyBuNtCh7iDpBwPbYsL4wIhAOotUT0eDONNpHexSmPx+VhxebqQoNCPvOHiJvgtG49w","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18790,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj3R07ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoI/w//Y/sXf/qcv1S7+XtIvRpRpre8WkE76D9icC88NpXda/dHEoI6\r\nPmvR1P/nTmDtj/pg4S/flodkRtAp3zurjhnMmsKmVlTzTr7LgWWaomgT9ZWF\r\nXosA31v28KsRJd5MnPeBXefgBykO+paV9E47V9lP+JzivrdnPdc4OnRwXsJT\r\nN93e8KzOiD/Z9gmNSFc/fGWcD4ciZ/Fq7IuiUaitY9A5g+H1vsqCkrsLNg+L\r\nF9wlIgmsfsup9asZtUp+Sl7Bk4+pOfHaqNyCp2auqucjQ0alDxG3MAdi6DXT\r\nPnRFoS1k/Jir9JoWouxZNyFbqmGAzVHFGVh74DK+yu8OiO7iadB7prS/smtX\r\nRk384pVpJlTfodKhGh05h0vWotbid3mRa4x3kVAK7SDp3Gw67riaf+ftYsHu\r\nM7hUJd1kel0upS4eod+I3K8Jwo85xiKVgP6T0cRNUcxCorTLdSy0wIz7DrjR\r\nt0QA2MIvNe9eEcsUaiSqVjtKw+2burVqEaNyotwfR6KqYH0I/Q6SfLLrPytU\r\nUQeRT//DciYeIHvxIHFm+k7cjI84/j/6GES6NJgIuTRtCHa6MzSkkxTbNbFc\r\nylQ3cNoj/QHXGUaBJS2bRU9Kx/D9EJWYpwDIqrMC2gARdwkEGxaF0/Qq5fl4\r\nCx/m7mivCQFoWSlNp9UnhUQJtLBZb7Ujn30=\r\n=yICR\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => {\n  return new Response(JSON.stringify(users), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"868d6ff643fa0ce7b1641ca62b4c253d24d8ddd0","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.3","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.13.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.6","@whatwg-node/server":"0.6.1-alpha-20230203144149-868d6ff"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.2.2-alpha-20230203144149-868d6ff_1675435323038_0.43204927508444224","host":"s3://npm-registry-packages"}},"0.2.2":{"name":"@whatwg-node/router","version":"0.2.2","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.2.2","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"880b1743e6d491b584bdce8c7cf447d619bd6c06","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.2.2.tgz","fileCount":7,"integrity":"sha512-3xMshjG0yt1hGKET+8MgWctxCnYxg33TwBEkGmtaKiLsZwvcPQJx+k/p345QLSKy7DbnrKoUYtAMZZjkg+DTWw==","signatures":[{"sig":"MEUCIQDKufmcFOQcWNdjwZ5dEv53iuIVRTwJpfFnvxWfUBEOFAIgKj15mupJwQvqilrxXhiiPan6+w5KEBi6V5hSj1iSeXo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18732,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj3SGcACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmpp9g//b6oVguxU7vicHkUyvsEx/vUtcqGKTI4mjxLYjVosFUvrPHQe\r\nGnSOalJ3ZbOhATSqNlxtDXu/Z4UtFenbUaTJ7EfCGO8b7PYNOPns59qYpsLX\r\nfokZ5P+CqrthF3LhGxkVyaqWVs8gsV/pnDJamUQSjGONFgZEV6EZW6Uhy0rK\r\nGTDPErhZ1Utd+wfqD9Y76wsB48xS4dmVcmSHORs59PAyU1eSif1KOsLFcJ89\r\nnai40cFfCHFbcJ8EP35ecXv/VTfrVwZytVg6XogjIW4uRUrOQjimkNFYf2HP\r\nQM6f8Lj91BKu6wa0XO0P3nbscreqct15OTGeCSsRSwvNX1L+2E95Lf0schHc\r\nqJHEa7YxRRY4ql+5oImruEFFUo9hx8gNLmvfEVs4e/+VrkiOiAy+ehnAyI8q\r\nl5vXvJM+gZcFO1Lp32SeJluD6AnjLvV0YIG/6zrkdbZM0yLcdHL5nM/nyfxk\r\nM2hC5SBvYYQuag8r3KbrN00gSp3CKgQ34foCFFLYZgl4MrlgfYycZ9oeWOcH\r\n4dtvZZTBN6ZYoQo/XIym+1gTV2T++lW7vzVfSVXScGO3NQvEaJ5acTZqlp+v\r\nzzXERb6aGkL/kvvh5Z/NcFOYg5GX86myGRFvHsNGwzkzQgD+EAujq0CaghHM\r\no9+lSjcFWX80E0sLDdkjwu9Q67A6PychpDY=\r\n=DUfA\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"99c484aec6e52ce118999406aa61eb3bc38243cb","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.3","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.13.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.6","@whatwg-node/server":"0.6.1"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.2.2_1675436443864_0.8674063733893209","host":"s3://npm-registry-packages"}},"0.2.3-alpha-20230205160101-d3a1033":{"name":"@whatwg-node/router","version":"0.2.3-alpha-20230205160101-d3a1033","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.2.3-alpha-20230205160101-d3a1033","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"e57f6995346369a9f3c14c027aa72f14cd87e4f3","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.2.3-alpha-20230205160101-d3a1033.tgz","fileCount":7,"integrity":"sha512-6MyxtDEkHXOmBN2yzwCd/wJLbHXiBkL+X+OyWpoaAwnrLdQEsDP8Z9oGoTISoHUAyFWzFqGaS+1igIe4CH8rjQ==","signatures":[{"sig":"MEQCIGx3STtD7sZh7SorOTdJZjfGIL665No8tjJqLXrKLTUEAiBpvZ6CuB5Obavz5iM/+gswBjFSNWQYI6Bs2px3nY6dAg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18819,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj39LLACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrR/RAAgujsg8XKrdXlY9aIeREqc0B6+cXlop60IHdkpN7RqDDojGVa\r\nLiNKbAy01Y1G2J2Q4Ij6wYtsOulsypMBHP0LHpnLT+WYA7UrdBRvrvP1ov7V\r\ncYxyJsUCy9mdmJyAEhJQRBBJspz5qCPuc9imKvj2kWzBybjaUTn7+Z+Z3SQF\r\n1z+2Hu9Ie+deJqviWSBFzIYk+lMs+f5tL7ZVPtcu2jJV8ncmGn2AZi+sUvi6\r\nWMenaQfykEDXtrK0esAAnHoI/hxN9NhqvUv1y1l3VO8sWaRed7S+kjGYCNM4\r\nYJ1AO0H5Hs2uZd3FVlVeKw3tGPLHts9zGCzfk0LTaMc2ncUY2iZCh+jFzjPB\r\nZ2PbCCKM9hPkP14Gja4a6KzLg8OGuyHjDtFiEgrXx6UThkBDifA+jum4r8Zs\r\nnMAsWTcjdHTQ2q0DpXrS3lV5Ps3Cxvkmz0xiXSHcKa655pwEpZv1a7Gq+HG3\r\nvQSeIROQaJF48EYV4LqV1TlOuUuJModDEPKQsChvTC1yVJScV7EunoK5g7oH\r\ny8a8kDJItR12Cy6dFbbkjx+yMvRw4XNap0ee9fZGywc9VCV4HCVRkCiTmOo2\r\nSaP5xNyqz7XNp9wCol5EZ1smmv/cfmliHRj4qNfzh5GrwqbApI0yPLFfVZLg\r\nKT15taHfncO7IvrxT45WsYmaGhtPvD1ALsw=\r\n=x3Q5\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => {\n  return new Response(JSON.stringify(users), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"d3a10336b1b5a4c7f59e47f2ec00004b27431892","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.3","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.13.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.7-alpha-20230205160101-d3a1033","@whatwg-node/server":"0.6.2-alpha-20230205160101-d3a1033"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.2.3-alpha-20230205160101-d3a1033_1675612875431_0.48294136098816054","host":"s3://npm-registry-packages"}},"0.2.3-alpha-20230205160326-cd8fd84":{"name":"@whatwg-node/router","version":"0.2.3-alpha-20230205160326-cd8fd84","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.2.3-alpha-20230205160326-cd8fd84","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"c3cbed488229572e615c99993c9f94fcc529549e","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.2.3-alpha-20230205160326-cd8fd84.tgz","fileCount":7,"integrity":"sha512-F3iriKGkNO5IVZUi8OYYBfJlwW3jYLzK6QFoji1B0O63iocGuq12ABBjalLlm2KIaHj3onY1VpMNHJnCfKM+7A==","signatures":[{"sig":"MEYCIQCBPriit5v+2IdBkrBeRQz6hcXA9tSjXrDj4lCv857MCAIhAINeWiUp43Tol3lzZfyyDfyRBpN5o/JxP/xNY3HOJhme","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18819,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj39NeACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoHSg/+PAq+cMtYkFD5Ep2btSbLF3bIN9a6ChN6DP68wI1tVdORpIyq\r\nW9Nuf3BiCrtIMhwVZbK2WYFmfCsQPuGhHt/IDyLgTV/75TC+Yi8rLlOK8PFY\r\nEXIE89dWClDmBrX6BXqgvCEdc9fYZmh/71b5zG4TYKJ88EV+qAwNox47FHnZ\r\nt6IHT29MtPonO0lm9oK2gR/W2bbr1e0qarnlx4tt5T2rV4iZdswDpF2WGAfA\r\n5WED+XWBy2toF5x7kFhaFRn15T+YGCwir12aJpIrL6mlTRdzIK8eS8/O3jai\r\naW4eGB2fyXJu+4u4CZ2S2/cPSQGedzqHaUWA6nysXILb72YUy90IGp7qWw8/\r\nWBw3EGk3OFpau6rM22aUkWIbUvCUyquQROhs6twyo5EHDROoQGA+k0GhD5tn\r\ngkiDbBwDXOXVQ5l6+fO2ffAJHkEK07HLGNyrDiH+NaTiuocQ5c8e61+jQ/aR\r\n72LYFBY45nky/77uR4va2Ez32HKnZ5e1BbW1dT29gwTe8q6PikQe4R/e0Rp0\r\njb4C/PfO/IQk2vbKWdIXKT7saqGt8WD5vd+bc2uTQwiyBTXp1wAdGmnapEp3\r\nnHo1hdWfQbxGhlgW2WSZJYxVdGsNf44sRZ8TPaNJrLlMUFs1jpEe2tIcGdNC\r\n1KCKL6jtMgxoelzNpUvwyvegrs66okNHbus=\r\n=3JIb\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => {\n  return new Response(JSON.stringify(users), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"cd8fd8406fb59b7a9ca62065f1d0565becbf31b3","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.3","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.13.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.7-alpha-20230205160326-cd8fd84","@whatwg-node/server":"0.6.2-alpha-20230205160326-cd8fd84"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.2.3-alpha-20230205160326-cd8fd84_1675613022219_0.1681499782990461","host":"s3://npm-registry-packages"}},"0.2.3-alpha-20230205160404-daaf017":{"name":"@whatwg-node/router","version":"0.2.3-alpha-20230205160404-daaf017","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.2.3-alpha-20230205160404-daaf017","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"27bfd48ef44641669e4feea73ffb169fd85582e6","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.2.3-alpha-20230205160404-daaf017.tgz","fileCount":7,"integrity":"sha512-vkdv4CGoSaL+WgccdyOJy+CFyq0BpZSAXL+wRWbb7xrbWWiGYSMosT91HCmjpB0DNViQe/P0Ta2VyAGplTFO7w==","signatures":[{"sig":"MEUCIQCgvlP4M1b9/1hCVUY1o2DFp1P0Bzcm5BG+/vD3X0M8PgIgWg/G79xaj6E12abADs32olz2r20+G+FE4FFTG7brMuU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18819,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj39OEACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpJWxAAmaogoBn9HTZFzQVm10CbBW/nYhhoCE7B1GtDM1zXmLDOOxWd\r\nUudk9CPbk3LOpELgi+d/fTnlDI4vtfL/GB7M5cIdBsjANzmwGsRbYTKH82Dc\r\nU9amgfdAGk4MsqAkvoS7ucJu7tYlAQ64UpqjEycVeUP8c6SZx/+yBeRxCgMS\r\nnSI3MP691EMzJxkncX2sXX0a/ChAVj2MkJegtHK5z+VK+tssrv7DAIEON93K\r\ng67XSMr/k9eb+5fVKpDeVAGrjhCczB3HHWcjVwMLPfdxlSz/R41mpdIdltPu\r\nuyw+Zj6QqqaFL2juO53xnY5tkC6JMgy0YPIEi+IYZ9PzSZGH2aXOza51C9NN\r\nxH2SvyBh8APhSIe2N+RWzfaR/U/P0EjnuY/XYBzgquHjw6+gjunNrA+tsUmg\r\n7aRtKN+GxdVMaAtYRce5BZhG3i4AaHBoljT8oRhnJrEeqpVmZeU+73hj6s9E\r\nu9LhkBiCKBFrARk7AEV6K5jB2dhLzyZtK0G+G3MziwlcSiApqGaAF+Ho3cr9\r\nE8KKJT/vgeee6heG4QqcqvfixjJ1nUbmx2K9xjUIt5w2px7d4SVpaQ51Heqy\r\ndT+ziY3XXlG3mCscYsGjvysyljQoOqOXMc3txNH3CvmN/PT5pOamPXCFR4Lb\r\neLctUBewACuzd6Eag7c6mc1mT4WD4MN7wPA=\r\n=61rZ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => {\n  return new Response(JSON.stringify(users), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"daaf01716ccb62eba0b32e485f71b78355dd85b1","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.3","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.13.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.7-alpha-20230205160404-daaf017","@whatwg-node/server":"0.6.2-alpha-20230205160404-daaf017"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.2.3-alpha-20230205160404-daaf017_1675613059814_0.569529232599951","host":"s3://npm-registry-packages"}},"0.2.3-alpha-20230205160723-6e9b185":{"name":"@whatwg-node/router","version":"0.2.3-alpha-20230205160723-6e9b185","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.2.3-alpha-20230205160723-6e9b185","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"368d76acd95b2ec66e2811e5f8ca7141a9b7ddbf","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.2.3-alpha-20230205160723-6e9b185.tgz","fileCount":7,"integrity":"sha512-V+BTGuJSMRko1IZNFRGfDKg1oMuU5dbU5R9hmgcvVbD0Ea8B2k8xLNEPQBTZU1o4cJi7XQS3fwX+0zoIVPItBA==","signatures":[{"sig":"MEQCIDlpxl7vR/MGNxvFO1FYFqdsPZglwFs/fNvIDo6F4sX4AiBMxjAivLla+LcUbOwmx+1aLJYz2gSS9QOI/AZ6iXDQ2Q==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18819,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj39RIACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmq1VRAAi3DxCM32PjKWwF1BMwT3LnaJMdgO2rS60BA3Qc/d95ajZnQu\r\nxsUBSqLwB4KAZc7xdFCydMyynSRGJgeiEghWpofYLKbwP3NPt/rFE8vk/vkT\r\nMyDV3HqCYo2x93W8U42174nf+nDZB33X+ZnQ2K24kY/3Y7SBpgc+zDJHVKZf\r\nwk5Iqdi1fZ87KwKAnn1VvjiSHpLnVuJXbEDg1hdH4z82ZNgydzuzvQyNOQd2\r\nb30t3HiyadzBNVTH3qvmT0jFMFN0f6Yj/02VKCEVHcgPYM9QRyGSRT2ryb2z\r\nI073E06ole6BD7NQZL5IlqJ7E5qFTfdcB1MVMGJZ49Y5mZTGJls37yggusWx\r\nKu48FFeeDRnM8uBgncw0UypFDSn/Ae4a/layMyuh3uWkQV5875vVXUpj0CAv\r\ntS+KEMr4H5u4KHDl3KKLNs9hJoKaCrqSIl6LXWVEpnGQlfykvOMqC8VqIggb\r\neli7xMy6xekUKKI3LMhdA+Q58b0UGkCSuKHumYOJI0TukjLJ14SnfQSlA6lp\r\nu8p62ciCV8M/YksqCrVXIzu93ipI7E52Zo3752GXQvnIUukJ+VPiFBE48Et7\r\nvNoPGwKbARyMHdcHgmTfN8rbHavin73tSl/ogsdws/fCpvZWzmEBs9MEMrlS\r\nvaEd5ASTEfu+7Ahmh9UIuEE3eqgN9tuGkjo=\r\n=3Hav\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => {\n  return new Response(JSON.stringify(users), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"6e9b185a9c1bd7bcc54cf5ca9096b95bf5683af7","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.3","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.13.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.7-alpha-20230205160723-6e9b185","@whatwg-node/server":"0.6.2-alpha-20230205160723-6e9b185"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.2.3-alpha-20230205160723-6e9b185_1675613256679_0.41894827562288284","host":"s3://npm-registry-packages"}},"0.2.3":{"name":"@whatwg-node/router","version":"0.2.3","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.2.3","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"8f60ada53053cf9a400d680dc350a873ff121395","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.2.3.tgz","fileCount":7,"integrity":"sha512-xRkX5f6/KusmGrUh/9mfGhoOt+pI+TZIstpSnBvCUiDEb0ElJHrkKN0iQGq/QlWpK00S47p8/f3jJQemM3o1+A==","signatures":[{"sig":"MEUCIQCDR0gdVMNI1Zocw7VL2f3pt5w8r+DJtQyaj72YHn9bLAIgejCAXK1RMVnkwaxVZP4pcxum1uPausZXKuEgxIKaIaM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18732,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj39jHACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmpsnw//TPwfUqGhXrG9KIJw4OIfONwFMv19+Gvd8x00vVHumf8SVEW1\r\njCwMgVUzUoGRmSX+G7QyiLyvDbNeDppOp79JOcFwydMMssju41H72qYlZCY1\r\nzK77tX6o22URYyUzzpTcDAYLA1wvmfKjug8/2MCB68pK1RlT+EoWJXrMvRRN\r\np6XjrVTiTyGPDcCvP4jcHxyJOHXUPseEDuLBNCX08yaWRaaICM6efs0humQC\r\nEzdm6aIqTsz9OV6w969r9YiVoLSjsh8kv+P5hXJX2NfVmQQWF69mUfmTFEtd\r\nMEUfG9I9osJs0NCTl+0DN1Cf6ZNiiXppilyO0pXqDsrIFuHKHr0jtyl95B7l\r\nrLJXbw9X6h/aI6/VT7bVd2E0RmG5vPw65XXD/sb4FtMHBVFedh32O6I9SsMJ\r\nJ1TfhxZzF+OumbYRT04ChvamhuRpWMnaBHWANithx/f3eJ0BwLubo+/8XJ/S\r\niHYtxHue1SRof8kJieDHNOKbYemVT5619uYmKvsSOht19sD5y3iKgRLHSg10\r\nunsqQPs0EJv9fk0+NqNTMDLXvn9NKppP7auk4IPHdLGnU0UAaU2krv927JJa\r\nE9Vy5RA2ThAa9s2uIUoFZk+GBa0g2kLiDyKzsQblObP6JaTqbvCuouosKVaD\r\nSmBARID7eSOMlYCo1XIQS6Jc5/9q71b7s28=\r\n=dbTI\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"4b18d6c527d9dbfdc0a373161b9c929c57367000","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.3","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.13.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.7","@whatwg-node/server":"0.6.2"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.2.3_1675614406968_0.44004027751251495","host":"s3://npm-registry-packages"}},"0.2.4":{"name":"@whatwg-node/router","version":"0.2.4","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.2.4","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"d507e35551e1aab9d69e0da5925d957847f3f915","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.2.4.tgz","fileCount":7,"integrity":"sha512-8g8N/K5y32SsnC17yLOXuiRnDw1L67vOgqwAOgWDLotk3Lvsz864SV/QJQnUe+QX/REb9mnzyBimtBTkFdW6lA==","signatures":[{"sig":"MEQCIDYhknS4nNl3VFq6U3omsJHXdoyG97L/HDQJOmDK1BCEAiA9KE5GiLX+e06ZEuuoPKzWOjT3Pt4UhwF8/jyWjHDcow==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18732,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj4PIdACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrkAw/5AFKtjckMiKyKS+LfANlYi1+Uc0WW6qnNhSQvwFIQ16g7veS+\r\nz1DkX2VcgwMRafjOnkuV7/s7VPW7/TKR9AfK2YIv/TGPj1ItsL2XOrBMt0qf\r\nUm3ejTBNnrIgEklVfl6BYktBB/psHxi45jvw2DA4kpvPAW1f1Pthp/0IrnwM\r\npyth4N+PuIBC+VSs5QvRHh08QMkvLWqnIu9R8ShtmeL/UayVx2XDoObbjB16\r\ngupmoBpdifgSzkqs3ORULNXXh8raFMTZ3Yiz/c1ZpTkdkNUToR9BeVRHhIsl\r\nVcNyONEiemS71aj8aiQeYxG06bgezGbvx59iDNM+WkV8Ga1NPA4Jb2hci41i\r\nY+i3PxZgichOOo/OcmrWv59z3AnKJQFbcgRbO0D/+Ylgv6Z073CvcJIlSiqv\r\nEaR696ZsxRszOlel24gL8tGanvuurvkbXhKEUljgJ1IbeToQvb40ZoVgmitJ\r\niB+MksmhPhwvWMrxVqbyUwyEgH6EDuT5E2CMPLnSspbnKzLKhU6/UxcV6C3o\r\nhBPcAiU5mb80a+s7KLlzGY7VyBrP0cnmXYMpQfmAztyL7R7rQzznv+OHACqN\r\nEtT0Jn+3YCYLPRC7MnfmvU3VgOn1rkZZ8AvDwa99kfWUnrkZwQcU69CQRxmg\r\nnjqtFXdaWLu19qGZByMKUb6d+57deQ5KZik=\r\n=MMNF\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"3ecd81434a4bdc0f1c5f3203db9dae01f1c1cc87","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.3","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.13.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.8","@whatwg-node/server":"0.6.3"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.2.4_1675686429617_0.39253041807391154","host":"s3://npm-registry-packages"}},"0.2.5-alpha-20230206135508-d9b0cd5":{"name":"@whatwg-node/router","version":"0.2.5-alpha-20230206135508-d9b0cd5","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.2.5-alpha-20230206135508-d9b0cd5","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"d09b1eec3a07535aa6ad55c0b3b6ecff251d3d43","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.2.5-alpha-20230206135508-d9b0cd5.tgz","fileCount":7,"integrity":"sha512-wIbsIjFnBLS4vHJ16vptypYuc/IcEkXFcAus5wg8smDwIT/9G6LxzEbuDpD2U2JbdcgeGzcxNkD/EEWnviVYhw==","signatures":[{"sig":"MEUCIQDN+HC3LsxdXn5hWo5fLcs23w+WmgAI7bJ5wKgtVxUP9QIgY/DOkApfWx5crThVst6deyM1rR+GyDp0oQWaE7fpceo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18819,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj4QbLACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqALw/+Oqz679cH9mhOMPCqRNomX3/QdoQmdGkyRZQLsDvlLMNEzzmj\r\n1209yIna7BAAPE6YXXbCSFwZcQOJ2xrkmo4A8pcz+XUjLeXX4YosPDYVbNoT\r\nupu7Te5wQ93M105kuk6USf/D2ovke1hliPAHelDylICtkJkipd2Itd2TZ4Fe\r\nRyMBe7gcBXLB54qOGvnyRWh523WzWFoRmXz9eOXMQOOE8BmmW2Dkb8QcIG3V\r\nrN13h3KLsQr0cyHp13zbApJOQ5dhT/yWUICNf0ECQfv0CeIg5JRgh7YHdRtb\r\nLZgRPCcGygDxmIAKt48KNp1EoCie0DZXmh/Sprou0h9hEnLz5xySLHBAZacX\r\nmQWiHQrljJpDEv6QIPUgsR1hbog0uqWqoyebYQKkZo3UGG12luyMmY/A0Orq\r\nZwDaJ7DYrjQZ6ua7om424gzf3xSOXToIU+W/uS1zdZ62RwMwXV/2YHdmmBKi\r\nR6Ilc7kcGjAAH9O3FRiHODJ0nHBI/ee1ZiQUlNJ8hMRT6zPpCrdqDP/sNdG7\r\nP2+cpntJcpmbYbrDhEHmBWkMaO4aUq+eHUP1Wi1g2IUkkwd8Y3cnX3fdM85E\r\nyuDNcKsAhZfW1tvhdJ/kAQYPbTWXQ6fgsr16uD/Meddylhh5/XE76YPI0Yna\r\n9fgqG3odkZ3browfCkgw7Zg8Zu9dmtmRcVo=\r\n=i7r/\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => {\n  return new Response(JSON.stringify(users), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"d9b0cd5155ec8dc75c53669f98defd93ba103f84","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.3","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.13.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.9-alpha-20230206135508-d9b0cd5","@whatwg-node/server":"0.6.4-alpha-20230206135508-d9b0cd5"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.2.5-alpha-20230206135508-d9b0cd5_1675691722939_0.9424027766714718","host":"s3://npm-registry-packages"}},"0.2.5-alpha-20230206135558-1370a81":{"name":"@whatwg-node/router","version":"0.2.5-alpha-20230206135558-1370a81","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.2.5-alpha-20230206135558-1370a81","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"c1d70a8f4de579a83eefc7d7158486057a9329b3","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.2.5-alpha-20230206135558-1370a81.tgz","fileCount":7,"integrity":"sha512-Fkdh+ULxW0/TL8+3+QdFotW5z+sBhn43HmtQ/leWrBovn/GgEkYloSf8N6+sBKberShpUB660aoMtWj2UC88jQ==","signatures":[{"sig":"MEQCIHOhfn5FAHWDreVeeues2HXPx+lgY9OX20i+3Qz3X5qsAiA1M5+BAB4gIngpfrZiK3MxXGPHKOKlnq3Ek7sIwZcEcw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18819,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj4Qb9ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoaFw/+NIS4ZrmSEFNFsWLhvTWBGv8jPLHmuiQT6xsqos8a6sZyz/up\r\nIgRgjAd0wkdA2B19ul5TWeWjrJfxsbyiftt+8KvEfjWAX129RZvi8Iy28r3e\r\n7bjo0z7F8l6ZUpzTBR5eC3QX9f9zpvd7ldNMYzECLt3vF2G6mGeqluSf6FFh\r\neIfSg9O2xaZvuYhP7EZZpWpIm52F0h78s88gr8pUKuGfkvUjsntN2Ochon8B\r\ngeCsjpqY36LjlqXDj7r/CT475HYPngMe+QX8DYDAaQx0vqKbMpnbXIEqtpLS\r\noOsB1wtzc/Ka4wfWxJAdQwVRUPeLGELWlGk1AqcWCJNBk3RaNuKT2V57O8Px\r\ntSdHRSgy0aAYnrobqwHwRoqVwunvxtnSFL9P0bdwpSBQuVeS//4LNwNvnCbQ\r\nBxMYaST3qPeQJPHxiqrKJlvcjA0RTEXgG/yfn8Y7k3840fYG54hl3cfhAzqW\r\nlx6+LKIQy8d+p3nUDm9BTyxbnDA6PRUykuNyaQlmpPikYrdQbBTX3SoAwhG/\r\n+rqz+z25eyyn3XT0qcWTFfXyKMhpdDD4LlABsvNI0dspjC9iNYLm39f2qwN2\r\nphNDgr+CDPTTy8nrk7LCjnwmaQ34OymnWnG3cxrOaPOF4QVTbRlJ1bS7nKzI\r\nNxC9jzZQS/SW7IjNRCcG1gihCZfYxvMATLs=\r\n=t9qg\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => {\n  return new Response(JSON.stringify(users), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return new Response(JSON.stringify(user), {\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"1370a81342546ca15c9a237fee6e2352489c773f","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.3","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.13.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.6.9-alpha-20230206135558-1370a81","@whatwg-node/server":"0.6.4-alpha-20230206135558-1370a81"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.2.5-alpha-20230206135558-1370a81_1675691773197_0.6926499805272599","host":"s3://npm-registry-packages"}},"0.2.5":{"name":"@whatwg-node/router","version":"0.2.5","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.2.5","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"0e512e9e07e348c430b5afb9c7e38dbf3320d830","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.2.5.tgz","fileCount":7,"integrity":"sha512-JeSKneFFamDlNWvfUHSpV/1QpakPVXGNSBBhg6+LjPCOOVQKzCeiLyPh7rJxdyay3McPcac9B8lr7nF82mvmTg==","signatures":[{"sig":"MEUCICRbo8nkGORVQm9MiqngPs6xC53q98qZPRg2gbXCKS5YAiEAyhuBiWUjG2pVcd3ycVnWJ3n3SXxRBSzrkOcYMcVi90w=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18734,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj4Ql1ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmpw3hAAjWx+Nyx9w74cdFyinELZMiSMHdWtz5WsD0OCuShe//15/PfS\r\nmIUyC1Fs3+XKkw5sw5dHQNXTs3AvOmXP/Eobtg8sTnPZArbdvDGNzUmpQiih\r\ndiza2Ft1fJZOd8yrnSPeZyGP1UjM2ecaFbOVX/IFv3T+wR3r+fo8l6jZoCcd\r\nRxMND7h6cFoHGLr7glCiv60ffKFA9sRBI1cFnbwbDY7Gw5Xz+yKq8fuiTxty\r\nGFQMlF3Sz4EJ2L9tBOj8OfMreNv6WtAWJBqhqQP2hLmaC3Yibm8qTW22SNad\r\nHcETzBsZgUKu08ewYjPCxz0rrCbJwEDjnUidV7EtUlKuNWfu92eSdazPrSZs\r\nY0jVssvJ5iagq4tOQizbLjiTMGar0B8ml1d8q/iBLhL6ZGokS0gEHeWkVdNq\r\nT9cyN1Q1y7iuCD0VDM8CD+BJ316FU1/2PquXE1NlIdY5mGDmRQllRyBQXyA9\r\ne4nIKcBzRYFo6HOr/Q1pVyA9Er4Dq5pmQyG1vu2L7EmZdV+RUeAjspqJETxw\r\nGgw+Eed4kFROwB+DJdaOhC7woMUGOXa1hsyvpHe0/XAveKcbXh+nk2Bq2oYk\r\nTtiYha6GHDz3UNVPdtsNmNbougQAnbTezs16BobKSmk7nBEymjQjhDxVt0jA\r\ncMJo6PGh8fI1EG5mc+5A4jDq8XMxn96dFd8=\r\n=M37Y\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"7ff236de461cc699b29a3195aff54208d5025bc8","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.3","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.13.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"^0.6.9","@whatwg-node/server":"^0.6.4"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.2.5_1675692405000_0.15376912024397282","host":"s3://npm-registry-packages"}},"0.2.6-alpha-20230207093208-c16434f":{"name":"@whatwg-node/router","version":"0.2.6-alpha-20230207093208-c16434f","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.2.6-alpha-20230207093208-c16434f","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"66530719915f28ba5138499529a2f0a713768cab","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.2.6-alpha-20230207093208-c16434f.tgz","fileCount":7,"integrity":"sha512-oh77i8oBQyyqcrgg2wccivgGkDqk/G278s2l3TWtwxupzmdaKgz+QN8umW5py5dstB1TihIrT4B90/UHLgZrtg==","signatures":[{"sig":"MEQCIHE5PMeThqcG4kvdetHragEHgwqolngH6f5dtT2BiAteAiAOMzyNIlCpy4NE5Y2GfaVVVeVevJ/Qww4ZcwaE2TjhHA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18480,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj4hqqACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrxQQ/+Na7tGc8sfjQhNH9BpOkTq5HZfY/P+nKwcYl99z+DJoe7asSg\r\nl4GuN7ykeojZEry9yeIaR9sZuCZ+0kYgjseTz2kMGslG9kQ5AtXlpbxD34+S\r\nnINCUwvCPVP+z3eFLTJdjLxJQLJDIo3mchk/pzoGwdlsO7elGBravl1Y7Rus\r\nnn/x6SIU+sk7p3d5eNEgiyRK9Fe3Hqkw/5aix6I6hv19Xqpx0PJHIn7F5+Ic\r\nL5tCyu16PtsU+2+skN6M8bDqM8/0uy3+tCT5NmEgRoI7fiTbOWk24g5yFhMa\r\n5xfPykAamxrhfYX/Ts7WmBCIO4y8AcuejSMq56BbSsv53gu34E8Zp37dfOsM\r\nbwAS/l0PIX5WRe1afr8B5ogqmos+PhKoCMXEdX4yUdRe8kvMSQ0XufSYMUNs\r\nJe7g1lxhrRe6c85OqKT1vA442pOYb1wT51dsJVgAGoiSzWVpjvGuXNPjhC4k\r\n5g0iqXpNcz5vXA1X5A+sZCiEbml+VHXh/vIujb7pab5ELUE713DmJA0X0olX\r\n1kzTAI+ni9Tuw0+Leg5CmV+OZzP60HMhAfoOb9nUcGg8RAkmxn18PjahvzZp\r\nc3+ZF7sVm+HnTLjpXGeEm2g43nqVkQo36gNwc1RPW4ZVmsAg25IUbRqQTgbL\r\n5M2vLNIvG5kSvzKps1/EsEDrMpWf/r++iB8=\r\n=pGBX\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"c16434fab11b324b3fe839559d9ad61eb12a52ec","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.3","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.13.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.7.0-alpha-20230207093208-c16434f","@whatwg-node/server":"0.6.5-alpha-20230207093208-c16434f"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.2.6-alpha-20230207093208-c16434f_1675762346805_0.5159822401615208","host":"s3://npm-registry-packages"}},"0.2.6-alpha-20230207093213-131f46f":{"name":"@whatwg-node/router","version":"0.2.6-alpha-20230207093213-131f46f","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.2.6-alpha-20230207093213-131f46f","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"8046729c8c326f7145760429ad787019a3a1a17c","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.2.6-alpha-20230207093213-131f46f.tgz","fileCount":7,"integrity":"sha512-JL/NHZT1Xbh3cilNYBuQ9tg71aFJ/MblnMlsKlQCG2+SSKppNUb+TIxRcn19fT61xE4NaQsZd9/BoyH6TAWVkQ==","signatures":[{"sig":"MEUCIQCm2m+o1zdmWLDHnrQgurQTRIdtT35DJgUEuCGcZhIy9wIgIfaoXGKIt+Cjp/stR2PHalcOcUSa6ZqKV277Ypn6Ie4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18480,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj4hqvACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmp8DQ//XyN5XNoF+J/wlRRWz9VqVlvo+4yJZsHCY5M+Aeegx7T37nyS\r\nzfySN083l+y+EsoEOG4OhHD6bP1tHIijNNng7X4rkAi9ZZDk+9ddToI79PLz\r\nURTPxcFktj5pKXPAc5/qN4DR/3DGdwL3T7XIU7f9F5oMJ4jlpurtIFBSsQk1\r\nPe1wEbnGkk1JtvpRZQmVboVkWCT6tjF+HWq2qjDxfndteEat1je1AJLkXEHk\r\n3JeXqEGT4Yh4ILkLNfbG9WjafyiaWFYjfZ4vnO587lyP4++JD31CTnbBlag8\r\np6+zYWmFV4Kjy18PvL3/UL6hMUFZGbXUDCfkuZmILxYH1Sl9npd+H6XR+WGh\r\nMnHi36Lphe81R3/qWbf51QB2x9aaM2sRKGH20t8qN99XEgobIWXua2/FQLdY\r\nEFVIFz0Q5+ll4NfbCCJ2CwRWJp+yB5ngGKmPODHn2b46aXsy3Zgay6MdRzZC\r\nb566+Ty8YihIvbep+LTozQumRmj90Hf/pkKQbsUfM+8WJjtCavgHEFozBjRt\r\naeHgiGoS2jOdeotJx7iI21YAsHMibICiF7NPLE18kmc7tfeTnjY7SFISDfpi\r\nCCGRuHZckqIXxMtpN2bm7q0C/yo6YjQidJRvGEkRaZd4lT0NCDzM6GfjuzPt\r\nxx7mfBLsqbu+UKk6zLDleItrhN1D9BTxsdk=\r\n=ywea\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"131f46f145afdb5f24d3967e21b0eb5df69fb4a9","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.3","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.13.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.7.0-alpha-20230207093213-131f46f","@whatwg-node/server":"0.6.5-alpha-20230207093213-131f46f"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.2.6-alpha-20230207093213-131f46f_1675762351234_0.15957133151312686","host":"s3://npm-registry-packages"}},"0.2.6-alpha-20230207100807-5eb50c6":{"name":"@whatwg-node/router","version":"0.2.6-alpha-20230207100807-5eb50c6","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.2.6-alpha-20230207100807-5eb50c6","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"5c04bb8491e3fc32032fb34b25e64908cdd99ade","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.2.6-alpha-20230207100807-5eb50c6.tgz","fileCount":7,"integrity":"sha512-aqecVnzM9QrCLIh0c13exyVYjZlBK7q94cRi3S6I5EcXpEM90zShIOEvzmzHiBjhFfR2EIEZVJVGAlhUTclCsA==","signatures":[{"sig":"MEUCIDjkk5WhcK3lXY/OBSdyqeQv3DPHit8pi4FxuD87BjdbAiEAkkO/A0cq26R+ZRyTM6xXhcX/JLUu/IZ+cyt8xrREnBA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18480,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj4iMVACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrY/Q//WnVC3JeMhSz/8YIPVnn881shDqwtksz4UwhP/dbIdLw/66Zf\r\n46thrJ6HzOWRRLLwGVKPQMq+cE+dh2GHgAfGGGzVrs8qqQbdu5u0EMhbFyeD\r\n1Z+Ahb7BnXDyXVEgmw54H4yOe7bxfOn2GP3p8y2gHKk0mzY1tVrvJdLcRa9T\r\n2TN6oRHkRWWb7I5GXUcOuYdamfdemeCiaNfIufsRWlrEPELI9xSOxjhtFw3E\r\n3/C6ks2P9r5iaLDNJYb+HW9Y9czR/YhbQ9sn6pvNWiv522ztvmlgYVs1V/Ye\r\n/InLESIAPZHoiHAHPVlMDPWEJ2CYoSBvRR8HA4p2LGykSeOj7oBqtdHodbJN\r\nCq7Lv47GfavC14JIFa2KyMbI3krWYBckg6Emhozr06ZoCXklUN+ClQo+WDqR\r\nVD+7MtGBE4E7ePi1RdRZYu02Ze+mK/ugK7FieBMuOV+3J+rmCUjiqieYl+Lu\r\nSahTJQ5VxUvYqkHQI6RmYqI0qWuAWQbVnEn7ixa6pP6X/L1krWAoLIrHNsxh\r\nGcchvBptQCt7b237aPIt6jp9mXe37kGBBNVMU9IIjgmFo22aHYgEX/tB90z+\r\nwUTKnhfHZCGR47PO8q7v0CQV6yH11Ps5v0LyQWy4BCd14CAuTXkBSmOSmXzO\r\nXoGMuH3Zw6VGVmR2QDyweNKp7dMmlIAhCjg=\r\n=dJ47\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"5eb50c6bc1cb7862b11a2b80dc8581130b28ab81","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.3","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.13.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.7.0-alpha-20230207100807-5eb50c6","@whatwg-node/server":"0.6.5-alpha-20230207100807-5eb50c6"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.2.6-alpha-20230207100807-5eb50c6_1675764501310_0.7237817974511458","host":"s3://npm-registry-packages"}},"0.2.6-alpha-20230207114030-349e836":{"name":"@whatwg-node/router","version":"0.2.6-alpha-20230207114030-349e836","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.2.6-alpha-20230207114030-349e836","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"7ee2c481be8aa25b9731674d39094bb5851c37f7","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.2.6-alpha-20230207114030-349e836.tgz","fileCount":7,"integrity":"sha512-6NephwvN6eVnQh4ONUf8zjrMmkmQ4XwNGkb56TvlsJZ9BbgVU/6y9ZU6wRis0E0DA8f1bwFt+minm9Wr2TBtHA==","signatures":[{"sig":"MEUCIQDbzD3sFUDNGXARhgOxAma8dXRdWRwA+H00fe3j0T07cAIgeCbpMuytCz5y6KNXAtRLJVt4L5NLSX6mP1y5Y8c+D20=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18480,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj4ji8ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmraTg/+P3oWEpwPIhrat9XiQA8Qm1j/BmWwpbhHVtFfEkGmhWJbSsr6\r\nHv69YlSbphDStdId6Rh1qr5ex29xk4NzEHXa+c+TFV3i0zMtnKD2hDvXcz6j\r\nd7Pm6OWIMy/E8+a2iN0HLmo/ZnlxzdMUbe2y27IJxKWmYJ1lDqAF8yuR/U0W\r\nQCQNwlzhJv5LfYJH7AifSQRpZJMjUl3ZuQsBq8IUOKABKvgJbZRbhYC3zpk1\r\nJzDpexa/Ve+uI3ABVGJAhOv0hZch3HzYEyvhxYFeh3prW4spWQ1byjzBBBSU\r\nCIo/GDCeRwUBJDg5nUvb2azZpdrIHTmdikb/jl0tHNS2+J3LDehibCJl895w\r\nhCQvi5ZYkmUhLSlFm8NDi4mlHYvi5uarWyHTaSwrSvaIEdCfbnt6YpIOF/8b\r\nrj0J2KtYpVjHVS9dUYZ5s1EcTfpGH40QFb+VawChgOMxcCGBJQPS9oC13eHX\r\n3IlhKoxMoXssTw7fphDE2ACYjPmm198dCLNNtr2UDRBPhiPNZpsVmltyLCWB\r\nM9iAyj6ozVHfrUYWYZ0QOFBWuDDOEWv2zhpR48MZzy4yFzE/rQirlLmyMycq\r\nUGkPjf6Ns/yifTH/iBcpQA4ZzdSqM+dpu1Y16ahEpSANNsy9Hq+CtBzLuiyC\r\n3HRuP2KtaXVeYYDEENcx2vp3xkMHXohFypM=\r\n=BK/b\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"349e836d7a7d0f60abd831a9e89b10af13190d92","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.3","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.13.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.7.0-alpha-20230207114030-349e836","@whatwg-node/server":"0.6.5-alpha-20230207114030-349e836"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.2.6-alpha-20230207114030-349e836_1675770044740_0.2953581271101726","host":"s3://npm-registry-packages"}},"0.2.6":{"name":"@whatwg-node/router","version":"0.2.6","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.2.6","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"4f7c2962bc36d3f77c62c827baa473be4b89d5ef","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.2.6.tgz","fileCount":7,"integrity":"sha512-a4nzzdqMMdd+9C2T0wh36EG5eJyufM8Ng8N92OxBbZslwavrWG94uUz26i+moxAuxMohOugEmKmTlWQJUtrGxg==","signatures":[{"sig":"MEUCIQCShMOad+ycJP4Xt8Aw+5CVdAFO9xJZJuEEgDLj46WcoQIgbSZz8DWvPzeyL8l4i9Jtv6PsABPWto6sMTU/pfik8j4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18395,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj4juUACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmpjcg//UY5KkkBpigJWung6d13zJg/NhZpxB+bqDbS9v+5tSWEblHrr\r\nh0aSuHcf5eMovp5R74zsXv6uHsyM/tsGubkJbgFfy+dZoLcBTF7c8Rx4isFN\r\nBx6sHamxUDRbfKei91XF0eP1F6swqfS2fy1sOsZwMV0sr9mctgD3tou99DHV\r\nPWDZXqxiNXgJ5iDEUzHVJPkzZ2mjjobq9C44q2c1394tAYq7E2E6T5D/rlwD\r\n4/sGtB79a0tM2YK3NNVynOL81i2VXAXnZrOlf3/JJiqfVsRRO2xJypaH4zYM\r\nh/gxNFCzK6WgUI8MKAdhu34JH3ROgRAsouK9CofJR+U2XBRR/9ZDQfL6e/x/\r\nAdB3lq4a8P1vAqKmr2dRCB1tBWj/DPF0UvtFn82GRSnREvQtL2169DuU4EsL\r\nlus8bRVzOJ92bQiK+ndmgdWJZg+tpbzCi8XVT90i/6vIAa4NqvAbS4MxC/cC\r\nEXGT1YLk2QUqY96t+40hQZCyt4IUliy3G6Tv4roCnFBaB7VWISpzFwXJZDN9\r\nrJcEcrmpjpiHqrD03lJBFJDRQWZzM7pPJOXwOtNsMmUKbIvkAkXRBCLLwRJC\r\nLuXJCnPMrVi2eBgNg2VNUztzGvcHni2eExOrcTtlnGUbqZn0Qh8HxBlJ49ps\r\neuCZPa2OCmWe4OuDsUe+eHIuvNg5B3ALI+4=\r\n=yv9D\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"674f3010147c563a5077625c848f6cf4d5f249df","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"8.19.3","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.13.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"^0.7.0","@whatwg-node/server":"^0.6.5"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.2.6_1675770772671_0.44198683608802525","host":"s3://npm-registry-packages"}},"0.2.7-alpha-20230210093840-06aaaf0":{"name":"@whatwg-node/router","version":"0.2.7-alpha-20230210093840-06aaaf0","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.2.7-alpha-20230210093840-06aaaf0","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"5bd2a23da9ab3b3435c41dc5209a75894b97ae80","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.2.7-alpha-20230210093840-06aaaf0.tgz","fileCount":7,"integrity":"sha512-mrC/SlBrh7L6OOmD4NKa4QADurYts7ejnPTbuQWEtoBVRxX/se0PCUDO6u8lN30HMXfKQ29aHgd9aU3kNNNf1A==","signatures":[{"sig":"MEYCIQDzlcloA/Nt25FeOUqUw/K4UYU7QoqOGhp3yFOl7MuctAIhAKe4xgNJorip5ZOjV2ZyPxjJQqhhgtlds3OXCERL3iCd","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18491,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj5hCvACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqdyQ//RVSBVpWhBrOgawD3vBVNntpx9LVH/p22ZKFzX6lGTXqSEiX3\r\n8HSUf6jYzwa491Y9CZ0SWIpg3YHn6bdN4Sbl17dsgJWd17HHVi3e/ksCxrgO\r\n00DwfyfqikF47RPS3VuJA5LCUwnGUv7H3AEpt4eS1k6rfXahSSqO0uaoC9Sr\r\nzA/ZZ+dFn0JrXRXTVRxceNwWR2pt+7Er95/3nBsFeOvdzYlU6S7EQeDPaDOK\r\nIU6ROYUqht9gxbJggtvPZzYhI5KBggMc8OrtgHyZP1fFyFvc/ssy5PXRspxi\r\nAr089icypU0fKktySCVmx7sZWU+9mD/eT0mzyrItdXFuCWEz5H+ESjJhLRf/\r\nA+uqsk2Dyx4dQq4s0OCdHm39UbsnMgCKSTARKkte7tqXraPuM3vulo7Uk4Ij\r\nWZ2E5/Q7KXSEF2WspdwLoEWfU+9B+tN9jEF3okkVls1XWWivLnsm7tJTJy0m\r\nfJJ0ZI1cR2WyYO2ShGsCRbzzbLA78De/Ym16Wcp9PX5ITT8Q7B4uOUAcZBeq\r\nYP2Yfn3Q0IWaX8iurpd7E/yDjyKkKIe3i5RpPGwjens4kFi2kZ1s7Jyj1afX\r\nF95+R3zlIgu/rqnoeJE8HgKwRIoCOtW7D4pkwGLN6QqeaG2Opx8BtUw8LT2c\r\nK6quvSVjvROVazmujhoTgAMNi/zK4NnNlSQ=\r\n=Gaja\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"06aaaf06a662effaecaa8afb575cfccebaa0b328","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.8.0-alpha-20230210093840-06aaaf0","@whatwg-node/server":"0.6.6-alpha-20230210093840-06aaaf0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.2.7-alpha-20230210093840-06aaaf0_1676021935640_0.9126946804727412","host":"s3://npm-registry-packages"}},"0.2.7-alpha-20230210095043-408a558":{"name":"@whatwg-node/router","version":"0.2.7-alpha-20230210095043-408a558","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.2.7-alpha-20230210095043-408a558","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"4228dea670f8bf7e1d4fbd851689a270e3db6927","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.2.7-alpha-20230210095043-408a558.tgz","fileCount":7,"integrity":"sha512-e8pledQm9tgvaOS4ijEBnyhu15mNsxnqNZMqH4Mr0FijkBXbQ90d1KnO7owehrIayc/eq1k/m4ZMFWFiT7BL9w==","signatures":[{"sig":"MEUCIQCc/wK79XIuGDq5fLfU+Mm3pe07OGJPfWO57KDp24y0jgIgWuQhd86vse7DH/Cxr5+DTtytx44r3KDN37jrjDQ1Jx4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18491,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj5hOEACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrYTxAAk8YCwi5dlHx9vElx82M/YiOMuknRPAVg8eoloVYwjdVcPhgg\r\nQhtw/pV2lDJzEXLXFyidrvaaJmvjF8FLX+SHF0s7PqHJI7T8DEmyBtwu33nM\r\nJv4ZWSfY6uIN6a65xAatN3RCxAbNEMVbg/XoPTRnjTZvUiGACshbUyf8kR7Y\r\nnPADo4YN5kGa7MmaABdch7MnqcgspS5fQ9mcsp5ZUNKZ9JKZCwCPu/KXis75\r\nYcTi4cqr2URRPGIolKNqeCMjZjTWGqe5ar6eLmnJgkGdYC6k2XGwg3TSL5Ez\r\nG2nxceb46hVaFBELTyOzg2JU27x5Aa0MW7Q1qYWuS5ogI8koQsPmjLjmCvdh\r\nwiLzAgVUJjQqvKzo2VP0i4NADwl33PC2UXlHvp/yluj1tO1IFWiZQoaBHSAS\r\nGOJtHkxbOA9QbyT6TrKXXKMd2reObxNuLcsD36tzfJFPg9WPhjk6Yrcm1MUb\r\nArfPNbPPsAKT6A+5vCixmwOjsfwjcq57z+J9DDaY5ocrIGWwXKlYymCuuqGQ\r\nN64aFnjGSvOGCFw+yFRPWorEneb9NyQ2+j8JP13NT07EtGQN55StWXavL6Ah\r\nfPhHNLK15IUit5nWpr/Td/VOfwSVXaHAOqvxSsy6WIG5upwI3vhEOvU5ZhUW\r\nwAQIZ55twsxofWXthPsYYP+EfvcGfqD2dc0=\r\n=cFyg\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"408a558308cae9253daa804c60dd33320a9e6e96","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.8.0-alpha-20230210095043-408a558","@whatwg-node/server":"0.6.6-alpha-20230210095043-408a558"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.2.7-alpha-20230210095043-408a558_1676022660347_0.1676874774219006","host":"s3://npm-registry-packages"}},"0.2.7-alpha-20230210105523-366e74c":{"name":"@whatwg-node/router","version":"0.2.7-alpha-20230210105523-366e74c","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.2.7-alpha-20230210105523-366e74c","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"8e2748f27ef93824fd9c784bd3251b524d630589","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.2.7-alpha-20230210105523-366e74c.tgz","fileCount":7,"integrity":"sha512-esb5PZ6Pn1JccIzPs4akGNxEL/7mUYfsTxnoAJ/iokZSipS8gtC9Mwn51rCRVl/hFa/hrsB/b5Epdyl1ww/lEg==","signatures":[{"sig":"MEQCIF69vROWMiFder+PvXI5J0t4FYlQ4x2sC02/6NmR+fqYAiAFDr5ugMMzxWLLNGLNXYgUIwLvC9aepfSBK9jSUfqGdg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18491,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj5iKqACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpYMA/+MjC6FhVz6xaNpG08Uo2g4wfwr6nHjRCFjqDxw/YKXaVZbV2J\r\nD77lHlS7oipWbB/tUZ88v7Hh2rKLHRVMSf4W2S/7wk62lidDELKef9Tu1BPA\r\ndzS2BVNq+k9Udg5g6K48qlVy5/0Am5WrrEbLqD90IqJiDmEFfVjAu/IWJzHd\r\npAzQiTmFVD43Om1cAHrmX+h5HzgpUCL+hV8AUI1YJQBPRnkSF56qGegOENs4\r\nmi3V/ketS7Sbh45rcIwWXtsFsBAivxzfkEc360r5k2vb0WkNQ4VX1yhvgxx8\r\n+N1lLkHEc7a4K0/Kvguo8GPG0HYCXQNdVCpk8vtt+8l4Vxu/laLGLq3KB2xN\r\nkGYCiBqnTF+L3Oso5niObyh2c5u2aXdoLN7doWc6QFlW3lD/7mKr+JkzYN5Y\r\ndztFNTE/Y7DW+l23ktrHXcCzf6M6S1pnGPL5ujvDGliZkKXMrUEKfOrdytZW\r\nkTg1WXBLV99bjCuyRrVxNpB7vhquGVLsgBWRqsYIZs+oLlnxYYVAQDyf9CIc\r\nZeAKJc9Tu/WmEWYq6fo+B/0g4UqkMcccCvmt6jTNld8x4QQ7Qty6xlXgzYHo\r\nHTIqcGKKiFvOztAVab+8wmQTx2FqVDv30J+wzCIa7LTmMO99WBvwOYn0zd5q\r\nXbpx+SdpO7QEKs7oNwDs/zE9KeQaZROt1XY=\r\n=1QEq\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"366e74cfa58158619fc8c064d623cfced8468ace","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.8.0-alpha-20230210105523-366e74c","@whatwg-node/server":"0.6.6-alpha-20230210105523-366e74c"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.2.7-alpha-20230210105523-366e74c_1676026538658_0.48348788323999004","host":"s3://npm-registry-packages"}},"0.2.7":{"name":"@whatwg-node/router","version":"0.2.7","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.2.7","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"5b47279167f5c03f2d2c1d5f113d2c035a8f7e3e","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.2.7.tgz","fileCount":7,"integrity":"sha512-kZynz9z5kgBJ/mWowSNzoacRsP4iGPkM6MAVHUzaUxYcQR+crtUvsp7/P6H4X20ScRbs8sDRXi7XOU9mFT8Zhg==","signatures":[{"sig":"MEYCIQDYjSHEVJ0S+xVjKna6hYDMICLsKvNM3TNmC4Syg7/eLwIhAODxJVmdPHCwiEcylsd0bIfanRcfe4YDd0k/uJOdU3V/","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18406,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj5iVcACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrAohAAi9IURwEWhMYe0aQg6wFje5IZdTJzacq+oBJHEP0munRgppJ0\r\nYehbL6lR8YaKvGi8XzrnREITd54wyd/eFKFkrUua/5FLbtLxMEJPja+cqwyZ\r\n8+zqUrwfMhXXAdLC7KmKJGV/9jAd29U5Gcokol3cz2HqRuW4BGT97cOEzkH7\r\nkdRdATTVhq3dSOoFubGr39MJvf8yRrDgPpXCURS1fUmwl2b+Xlx+LW0PjxkP\r\neo6rxLmGoMpXQ4R/jppBGcJlWCt80QOOu3rY/JqpQztbGtyLdfk0KYgjGxGS\r\n18FZoCoQFThBe6fn2La/zVc6mvD+zCY+QXMo6Z00RUMnyYg6UyWRZNtP91BJ\r\n6fblUDskrhCeUI1dZJv7qhodM6OugZZb1Dn4P83o5LZ4lZnatGPIn0Jg9+uB\r\ndHvHhZQ4sIaTIA2bCPGC7TF85+zZ6yrPxMIMXdqBo5wk0hoSf9HfA0w6ok+2\r\nv/ZCPDaJEJ5OZMRDUaMa8kO6s5fa0bcWmpRPRF5/iVpdqtNqvx/4ORgrcFUp\r\nnfbsRSpbKQX1P9Rz/U8hUMlz73XTSfFC93OiZkNKM0SI5Rb9aCJEvKdIepTO\r\nlrcbRDgyPBYeHIud6sQrLDF7F/zjPsxotgs+Btd0V0kHfgJCnQyfnx9x1DUF\r\n7ZRq8MqPTBNe6ThcUKfJzJVurXVhNf9IYcE=\r\n=ZHRl\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"520a6b4fb119398521af72ab0ac450228330ca3a","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"^0.8.0","@whatwg-node/server":"^0.6.6"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.2.7_1676027228262_0.6434732846232689","host":"s3://npm-registry-packages"}},"0.3.0-alpha-20230215085115-d099e0b":{"name":"@whatwg-node/router","version":"0.3.0-alpha-20230215085115-d099e0b","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.3.0-alpha-20230215085115-d099e0b","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"c3499c5bab71b2549ae92d6f4206e4fb3feacedb","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.3.0-alpha-20230215085115-d099e0b.tgz","fileCount":15,"integrity":"sha512-E7rr/MXx42xmxuXU2XyA/vDctVwGWx3YNfA+lxaabOf2p8cl3jnWL9o9LdinQFk38E434//pBKTBntPaXticpQ==","signatures":[{"sig":"MEYCIQCB1HdSip/BMHuhbG5HjD5vaTEW6cvjImmdQgrjlGR5AAIhAMraEBqFPRte281La2IvHnRmwRS64WQ/tjR4EmxK8YxS","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20867,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj7J0fACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpUoA//T2ckyoCq3RRzaJGR8SZv/et6oxk/L0ccjQjKRv2XmQ9M32uU\r\nyhTHhj4ATVeD4TWWHtZ5I5/yj5pPLnuZ3k/O1K/ozx3kKNotkguuslboaHMc\r\nymUj08JaVstxDcidRTDWp3DYjuyQKGFEUhn7vf3dRPz3Y6nDF25OJgN7L1kg\r\nlJQz8nPdOu7ejHSYlm+JRcvZsBb8jRDZif+0fbTMaeOok5EvtDv30uFwYgmd\r\nwXzRkwsMFhO+o6K/Y2EWdVfGtyUmAh2z+bkn0DM+PZ0FezuokvGMPiVSilii\r\n1ZUkXIx/zSn/Lr3IZ3ylyVM9c03sD+lBoi4Vw+vThTOhimFMSWfI4ffeodpL\r\nVR5GgZ4+uaEOEYIOcQ55v5opbboqiaFS6J8aDqIS8EKuqphdXDoP0g0USnx5\r\nGWJwrZQD8FNk5VwhSSSEsnbmAe7G1MdS8vAmL4gkmDxUaG+BKhaO3Jz/wM1j\r\n7wrr8TFRFDv1YZXgACCvoqrSlGBVJJ4Ac7yN+lD+sgV1yuqulAW7yeQj0h+Q\r\nFWhMIlrMOVEbxZXcnQSWTPW8iPSlQd0fkJGcia4MZ8WMzjHFh5kHJGwWJBRs\r\nnKsUis6ZYnnKX/rMz1j36n1sU85w21cuMREHbmiHet/K6YhdNxpAxO6IuGCN\r\nYh6TWePuV+2ZlKdh0aeD0gM+zXYtgKKTahM=\r\n=KA5W\r\n-----END PGP SIGNATURE-----\r\n"},"main":"cjs/index.js","type":"module","module":"esm/index.js","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":{"types":"./typings/index.d.ts","default":"./esm/index.js"},"default":{"types":"./typings/index.d.ts","default":"./esm/index.js"},"require":{"types":"./typings/index.d.cts","default":"./cjs/index.js"}},"./package.json":"./package.json"},"gitHead":"d099e0b944eb3caa84c1d3f94f6071923292ca2a","typings":"typings/index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"typings/index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.8.2-alpha-20230215085115-d099e0b","@whatwg-node/server":"0.7.0-alpha-20230215085115-d099e0b"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.3.0-alpha-20230215085115-d099e0b_1676451103194_0.5094749352072041","host":"s3://npm-registry-packages"}},"0.3.0-alpha-20230215085143-56e6bef":{"name":"@whatwg-node/router","version":"0.3.0-alpha-20230215085143-56e6bef","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.3.0-alpha-20230215085143-56e6bef","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"1c54ee847fb43a54727e4b3c0647f41f8f311283","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.3.0-alpha-20230215085143-56e6bef.tgz","fileCount":15,"integrity":"sha512-3OfwrUVGM7Q6H065MLRhp/nI1IAiAEqF0HcEbuTJIygAXlVprH6TaixL6UgqMdSmx6dxMN5sFo8vgCQq1Ib3Lg==","signatures":[{"sig":"MEYCIQC6eK/WWGEdmNjT9qcqtGyf/suhi45THV/EQATFiXl2uAIhALuEF7j6ttFjLb7sfLNCLCuu+jWPb+qQqrmgzYEG6c9L","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20867,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj7J03ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpqDw/9HME3p9QjUUmdoVFA2KkDrKD/mkgSFftZVFvn5Naw4/1QycHG\r\nVK55o/TaF4bRZ4wbXdcv9kH3i91k00SRXpTnLwjdASGSZspRiqbumST9cgcI\r\nJANmpaY5VvzvrUjXxTVLupwoDyv1otwW5KjL4K8aEWX5VlZT7DpfvhmVGNcT\r\nUfg+LDQzeGG/aehhmN9mtu9mptfg8SDARY+fIY3ayURieU7YNN3yqZRyOBzg\r\nBsAOLceoYDRJSmXYUmsJ9nHnVUEyfVSaq2iW3GZCauHvWMZ49Y2mcNw2ihbv\r\nHDG81W+j0qN7tlI2WdVz5nokbJBLfsYyUulQoX4f6rmRr1fkOoxM2EbSYjJt\r\nkF6toN3zl/uBR/n0do0usyj0PGFmF3o/F0KnqcbH4qL4g6ksXDdRTMSxMKlO\r\nsO/23EAGuTrvp7WwhrVgF9ZoGBGkNr6UPzlm/tRva/wT7Wm2OGYOnWLCdzu5\r\nho2tYUN3dpuW0w4kWcIhACcMkfimIR1QCZmfGmaQ5+fB22VSeVkJauvh0LBi\r\n5uF1RhpXaV7crUMXQb61dnxWjXIuYGZuSOJr1nzHQH3hOsvclV9zKR1aqXcU\r\niqR3UFSKVUs7fry0fenqsPG0cXLmNJ39sswCEbUjCtq4fYbvULa2nEldX6M4\r\nH2lx5naWRRWQgNFCm4ykPC6BwYqcr7RLXsY=\r\n=sdqL\r\n-----END PGP SIGNATURE-----\r\n"},"main":"cjs/index.js","type":"module","module":"esm/index.js","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":{"types":"./typings/index.d.ts","default":"./esm/index.js"},"default":{"types":"./typings/index.d.ts","default":"./esm/index.js"},"require":{"types":"./typings/index.d.cts","default":"./cjs/index.js"}},"./package.json":"./package.json"},"gitHead":"56e6bef3e47e2f400a6b7a58bd90904edf672158","typings":"typings/index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"typings/index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.8.2-alpha-20230215085143-56e6bef","@whatwg-node/server":"0.7.0-alpha-20230215085143-56e6bef"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.3.0-alpha-20230215085143-56e6bef_1676451127272_0.0833892335944264","host":"s3://npm-registry-packages"}},"0.3.0-alpha-20230215085620-3393c60":{"name":"@whatwg-node/router","version":"0.3.0-alpha-20230215085620-3393c60","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.3.0-alpha-20230215085620-3393c60","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"3cde21f49c7f4a3b296618f4e611c29f1557a659","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.3.0-alpha-20230215085620-3393c60.tgz","fileCount":15,"integrity":"sha512-lGYVXoGTlXEoiA7J5x94TtsU4VsSIuhRyipzHBLM5+v8VkjgxYoCRUtSivU4dwmjL9dhaMKYEPlZQ58bQSZC7g==","signatures":[{"sig":"MEYCIQCb+rgIyAe1zam1xjt3YPev8Oe3ybQHal6na1RZxbH0XwIhANIYLMAphuuOUEmqMYgejwEqfPk37/DSMiGe2i+ZCNas","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20867,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj7J5MACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqF5hAAj11R136KAPD76d3Ur3r4lg7VCILNHmbThkmP6hvId2m+Gs4d\r\njn8FV4dFW8loTVYKueT3KVBLYjNDlbztrNlgTt1H+u1UTKzZJxMUKryt9xhQ\r\nYXCnmGak3Bdkfb3TaaEuwTv/HWCkYPEuya0f6iFAV9PCSiCDr7juSiC/+849\r\nKGEavkRORmAdbxaof5q54tIv5pQ3ZiCq3fFdCrXCfB6xV15gE10EqsW+nccs\r\nehXqGNDWw5LXxwR3AW2IjnCgoqi6yQp3BjsLeY/cVeVIzi2LYxmGg4/sQMfl\r\nmewfEkRIrSQvZFvxHzqhnrvApXWmol1AJQHHddVSO87n3KRkVzTalJXrSRR2\r\nb79+udoPw2sId1xdIM76aZ1vHkDaWPghqKh6dr9jC+XwBThk8GAjbtqL6eg4\r\nD1z/EF6MbEy6K/IbmS+WQFSgWiY9gE6sb3CQWNqZTg25aIVpbSkrjhGiK5wV\r\nmBksiUa1SCqVoINvsArAhD93qjoJGihhDjCW4BDWx6s/YISOE3hZddZVroTI\r\nQqkvQaPexI7YgWGPXWj31qaC59kYJvNY6Y2Aaj8uCPA8nTJ1XS8pgvHi14Nu\r\nw/aHVqrafar2LRaKYwNoq+OiYofeP7yWJjzqqY/BPRCMpWcu3NVigE7BvzYa\r\nDSl17IF5pPA508+7DqCx3UEHMchZxgiBYfk=\r\n=d+FF\r\n-----END PGP SIGNATURE-----\r\n"},"main":"cjs/index.js","type":"module","module":"esm/index.js","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":{"types":"./typings/index.d.ts","default":"./esm/index.js"},"default":{"types":"./typings/index.d.ts","default":"./esm/index.js"},"require":{"types":"./typings/index.d.cts","default":"./cjs/index.js"}},"./package.json":"./package.json"},"gitHead":"3393c60e38ac5011a2b3a169009c76fe925770d6","typings":"typings/index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"typings/index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.8.2-alpha-20230215085620-3393c60","@whatwg-node/server":"0.7.0-alpha-20230215085620-3393c60"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.3.0-alpha-20230215085620-3393c60_1676451403948_0.027103246780766144","host":"s3://npm-registry-packages"}},"0.3.0-alpha-20230215090500-a3d0322":{"name":"@whatwg-node/router","version":"0.3.0-alpha-20230215090500-a3d0322","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.3.0-alpha-20230215090500-a3d0322","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"318c3d9a4aabc5de27c64ca90230622977e5dac3","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.3.0-alpha-20230215090500-a3d0322.tgz","fileCount":15,"integrity":"sha512-39/cLDWQGkMT0uBxg/CiWGzSoCsTsRElOhJt6uoIKfmuRtZlusP2MOGCXTTigxhPdPZQGsKm73su9CZ9aQV9Ow==","signatures":[{"sig":"MEQCIFbrLlfGCycPSAKtsoXrq9H/giwncVF58s/eEP1ha/b9AiBATfVzsSlJohLpLUAVyreIzVAslu6JXZipLjPxyae7jQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20867,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj7KBVACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmqv2w//TPayLlDb8wpM50TSxzy19i7VK/JT5Sy0GcrgIz1eI97EToQ9\r\nwSu+stZ+S5jtSe8+kwVGiBfMPFQfgBSyXjVqwGOl1wzvbcDtqqsqVkIsJDMk\r\nMdIsZrDKs/yKEYBYof0uVIYHYVe+x+PUbVe6TQXdSgjh4AeoW0vGA4HLtznE\r\n3bt+JocMpyHTpDJHMQEYo1jv5or0eSE4U6iNAg5n9iZmne59JfIwnPpFIzGJ\r\nJnXqHKmbn9NQaB1pn3HfnliVqOcQmNGHr6rGk57nLrQhv0ioFU9uEhLGfp7P\r\nqPvxonbNzbpJ5QYRHNJnvlWqSW9S8sjUjFZC2SHktXhQyCZ15GTomVovpMmc\r\neXYxnFf4Ea7G5gkNhDCX/YR4WqNaunp/3kzqAp8U5m8F7Xs8JI9LNwQVE+rA\r\n0GCiIRiUZwRDpQRUUVko7mCGmG4mpK6yewuayECNZC1sK1z00QdDp3JxdD1Y\r\nSI1t+G2RLOaSPv7hgFVi1TNbXLiERNk+QcqWk+uYOutaQWg9G0d2NkT6VQtf\r\ndxotPqUY2u4AmxEl1EPJoCVtN6UW0heaJgVGtIIaJpOfG/dgIPuETMlPKPU9\r\n/cjDFj1tXxZUD1fYcItw2CoTU0z94nScpdEGBw+zPoukeOJLtMYsxRzQi89L\r\nV0+ydjQs6pJqhzsXWfa8G32nEuAyU2ebnRk=\r\n=1hNA\r\n-----END PGP SIGNATURE-----\r\n"},"main":"cjs/index.js","type":"module","module":"esm/index.js","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":{"types":"./typings/index.d.ts","default":"./esm/index.js"},"default":{"types":"./typings/index.d.ts","default":"./esm/index.js"},"require":{"types":"./typings/index.d.cts","default":"./cjs/index.js"}},"./package.json":"./package.json"},"gitHead":"a3d03223698bafdd705d4aa002efb5fad3fcd5cd","typings":"typings/index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"typings/index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.8.2-alpha-20230215090500-a3d0322","@whatwg-node/server":"0.7.0-alpha-20230215090500-a3d0322"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.3.0-alpha-20230215090500-a3d0322_1676451925086_0.13968039964658585","host":"s3://npm-registry-packages"}},"0.3.0-alpha-20230221104542-ee6a58b":{"name":"@whatwg-node/router","version":"0.3.0-alpha-20230221104542-ee6a58b","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.3.0-alpha-20230221104542-ee6a58b","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"38e5e53b63ebbda1a336d0ac7a7db2575c6a6cee","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.3.0-alpha-20230221104542-ee6a58b.tgz","fileCount":7,"integrity":"sha512-r++2phpxa9P+cZuoqQArnlgTdro9C+GYOFvR5IJ12Yx48jNKl28zNtGheHEi90CW4ghlC1a1ITPc+xb5shHtJg==","signatures":[{"sig":"MEYCIQCXlt4pJIHNB9x+l6PhnTt8uoskQrM8pCcDLhNV34cSDAIhALdJCRJDTuhxetCTq+BLKRB4o3NQLCRxh8e8OmPnY/9k","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18062,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj9KDpACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmp90Q/+OoylZWKxCqzaE3fS6GxqnOOS+vy084WALQP2RAV+AvaYBYQ3\r\nAMQRm1lVDQPIKdtTdiKoRe0Pmq62ya3ANlJdwprKPnX/gWYvCvRqWMhvxgSM\r\nZSshKJE40k3BEssjNn9hRu4YBnVCFJ0cCVMOQDxCJdsDX+fOElptGr4pcQ6B\r\nCoCZhTB9hBsPeRhcNAFVIQHyCbsqhkay7eqF5TemDXbueYufFSt0kzLJFj7c\r\nOczkPLqYqisOv58+jBZrQlx/wldLRaLDdGNwCt707/NwWOWDb8tsgR9gXu63\r\nPWQPOnogZhPLKjnRFGUPOOYOEISLzLIFbtKyn0gtbW4rj6dli/BwAxhJrQYw\r\n1Q3z8wpsWqgFz/ObpaaENfvWlGA3yB8xswgwKMEbu7LAY/ZFZ4BzvOViAkHe\r\nA7JQOIBLJ+lMA9VB1b35UXX0cnVWmeF95C3Qtv6rQo0u3IEAApAOp236ds/M\r\nBLrPBMR4tuQUfHbwUzdxPH29SWTTpPASM8VJL0i6glBe4feiweKgPo11ogjv\r\nY7gzPXMzxGH5nVC3k1V4oYghR0RNMH0cJc61twPexq2IE7SehXIkRcosCVr9\r\nIWjvf2NhGyASy5t5loOzL/N7ZFt2GfUIaU7x4CvZB8IABYB+U76OHEr6aSXO\r\n/Fx1OnaCXRAjrkWrYIaS/GklfKb+Ig5Ozd8=\r\n=4k1u\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"ee6a58b954aa66ca62b63c4fa81a3912e4c5f62f","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"^0.8.0","@whatwg-node/server":"0.7.0-alpha-20230221104542-ee6a58b"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.3.0-alpha-20230221104542-ee6a58b_1676976361386_0.04839003316841173","host":"s3://npm-registry-packages"}},"0.3.0-alpha-20230221104701-9322aaf":{"name":"@whatwg-node/router","version":"0.3.0-alpha-20230221104701-9322aaf","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.3.0-alpha-20230221104701-9322aaf","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"5cb1ef4e3aca017bc7a446b39843336311a83957","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.3.0-alpha-20230221104701-9322aaf.tgz","fileCount":7,"integrity":"sha512-7fslxOUHeH/y0sVXzoJ4rM8MynkmsP1ecgMqka/ObvVPPYHYv3BadtlHkYmZrIsedUASfFu/PT5CaHMG4vLf9w==","signatures":[{"sig":"MEQCIFy/q1/w2d4LzmPkYjRgufcqBfyOoKBXvom0nUoT3RemAiAXeEvNX1vA1akNRTDGHF/LPTiDfyFTWNElrS5Hh4zVtQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18062,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj9KE0ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmoh7BAAjN15qyWupTUpnctujFpSRN0QR7JXXGY6VqpNh/+7SYcwJkDP\r\n7wBCcVLRYWuBMpsDVZjx4SWGr9j60eauZAWNOZCDVqrkhPQZnQCetkdGec52\r\nMDCbuAB9pR+hGnMJOht45kbGIe2fiXpbYNU/wjTdDkZIandW5zNaIIT0nF9P\r\npk4HsOlTvWAiZtCIxM3A3ZMEBLbiMxHWbmJ5NhmV4FWpawfOm1P+9eHSWRsa\r\n1riILSyrd0pn4RebKaAgcJ3mwG1ztfXi4GBej63V8+EPmG6q8Kqd4P+ltCEZ\r\nGSHoKKdwOReKMqic8RhBjLc2TXQeihKByDFkw1Fic4Lg5izGqKTDkt+U/EKo\r\n43pnjnoWlfft6pvWoI7iiDEhkPT2CojKp+1u7mQm4GUutjAxI1lWH45yLBiA\r\nq8QuTOV6dJ5y2AS/9Q7/UDCBiE6wfxRbapm0TMKV0pd2G6dtnXgoetVX5wpv\r\nnN3bfpTcwH2kM4xKBNc89H2WnOuQx4NV8c28i+E4mbagfcKrG3kqllFLG36t\r\nkbQV6MOHglRwxDmxQRNN2du6BRQ0wGPQeRikZjJ6huXQyOVWUtk62gJyHdGO\r\nC4R7MwlltT1rRSKpa8TodtoxebrbZlp6zerOjWo0pGQHRW8h4FaMr/6JTXl8\r\nhigf2W8153mUkBb25xX14I7VfBf/ukGA5hw=\r\n=B2R9\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"9322aaf82d8f54d294956912d617746bb6ff743c","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"^0.8.0","@whatwg-node/server":"0.7.0-alpha-20230221104701-9322aaf"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.3.0-alpha-20230221104701-9322aaf_1676976436210_0.3253150409348744","host":"s3://npm-registry-packages"}},"0.3.0-alpha-20230221105155-000d664":{"name":"@whatwg-node/router","version":"0.3.0-alpha-20230221105155-000d664","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.3.0-alpha-20230221105155-000d664","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"b2324dea0dbe10978910ed028b185d6f45e94125","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.3.0-alpha-20230221105155-000d664.tgz","fileCount":7,"integrity":"sha512-7BAA1WM3Wc3nawi12r68MIGRp1trE3SuHujuTJ39zDQI/ROS8DvlR4qpIGKUs+WTuhLfXXQwrDdWIcf3G7HztQ==","signatures":[{"sig":"MEUCIEzpD48AnVOLo6L954DNquaWw01cn4RxvuqCjzJUygprAiEAnGsVeoMe1L+hzYN+Jqt7hZSs+u4n3TMDX+p63YZWsbs=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18062,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj9KJZACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpiBQ//bguwJQP/R8YyhhxGYZ/EnhEC5zYgIYK4i6b6u7JL0YTtRMru\r\nwa9zBm4ijna9Vrx6GSLpWiqRsR0rJKyRe+iLBuc6oIHHOdut2CNb0a97Y27o\r\nU2dIikkh2Jg6uW6wjqBZQ1Tk6rIin53UzBBq3NLLfpUDsiAGdaKoFNIAoyO0\r\nLE3hzRkUsODAxFo2GzJGeNwSExppdj7isxmMta9b8+RTh2MMHNYIRXi7+nKG\r\nQA/lb7Av9G/fCVHYa5fVWsHhcm1yCiLNjucDiRR5oGp1xRlaTU5JCcr38s2K\r\nTDvXOcsx6+21kL9t4Aoev8S3RSin+K1XAQHkuKAOlZVWNWcjtWVF9701V9b6\r\nNImmkNR3JTXk8mD0HuLhJTyuiYavuXklm5K8Pd7F+oKIfIhjVFQAuuDnNdnY\r\nnlfZ9/ksx7mTWVOGeag8l3xD4dJYR8Q4J7lbqUEwN8k2migPm+48WYCr7OMj\r\nfvYV2YecwkuAo8J9aJ9FM2WShRCSf5/0QLQGr69Z/9P6DLJMpVBAqjIPboQD\r\ni1fxJ+6TAoy3d6PfjbVXPHpKE0DW7Lnkqeq1lfrGgpZjlXiFPS2Oab/0OEbU\r\nslMt2jV5aYOys16rPp8OK2V/20pT9nskZUt8IS1IMNP6cO2P4TtkOdo1zyjM\r\n9en3utSdA7HCIkN7XiN7u9n3mTmxblLfjiE=\r\n=yW9j\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"000d664c55379d2216a624fa02397977c86a4351","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.1","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"^0.8.0","@whatwg-node/server":"0.7.0-alpha-20230221105155-000d664"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.3.0-alpha-20230221105155-000d664_1676976729638_0.7565411058111364","host":"s3://npm-registry-packages"}},"0.3.0-alpha-20230221105718-142b959":{"name":"@whatwg-node/router","version":"0.3.0-alpha-20230221105718-142b959","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.3.0-alpha-20230221105718-142b959","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"617650470cb8d68619c93f0eb80db9ff943ce6db","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.3.0-alpha-20230221105718-142b959.tgz","fileCount":7,"integrity":"sha512-GdRVGlaLvjg+yKhD9OhYDqAaIiGi9/nbr92LhlWPmmGrLaO+Qm0Bk7FA4DZBWWAYf53pMHsiZlgxVC591itdnw==","signatures":[{"sig":"MEUCIQCgusPKaBsxj6FQJwf4xn8kueeJyE30RH7z3xUciScQEwIgUA/ii9cAlxkcEMReyhtf8C9aeJjYMDvkJOpWRBPkzT4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18233,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj9KOfACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpxdBAAm34Md9Q6J2y3V5oNcJs4kM0IeshkXg/NZ4hl3hZO5RS4fShV\r\ni8gN/5vZU/hfBNAeuyKM9HBg6RRwLfzrqIFksj3i5y7/6Y2KXDe4Rd6rEzuO\r\n4WC0CwHEyWwLYAytEt3B+1fTClYwFWnWAouZWcFaYv+qDH9HpmzA2RUJVm6Q\r\nz/mbOS2mGnWaWz/HKVKYmE9DvC6bu4r27OP8EnbHxyo4bNRHFThg9Pjr8OhP\r\nRypTA8b9qLR1T54H7isrds2l0oLzE2C/mvw/I8iBObiGGSq4mZ9Ok33KyFyP\r\n1irM7TKBnjJzIrj4kgqe/0pwyrqdKrpoNyfnotPXRcLU8mxQCYMrUNxIL6s8\r\nTdFkdJL/HFsuGAqg+GXuQYNfgaY+avibEdkQM7YlNgVTMd3jFAqbgZelZV3M\r\ni5ze6NGybItiFItx5rfXy74hb/Jw1/7yWVF4ZCrDpkrWrGFElBqnN2eujfWv\r\n1UKhfO7HmuAK4xnIi9McGPFmjks1HlqxFNzeo/t5SqKBSJkQGvWjXT7fGdBJ\r\npAs6pz0pgi1L0/Y6UfTtz97CrXBheNThH7GF/Y+pqKCKKfV6qcc4U4pDM/85\r\np7Z8JUPYJ3u2uYbkRapdVKPVA+zypHAskFRYvn5c1pHXJejbiCcuak52MWJt\r\nNSW2F4r/Z354+07oU36v74uOM7l8hZE8wOw=\r\n=1kEn\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"142b9599672c8cf7e717b968b59131a7d298fc57","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"^0.8.0","@whatwg-node/server":"0.7.0-alpha-20230221105718-142b959"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.3.0-alpha-20230221105718-142b959_1676977055478_0.42638160381372936","host":"s3://npm-registry-packages"}},"0.3.0-alpha-20230221105958-43ce377":{"name":"@whatwg-node/router","version":"0.3.0-alpha-20230221105958-43ce377","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.3.0-alpha-20230221105958-43ce377","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"509171f69b629c71b0a36d865583880b8dabb705","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.3.0-alpha-20230221105958-43ce377.tgz","fileCount":7,"integrity":"sha512-KX90OkEeZVdmpgszDn/448LMnW4vwD1MECfPEN+Czt6bFX8bnZY6iBl9xQ3dtJfmtMU24MswzwRjCftNXsHIYA==","signatures":[{"sig":"MEYCIQDCvtIdEWQn2/HTaIXxYOqZjM+yM/ww8pyqATNVFq6lBAIhAPv8H1aWXSHayPY4bAirDRO/xh9ACWw4O6e6fehcgMAj","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18233,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj9KQ/ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmo/7hAAkxEhKto912oZSQxMMqwM7OomnLTSukafCVafkS3fID0DdDQs\r\nKw8A9MjgmyovXHRDCn4nyU56T0HNy/kEO6DwI55qt1J3X8/IVSIQk4nU2xxY\r\nayr+nBiY9JpF18aT6NaxdPSpTDX89/lO0pGupW21m5RIhJQEQV5PjsspgiM/\r\nUS9s37vDTM1eiKlOgzSeAqe1i7nwdHy3dnmTZjQA9pW51YADEXC3UtG2FCCb\r\nKHV4rEgXmGsFTATkCJbIiB1OLUOv+prOYmO7DfbDVg9RlAV3i2Dvc0oIVS0G\r\n0AliK4y89YzoZUsyMHusvHfJixKLHra5Jjy0HJL9vnzMas0Jc8VoxYxT+1Rv\r\nPXDnJK7eu14LJ7CiMQjPa+VkMkf8tvLVIWLZ6ET/LQeNOl8kngcYlAsCxoNr\r\n9oMWBXBBH8GmsEjw2+6DeXeUQB/LExM+p6YP85geVSRK/O7uK1+5xOsONhrA\r\nzOpIq68RcFdvfUZLcPbZUKZPpgQ8l46XKtVSoOHmQ2pgyQoQAA4AzqdswTvp\r\nygU32sOgCIv+mnmBhpPe/uOqoTOlPHKMjsgGJzylQjPTawhL1AIZ8tHvP9Uc\r\nYPR6AfCqB52rXsFNDTJOcMJ8W6ljzEqOowQY1IF5QyvuWdBF0TO9dJDfYH7Y\r\nRZf7Ep2+G/mKIKl9MwY94pUXvRjTKbXQL9w=\r\n=7RIH\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"43ce3774f75236de51108fc1992d20269ff86295","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"^0.8.0","@whatwg-node/server":"0.7.0-alpha-20230221105958-43ce377"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.3.0-alpha-20230221105958-43ce377_1676977215271_0.056968045947141555","host":"s3://npm-registry-packages"}},"0.3.0-rc-20230221114448-01b38cd":{"name":"@whatwg-node/router","version":"0.3.0-rc-20230221114448-01b38cd","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.3.0-rc-20230221114448-01b38cd","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"32419d991f144d8b39a7faa4804bd75b7bd0bbca","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.3.0-rc-20230221114448-01b38cd.tgz","fileCount":7,"integrity":"sha512-Z2hGU3O3EQD3d/8DLR+MNZn4ZdRU84QR+94rpRtmh5Y+Fb90kx7wjP0AVdisyMj9UiXs+s4cHXlNw4Sk2vBKtg==","signatures":[{"sig":"MEQCIBaV0YIFAfIqk9bwlW9JgMqdIyVI+qYZ77yQ3yuhlSuGAiA1z+W3Mp0NkaaxJyiMOhW+iYzqEUouGhlAVq/MqLVrXA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":17823,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj9K6+ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpvIw//fHHqwvVqZyL2nOCf98ulUfI1v/A6VZqLR6wnstaMMDsT7FNB\r\nYHNkwvqzgb253Bg5RospvfkL1ayeG66IO3fWca3X638cK8OdVaApRyVpHU5w\r\nMCYEH0VGCuujoUbsRX1wLh6SWQbVc9rqcGR2SFxJ74wHUPJm9hPA3HrPyAS6\r\nBxs/yxJLc6vp7Zpy+hvpxu0g9PZhHWCmrt2UtJNoHmy4clG02Xe1j7HTO28x\r\nMK0ULS1oAWN0AkyAfTWCP+7QdYDwnBO38oXNb2Cf4yBdzyZvT6ibhA1Qj9/a\r\n9lgqWf25ZFgENZc3NleRsm0y2AT8bLmH+rFRcl1eHuPMV226KHF2HyqyOLkv\r\ntES5SapLdIc1Se6h03MS0sDlGoV6kvSoQhbQOx1Ksa0l3ADSYehPBTpsgccx\r\nC9bjoAXqes8gLD/WVI1+PoeavfE3nA0iqLkXcXNNfAG+ILplrIvwiYvVvPd8\r\n3folm3u5586JQOqZ5957QzdNc/LdlM5oIe0apUGK+uiYKG7ORHQ6teKDV6lA\r\nKBX3JNMPQalzRnI61FfAYlc2Jb8bj3rdX4lynwSq4qfRHdBxwOmvzwhMKtiI\r\nrQFrRZx5uw/ZbPiz0BFSqulKNWaSw8IYwpXhh3lU39NaFsrUiHa17Xn9pPh/\r\no/r0FaDSqXCzgm/gO+RYirAH8su3J+PJc5U=\r\n=SL+4\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"01b38cd1c1ac2be96aecca08836e76664baf80c8","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"^0.8.0","@whatwg-node/server":"0.7.0-rc-20230221114448-01b38cd"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.3.0-rc-20230221114448-01b38cd_1676979902502_0.9401880461824266","host":"s3://npm-registry-packages"}},"0.3.0-alpha-20230221114745-06568a3":{"name":"@whatwg-node/router","version":"0.3.0-alpha-20230221114745-06568a3","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.3.0-alpha-20230221114745-06568a3","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"5da09b614e8de71b10c66ecb30312f6a0f2d8528","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.3.0-alpha-20230221114745-06568a3.tgz","fileCount":7,"integrity":"sha512-Lff5i0DmFOfs2zzI9i4QxzJPo7cG4AUwmjDomzCwTVpYQdiD0CUlaVSm1lxXAgbMdDazbI4kVwJpzLr2nmpecg==","signatures":[{"sig":"MEUCIC+CkWtN9cX2hyKJDBAU0r0Vg4brHeEQHz78K/hC2zWPAiEAuvRy4FNPdHRxoB1kYn1RfFHa8Hq8sSErTFFG51f5jpk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18233,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj9K92ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmrhow//cjGuuFtPPyY8hq9f/Pc7eKNwnbdW5AN+rplCtt4E1OYuHxPV\r\ntzO4afVNbLmV0xLBOK+v4twENU+OtZU67V3H8bHxlZZsPM4MOqoLwB8u82xy\r\n+4UzXKkgHurVtcuBz1OGmyEj6KI2a4NfCuwBOf13aOFXELNcxROxbMyAda5B\r\ncyynHjEgivTg74AmXYcNpWb/ajaPUD3GexEZ93WL4DY01oM/Kad7Ike2BgZe\r\nc708gFbsEFRyFeYUAZqOzVMj7Dd7j/5BJp9jkIPjM1Y+8y0YeVePMJ4aI08h\r\nh7NtEBevZUW5JKeJ9h/oQKLfYETzfQnKiYiuYZDkFr2dc517SwiyUSpD/Y8W\r\nrvrH2ottq8+44xTBwAmYsA8vyDNgQCj7Of7jm71CfhcLXZ8YAVvzm0CY1XWm\r\nQ1MfI36RtKqfJmzdV6LBgpBrjg7BuqbjHrC0jJlR81w6s+RYIzfFSridrT0f\r\nsl3NrdCQWUr3AeFVSD1dj9u+7OLuChS67sZttL/viEe0Nv1UKVrNZWZdvzpF\r\nWgVulEj7nOmZvH9MPGPr2pXTXIQgSgVa1vtBkhvAL4bgWqnkUGgkhPjAWbin\r\n6Sxr+zt/+Dd0nxehmG/DhiN8t14gD1OWPNSIm7y/458ABEM90G4mW0M6Kt+9\r\nmCpKWXZmm/6jXMWVE8zTeWhM5Wtcios1yXU=\r\n=f1Xi\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"06568a3724a58186d809a1f14e062f3ecfcc8f05","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.1","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"^0.8.0","@whatwg-node/server":"0.7.0-alpha-20230221114745-06568a3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.3.0-alpha-20230221114745-06568a3_1676980086023_0.844246949324716","host":"s3://npm-registry-packages"}},"0.3.0-alpha-20230221115149-9b16d88":{"name":"@whatwg-node/router","version":"0.3.0-alpha-20230221115149-9b16d88","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.3.0-alpha-20230221115149-9b16d88","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"76bf7bf9b0e8c7b9444442d9ab918157672376fb","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.3.0-alpha-20230221115149-9b16d88.tgz","fileCount":7,"integrity":"sha512-hdM3+PW0vPZepT+9BMYU8++JNdTQ78/L1C08T1U8ZWmK8LG3ULn/fnL3yGdP3qB27uw3zf/+i1jZHrzRNzJYvQ==","signatures":[{"sig":"MEUCIAzWQZzb6cRgtaLYS4ZqV/DmfflcE8HSm4oK3d38+E0kAiEAgzJxI7MP/DFVaefUxJjjqeB30Pzm7f6/r14etGySn2A=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18233,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj9LBmACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoWDw//S5IgtlXYyPXUxs8R6YCr9G7ZBwfDkLviQ4CQ6EYXdhK0pBxO\r\nak2dERg9T1JGiroiYejaWLcjoVxkY1a92/Z/KUwkATYI8ITuqv0maSTa5Q7T\r\ny0B6bW6xTgHbh86E8daCCFdDFJOqpZaEpJryxMBWX9ZuaONPRttdlayt8cDa\r\nmjllZwZy7A1eOFFQuc7OKobZhG6SEUsIXg3s2cBkERa7iymlyycfFKQ9V3Rb\r\nCOqllmVTodJqH8lp7t06AQX7MY7fCKtsKVjX0kpgj4Wlh2GVo/NbP5HJQUec\r\nF4G2FQZQLbJALQZrYGiDtAyscwLLvpMhdRcm0qUlln8ASukYdzx1vXxsHFBh\r\n/jlzfe7o0YoszyShWpGH21SrTKYzKbSrVBK5+mL7oC/mmki2xiYNmgRTHUYr\r\n28CJc4+3g8FHG5V4TDNielYs+FuB7gt3fcZG1pR2LZ0ii2BvBVh6CkrH0jtL\r\nAcV1nLbrRkXAs+ZGpssyeS3HRsfkUgpf0G2E/vecn+xRA80LsqTL2CaYIfLW\r\nYuQ0t37S871/5UjgaArr3jzvUKQGJzMYqeRnTBE/DZVOiYB8gi7UmC/U7JE7\r\n97q3Dyo8PbzWykyuIt0uUKFsYjfAlTd99xNoT53XoFuNvxw078+q3dskugmt\r\n0uXq6ynQFYL63Qch06Lx1COj5diJAPvDxcE=\r\n=f72u\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"9b16d88e7d4495250f2cd502da23653e38aab1e5","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"^0.8.0","@whatwg-node/server":"0.7.0-alpha-20230221115149-9b16d88"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.3.0-alpha-20230221115149-9b16d88_1676980326126_0.045774064479494836","host":"s3://npm-registry-packages"}},"0.3.0-rc-20230221115504-d14aa5a":{"name":"@whatwg-node/router","version":"0.3.0-rc-20230221115504-d14aa5a","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.3.0-rc-20230221115504-d14aa5a","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"9240920de88246fb4e6e03bc8bfe7716d1b1e105","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.3.0-rc-20230221115504-d14aa5a.tgz","fileCount":7,"integrity":"sha512-0EDGfcQveIh0IPWh2jPLsmIYEQKYdX8NMGkkeiy5PFUzq2d43RYtVBuB049xlb9/CFoVkLiHueB170YtRSJRNw==","signatures":[{"sig":"MEUCIQC0fyOrBGTUEmMAsNQXpZ3ORjL6JKytjWs0pUUx3gDTUgIgCpJDejHStMwUZzmHHqCfXYAuDViaCk/qIGZJafCHde8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18227,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj9LEmACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmovQRAAnCK8mQYJVf1noJXFkJIhYS0crV9tl+uTi4/RaAs688ACeUXm\r\nMAWq/hZHy9Jqu9TXjemz1U9U7+k3r8qbipbamrND8Z/8vZtuo5KlJ23DcMGX\r\nTgtp/7fP20/4wOpH8M9M4JJfMFRg/Ui9lCVdUwvfwh5wL+fuvtvgFzG3nqV4\r\napx7PZobwpzHZQ01bAbEValdOJg8BxDbCMImDlC/syLHXiemvHbOALm3OeXB\r\n83/TQGLYn8lkmO9TWU27aqEHCfLa6ioptbvyhP1aR2jIVMZ6+14YibIfpH2c\r\nGWMA9yWkKfdr+u3mCFTq3X6NamGHb6r9VZ5Iry6z6PG+wa/ALNZs21yQta3R\r\nK1btRnU3Dcb/eI+U94PBQm4FZICUd/HvI77vRARt6qQ8BAu+2X2QvRhUyvGM\r\nS3Rw5mSELUAdFxGvKd6dSIgU9plS1HCOm3+E1W/JXnrpynTSnc+anvk7cEfX\r\nIE1+QykRxqTYGlVWAkJrhhIloeFADu2gK//c09LfbKj+gLgugT5eff8g0Eys\r\n1gG/TmEWggUiSIBHCUNQPBXxAaM0pwO7Y0t7zNc6L0yq3Cr9xX9ye12QP/vh\r\nTwQDbIsNsznGHUUgMMoQ4+pTaK8+GTEGtJv2VdMcVMV6keD2sQcRrDuatOWL\r\njuvldo9eAG1KOBBvlkiv9yG6Q7sy9D2M/XE=\r\n=ALFS\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"d14aa5a0ea26196251ebcdebe1174389f3fd3e0a","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"^0.8.0","@whatwg-node/server":"0.7.0-rc-20230221115504-d14aa5a"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.3.0-rc-20230221115504-d14aa5a_1676980518338_0.503016015652382","host":"s3://npm-registry-packages"}},"0.3.0-rc-20230221120256-dec7b50":{"name":"@whatwg-node/router","version":"0.3.0-rc-20230221120256-dec7b50","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.3.0-rc-20230221120256-dec7b50","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"a1b9229471de0a03301bab4c157be30fc9409698","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.3.0-rc-20230221120256-dec7b50.tgz","fileCount":7,"integrity":"sha512-zweH8LHeyyItzZGHWB5RfMrxkoftYfM0wBnnz8HLCm1cOCuLiiw7fuCQHkhekxyw9OvWUl1mI9PCtAC1BPKrxw==","signatures":[{"sig":"MEUCIQCyHj/8eWju4fg6sIoFiJD8j5FWH6XSJQh+gWLYz/u18QIgMeuHmXsBPPxzWaRLb8XoCo33y8YzpgJ1np9oQ4J2hNM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18227,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj9LL+ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmrl/w/9G8U0/VhSA5CQICeTzxYKHiMraTmB/E4J8oRRF0+YVcd2/XmV\r\n3d8+eVr5FaGz3F+skb5FwcPtK85eNUd9ssXahQKXd9+6Ij4DQHPTx8OdJM3/\r\nui1jgTXBccVg8RfyQ0BOF4Hba1+g1CFmY8EonkaXK43A7XbbbPQ0y/fQDMtB\r\n1EAYT3o5VjZmmihPhvsiZ3YcRFm4wCMyKlC0Y+Dduhiuub38UyZtQxdc/Kvc\r\nX4lgYbymGOY2Spx5tp+ZeThHHXnoDcv0ouaHrUVJJWzIRHsC/3paRY/L0zDZ\r\n2UwloN/8L/Zc++aAvByU8daNI5MXUv8uAz7lFeSku+K5JyQAFuH2uWJ8JoOI\r\nu94DoiPW6eU8hVz1xb66KQJjY8zkTCiHLMO99/f1tMla7aSsRxzzZQBPBK+V\r\nw/cX6zIc+QwWYqstexLLbKSHoTQ35LP/67jM6zr6w6ry9NvkXIk6EgOkrZv8\r\nxJ786mt+JiliRsOXq4dMVT6koGDvtI6XcA+mbwI0s8Ka33g7daXNGK01uLGK\r\n20AZWcpw/CPkoTTfVqMI/i7JlNawN0x2yTLCiRslZGEbWpaWFJeqg+MDzogo\r\nRqQX706hN3m0Fen9+bcx1/bv4exguwe6gYrZ+h/SyAXPEh9kQ2s4bGMDIpAW\r\nNJs0fOb6lk34yOAHrUk3Bd7LMbqr5W2emFg=\r\n=c0vH\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"dec7b508fee56b03cfa514f30096584dcd800ec8","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"^0.8.0","@whatwg-node/server":"0.7.0-rc-20230221120256-dec7b50"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.3.0-rc-20230221120256-dec7b50_1676980990087_0.28870526739564917","host":"s3://npm-registry-packages"}},"0.3.0-rc-20230221120455-b9ab400":{"name":"@whatwg-node/router","version":"0.3.0-rc-20230221120455-b9ab400","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.3.0-rc-20230221120455-b9ab400","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"3074f9184fc208df31c19d56c8d8347fc7254311","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.3.0-rc-20230221120455-b9ab400.tgz","fileCount":7,"integrity":"sha512-hXUEBtC9Npwbja99cPhWPifyun2Uq7CEw81zzNCiYsprfL88LpZrIHCNdpxL7DiyoGdbtcRbS8DAsxNUnAYTlw==","signatures":[{"sig":"MEUCIHbRLlddWa407UuFc/GDQcYoQvTWVkHg+MnzP3tqLwo7AiEAghVmF/GtQTk4lgex98zMSBWyrNYw54sYYvvFJCo9Q1I=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18227,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj9LN3ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqlEg/+M4L6tqzO6PFKc3Tj9FUqyNeCzHB7nTwnsxUp6RLzVs7I+j5d\r\nQN57KMWWcmkrBiod+9yRUQddEJY4ibK9n9CPoZGeIEG7SYkUJ6f5uJAJClor\r\nC03bsFZmYwirfkewLXBYZjPcDelGo22J+CciitIhqTewF/+9VKJ0pL7PB/wG\r\n77ysn4xYSG9/yVq2nRRc0sGxYL0WG0EUmqMJ7wFx+jqgdLPtrpRiNdOER3up\r\ngloGJWr5ZTuCwYJVnub4nCXn4ETabSiQweem01KQSJcBPZhhZ229RVD+hShg\r\nJGTuu20yYW2/7AtO66AI0oc32hnQv4dj0r0Xsh4FkEDoFnhSEkmk+i1l2IXN\r\nFP4fA6NTu38efuoWaLqESziI5mHOjnctk23oSGICZ+ro7/U1MODy3Mys/IMj\r\n9p3uamNCiMbFEBO4QDiDRxITPki6cA/iYQHlmxeB8+1lLuUv82H8Z+AiQYJ2\r\nX192BzYzZeZTFHL62MM76v3bkB4WtToMIbZMNNU0IRRA9nVpW6hdvgC7lrf7\r\ndAa2q63AsfJa+IMYRDVn1G+04Cx1uZ1MKfGrhemH912I4DKZuPDhqdf7oYEo\r\n0Nnr4oX0cTHDtzSioqClzlMUt2B90HuCjVU8K0lKg/jLvPAxikUReNq19iiH\r\n6f/eteLUwBydZRfgjhGviUNv0kMpy3GKdNA=\r\n=AZLb\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"b9ab400b065b7d959110987a49ee95bbbbe4f536","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"^0.8.0","@whatwg-node/server":"0.7.0-rc-20230221120455-b9ab400"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.3.0-rc-20230221120455-b9ab400_1676981111541_0.12089437756026156","host":"s3://npm-registry-packages"}},"0.3.1-rc-20230221120759-2a26ab6":{"name":"@whatwg-node/router","version":"0.3.1-rc-20230221120759-2a26ab6","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.3.1-rc-20230221120759-2a26ab6","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"c43422cf31d348d1ccdfb20f13a9ce7f08b5aace","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.3.1-rc-20230221120759-2a26ab6.tgz","fileCount":7,"integrity":"sha512-yThbbGANlUtRekgobtmaOMvUX0gEiB/tYQOMPuGheYxCrlLcpGKX3IaHOR62Kj0wOmnTL0/86oRkVSn3TDAN+w==","signatures":[{"sig":"MEQCID4jNdGHkJxQLwP/py+Lx7Q31r/5rasuIk4WsgEGVb5fAiBkyx/0GRnNspsxpqrfOR7eNSgFnjnTvuCN5aUhig4B7Q==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18202,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj9LQuACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqYBBAAh17JUKM8edIlmbtMwNEw3OKDc+7oltJvWgK+dnY+iAic30TI\r\nHpUA0PYnioKBhIItYj+pR4MoO9Hz9/0rxqWyszGulNV2x3tL0jhO2lwS9gVs\r\n7yIkgyAmwzEz7yQYmIPduIUghKohl+8lqxLDy21IFRtu5RPXCbjpjg4IqdLM\r\nNw5zSri/CH9CAxT3dlUgE5+3x1GddXmHxpTnkYE8kPrNWgaI947FEmjg3fTU\r\njUBUEeGndxJ5QQiod8nNMJBHQKSN1aZpB6h9wrntyWH+GvOREzwj+12yZSNu\r\n0csbMgfyfmGEh8es0abNlLTVpOy0uTbErhWBMfNkSxzlXIm3rDo/AzUt9f6/\r\nTqptSpbYRyI8f9IRBCT+qadh2qq3NRaQmqiUOghvNDUxLpNLbDwIrufRIiEd\r\nTBm+fctG321wnDmWKamIA1cih8r0oTk9l0Skxb3T9eUMTkm9YKew6BSIFg0B\r\nCfk8HNRegPvrDeKJRHh79+4WzXt/cYBNm8gE8GglxBWD8vOTjH5kgaRAJfDe\r\nzASLrCaZrAKJMPslwIWyo0uVHjvSsMkKyYC1ChWExYq2LnG3p2+CuQUDZ4MY\r\nNEGZKejFpyBsV5EBbP7WkZ+uF91m9zUHu8e1WeZd/p7iiZk3X50j0BK1SHUz\r\nPoaxfvaMytm8dAf1p64paYLCF0uFdp28r4w=\r\n=xw+C\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"2a26ab68dbd705379a58991b784efd935c4a31dd","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"^0.8.0","@whatwg-node/server":"^0.7.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.3.1-rc-20230221120759-2a26ab6_1676981294108_0.6062174986391791","host":"s3://npm-registry-packages"}},"0.3.0":{"name":"@whatwg-node/router","version":"0.3.0","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.3.0","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"70002afb4a8ef4b544894c8344933e9559c0ba40","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.3.0.tgz","fileCount":7,"integrity":"sha512-d7qzIvbbBm6d0VpJGlRbp/G9PTLRCcpS9fRNnfjE87ZbWbB05vBzHkaUyOs2zaTny/GPuBzrEY2QewoLj4+5JQ==","signatures":[{"sig":"MEQCIAZbm62iCDoO8UgQyogP98iHkaREOzp6mRFS9+ZEHJlQAiBOrekDJJVUiPwDcjtDtet3Dv8H+z+tViqsfvZpMnMN2Q==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18176,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj9LSgACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmrv7Q//dgVDr9fAb/4LTEkFK4Cg/ZrFJbCM9jbQBWV2fluZd2ZDcdgi\r\nVOOX6CCumq76iLmXWXu/zXdmo4hDrYhWhSrESrsYHzOX9DSGRDybrQLMgah0\r\n9HWK+urr54YBPcTzvbhR8RujCP3Epcdze3xZMjyBoqT6showzesCtcbxfMuN\r\n43rS9wa4Sm6/7F13agusqznMoFc2vYv8a/TkAnRjl+MMdHOpXruWkEGIEP3a\r\nR38xwK9TTx96Ly7ZXDf+gXXTnJ4aP0qLmcfB/7c7GgyqRH2Sz8U/LkFZpDfE\r\nLpI3SNMgFlVXWjMgewX7Nxyltov+FmlXn3NR1pC7FFg7ooYCVRGlPfsoQ7/A\r\nRPN1Dc9x9XzHFMUyEHwYyQ2qo9OkB8DPL+p0A5ccPcTm5OLJU9diw4Ye59eq\r\no9Xf94GaiVhXnUk2ZsM/dzbVDMlZ3MMRV6UIxG8HB2AOikuqH6p8l/5OZjXe\r\n6+RJ6g9+xrOykShCXzc6Wa4IOjgfkF8y4TK92MCUClhiC6h+hkmC4lqBaOoT\r\nLHRjUaUdQvjmoAycNo818wYYzc8qgdRCxqqQ0WXWSiSZ1vlJpERhqAV5Ovkn\r\nTo5Mf1T12StKEwlOXWpfJgRck1gSxY7mK0g5dHaI7HyxOKDa3WWSZvONXcG4\r\nRr+83UoEsFF/IsA1h2djMUK0Z1lJIwK7kTk=\r\n=XrCw\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"8c2d9176bb48f4fdcc33ee270d01058e218592b4","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"^0.8.0","@whatwg-node/server":"^0.7.0"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/router_0.3.0_1676981408113_0.5247979153241449","host":"s3://npm-registry-packages"}},"0.4.0-alpha-20230222104450-ef9edfd":{"name":"@whatwg-node/router","version":"0.4.0-alpha-20230222104450-ef9edfd","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.4.0-alpha-20230222104450-ef9edfd","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"dde60d25e450bb69be66a5cee675257a9a31741d","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.4.0-alpha-20230222104450-ef9edfd.tgz","fileCount":7,"integrity":"sha512-ss9ZGBhok4UuDf0i70JxjhKsPjMAu6qHuw0gFq+ytcaujBa9TJ9DXrcHVZj0wBRUpu+LPHLa2P32SP3OofkNVw==","signatures":[{"sig":"MEUCIAUpNB4kCB2GBYeyQog1ZBith8kNAigDFhJ65xGv8uGwAiEAvjUEsq8S/aAZ0SCn/QQdGiPoC7KlM7lbGhuahiHS15M=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19308,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj9fIwACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmo26Q//Zu19indtZMcdqAGXJA7JDrdPcT32YARIjX08KKi2tyNrQMqI\r\naxcBCL2zad6vqEEJm5LvLWMeejlN3VryJ0w7R+WSX6GuurpJ3dXb+/2vBzSu\r\nlsi/HMiJGb0SWIjyzjiYwoGPxo/fAEN6XkKRL6pgY4CgyusYzQ/yYw+sVOYV\r\nk/HLv7MVFMu2Pc7eNRrIRlxPtrzLQwv2GQRgC2IukKNWJNiN5AxrmgAS1+nd\r\nXcwyxxTWj4mvc8A+LT5NbtIEVtJxXhPUtcsDebIuRooHkjzOK3USGMZw7Z8t\r\ndFc53psNF0E1m0g/DLuPkCw7kQkighMWXIGes5WtaJ8R5d706hQ3cZ9WAZuK\r\nEg0+g51rzjRq/oZUZBREn5cRA1Yyw0bUo4Mx80TdO8mBaEE/mv1NnsXM8bfb\r\nZYxirK80Dd5g0gPd7GvtC1UbyjXNK8qhj/SWZ7eGdhbDID7N2m1BVwZOyopk\r\neL0dNfVR/QyPUm8tsPA68run9iSrWddqgMOQFmSuiq2jkOJoBqfkhB1cTpBi\r\nBR6xYTxiSX7wQnmkooX+EmiS9jWOLar4FJte7YUp7LTzoZ1FIkPGUbDzjFUB\r\n9OPUq6VKzOjusCWneMrEDNt3wVtEqrfVpMqoon+7sNYav0icVnN6YEs+LO8a\r\nmdv5V7XYepmFlvpvqmJNVmM6y3iGX+wcwjU=\r\n=bmUM\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"ef9edfd3d89fd06e6073e8d5310c778108233c32","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"^0.8.0","@whatwg-node/server":"^0.7.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.4.0-alpha-20230222104450-ef9edfd_1677062704410_0.8010636683275416","host":"s3://npm-registry-packages"}},"0.4.0-alpha-20230222104536-27888c7":{"name":"@whatwg-node/router","version":"0.4.0-alpha-20230222104536-27888c7","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.4.0-alpha-20230222104536-27888c7","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"2718c5ef8d80cbbcd154595f75d9f096529f220c","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.4.0-alpha-20230222104536-27888c7.tgz","fileCount":7,"integrity":"sha512-MJ7VeCm7Jpo6kyH9jxCp3WVO/Ng8g+yLmOTScTh59V1viDZUculivVy1x0kahjlMv+NdMc5HwPt68C+8/IEmSg==","signatures":[{"sig":"MEUCIBwbVSyWzAPD3rFJzVJQvu2SO3ExxOX+qiZBYYKWaSO3AiEAgX+HsdSulqw2flrKAa6UAsPwrKrgcKbylSFDeXqW/1o=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19308,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj9fJpACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqCQxAAoXJM6fIuY+UEYtRNjy8B8Arz7F962RtqLXsjk3BtTktZ4Ils\r\n0VGXAvsqRT8Nkq9Bc35u2g6g3uPs7Mh6qTnrP1a+T065h16J12y+zOxWFuHO\r\n/uqpQirfduj2FC/CE4ojkCgf7eAlvn0HU7LAMsXspat2b9/IMV9969DiH8Ce\r\n8v3NqDtIAmi6RPFmBqK5gE00QQEoGuHtlHKREA5Jh9ZhBy1HJBI8BqWYasPx\r\n93k4Y57X0AOF5ELVJNHF84P4WBnuVBBTYNgpsrCpa4jzNDhxS4GIRguBF6FA\r\nL4W9qjKrq/nXUT+BVG3hvpCZzY/oNQuYVOd3zlg3aWN/kTB4t1dZlUPwq+R6\r\ntxci7gPFBT84EPffcOC2+GwWUoiNV5SbcPWAa/uMDVlzav/7QG726eG9RUDx\r\n6Iky7HTREMgK+ghU4HsCJ6ClTIKXgxVCUBpuvPxMGKHiKPS+79VKPdgHOFmr\r\nz9uBNGSVA2JpfMaTVOVJnslDre+5wTIHqbXhN18ppmn82V3IJLOfnMH7uMjB\r\nds3pc1YH2VPgFBjA71ZjPwNJm8PnHDFadxKxL63fKaa4SYDHmSJs1XMt9kEZ\r\n7O8WGEYir/+j+aYamT5VSxWfceNHjGQXjS5/yaFm+EyqIOBedu0Lh9mObdi0\r\nCCt+do0/g0zZFvrXOpD4r4hzfCei75MazUM=\r\n=bdZ/\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"27888c7f0e50939f3a8a09af67e010532f2fc8ea","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"^0.8.0","@whatwg-node/server":"^0.7.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.4.0-alpha-20230222104536-27888c7_1677062761041_0.25744885752200797","host":"s3://npm-registry-packages"}},"0.4.0-alpha-20230222122711-75f542a":{"name":"@whatwg-node/router","version":"0.4.0-alpha-20230222122711-75f542a","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.4.0-alpha-20230222122711-75f542a","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"f219ef64ab277299c41becaf68d276ff3f1d453d","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.4.0-alpha-20230222122711-75f542a.tgz","fileCount":7,"integrity":"sha512-av2cOpNNlinGP0uL8I2q9Uk+0yyjpaj3StdbQTg+3Lrb2Bh2IHRYGbpMURFGfoa/KZ39qncGBP0bcMy4D2AI8g==","signatures":[{"sig":"MEUCIQCtOXRsZjNk7+cVmWuF/IrxYxsC0SgAFH7nwB1bQDs47QIgHT/BZHAX4P3SYJuHnKHjb6iqJJ9GWADquVvUrhlj/Ko=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19221,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj9gouACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmr10A/+MrrMScjjQnsVsUSObpwSY1sTszCDzMfh+qfweent3NDmqB99\r\n+91e32vI68YPFNu4eF4z1awSBb9fvOvgU90xpLVIl6sbWb9Vum2JjjJ02YIS\r\nBpeplylb3ar2dzH0kujz03oP1bbtjren6QWTiB4O2WoghL16N2cVnHI9kFB3\r\noRLl1VyIWoKxl5m+Z56HLeAviahjdZZ7pL7L63HyuQLTgJ2o8cTbfT+VXCwO\r\n+O5ekLMql5pCLhSt0btyQl0Sg3/ybr0vBNJJG2orlxHAAQtpa5Mdht8cEwEX\r\no8Wtjg5OkhZLgv8NQGyUPUbX3/4UVImH0Ef1IbVFINraaTMM1g/MeoXG1mi2\r\nyM4KG8icdhZc5nAuietEwINYBaghsfpZ4Fgf+3DS3vG0VDWir+vT+3BFMtiH\r\nBIs3DwBOfeOzh/UW7Wz/3/LEia8YdIwrFrIicAtY9SwQYEqSTsf7N3b06+Xf\r\nwpCvP20pTdM34l0aopzzYhM8KFN+WJzl9gsg9LCHEV749EYASnngaOOPi4JC\r\nAUYoYxBM7k4jne6hPWu1lSQ8VLUfXYRc5TNxgUFSaKCNZ6/XwEUtmOTr0NuX\r\n3gcf1v6VGlhod9E33ROGAC6YSHIRhbImfK5iZcudg5KkqXusbXkW0cjBq46a\r\nRJKMnk/arLcW/bjTVDeVKeWlIc5UC/mdpgA=\r\n=95yq\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"75f542af19be1a8426e84e514becb2cf88c73d45","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.8.2-alpha-20230222122711-75f542a","@whatwg-node/server":"^0.7.0","@whatwg-node/typed-fetch":"0.0.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.4.0-alpha-20230222122711-75f542a_1677068846144_0.8129862443652012","host":"s3://npm-registry-packages"}},"0.4.0-alpha-20230222122922-afb98ac":{"name":"@whatwg-node/router","version":"0.4.0-alpha-20230222122922-afb98ac","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.4.0-alpha-20230222122922-afb98ac","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"036a06e36b9bb40aa235595c9533d59fea1e132a","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.4.0-alpha-20230222122922-afb98ac.tgz","fileCount":7,"integrity":"sha512-BN31dbVTfJz5KawiL10aXNNUpc7WahjdqCjK/5LKLHfp9DQySVDYrDLWDHUG9YWClZB1YJHiRqV2FOrQHLcPAg==","signatures":[{"sig":"MEUCIBpnEDGRXQBNQ9RxbZWWYIYN9wBrQOQjVRRaqEbOv71yAiEAm6uhXAN1r1XZX4FqM09JCgy/iHGEp5Rz8lXQ3uonn78=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19250,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj9gqxACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmr1LQ//aJo5iTcRe0vVgHdfHNPHOeqc9kL8/8dGM/l1krSI3P0YebVE\r\nvp9NdAtKfKwX2eZwNEXzCaMO5Yuv+1Qg4z3RdkGFxbG3F3fYAIyzCRtqhZWG\r\ngfa2S++CHheM2GbJ28aeThV/F4fCrXF1fJGxEBtRFhcntltx5FnJP1zW/V6C\r\nUbg7eO4x2OSBC0H/3xZJN0r0/4sCoZ+MZARQxx4vKXFwt+NI147sjQmhz8sX\r\nXRpSd6dnWSdPXDLrKGBBSAVgY4t6NjcmvqTLSU5RLbdAqXggruUsBrmwXssG\r\n590RSfIqvWp1Zs2xOFQmztv/yBk3tj+pqIC6tK7M3rB6lxZnUqs+vc7W9FDM\r\nfp3lgd+fO7OIYthIRY6VEuJg3OMnPnApwJomMlWg383qdOwroj2SxnwJlSjY\r\nCytmXOOYhL7vb6Q7OdxBzU00v2zB/gMXd1nJ8d8lGmpYb08BOlGUGulO0Y+8\r\nXYWMTFXClhXS6NSw32snv1IA2lhRPvHYzuL79c22s3H6xYMv6bgfVJW4y+2q\r\ne+X4o0FjN8d9NneuFS/qj01gEOH4mX/Zt6nG3JTIdw8/kwejYeOSigKJT4RX\r\njLia0w8ZAYpy40sVbHVFDhcwmxrFsYlS4Mi1/OLeJfQ38FoIFd1ffHwgwT47\r\n++KSZmNVhHRPUL12fuxSl9Jr3tbIL2t+Zb4=\r\n=oVXw\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"afb98ac580ebe0a89618c128c2eb8fb9a7b52584","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.1","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.8.2-alpha-20230222122922-afb98ac","@whatwg-node/server":"^0.7.0","@whatwg-node/typed-fetch":"0.0.1-alpha-20230222122922-afb98ac"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.4.0-alpha-20230222122922-afb98ac_1677068977118_0.7048711466074216","host":"s3://npm-registry-packages"}},"0.4.0-rc-20230222123132-90e12ec":{"name":"@whatwg-node/router","version":"0.4.0-rc-20230222123132-90e12ec","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.4.0-rc-20230222123132-90e12ec","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"8d7f4808c5afc1061b4431b8c98d95271f493f41","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.4.0-rc-20230222123132-90e12ec.tgz","fileCount":7,"integrity":"sha512-/+peKIb/O/3VUOciVrMyg87oqMhd9+qosNS2r5i5PUJ7Xw+MkaGk2ivmxpznUFS9KkY88v+N7+EcHvJYrO+DqA==","signatures":[{"sig":"MEYCIQCsK+zcSxwaoWxQr2bxYGXilm182uc2w6LaubHBl0JwEwIhAMIdRg5Tj60hnFTsNlt+4MVWjiEdt0WiU671bFRH9Dc0","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19305,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj9gszACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmq8LBAAmsiBxPmbVkZGea5DGhieaCA+oGCz+LQcQEQGsK6ZmZtlIybH\r\nmChsenjh56n2LZ4YrI0fZk3WB7sxnJchswjN3sJgUGezIX1seWlswWgCYwkS\r\nP7nPcFcroSW9DpbuH4hGeJtd5MX4DElUuhM2e4rpSq+MXu/xNZgGDI5vb+NS\r\n5fYJ2+8RNbvjow8mHp6+xnjPzkmVgSzTEVQ3DxpWiq1mRntb9E5pU/BBhDLO\r\nWpSzyrWjSSRIcJDJs+fN4i65HmWZObEGrX4A9lkrzdqR+mJQX7qJC3hhfZam\r\ngGYZ6dU01vV8hlPc+F+4RzF4mnGVstpDg9p+t3j5sGJOUI2XSZcRn/+d08s8\r\n3lBix6IMqAd0nip3PlX7um1aKZmX88dcYBK4Uk3Vk0hLxU93tprma2oG098m\r\nE+aagHYEyoG+BYp1iIr1RBMFgBzkpNYVkrm1wnX3+dRyWexaQ8uxtEVffAur\r\nnoP4+/0thTrCfOo4BeG7e6a7IiDjABISrGH7yFCrttgiJzU4EjrCjnDswJnr\r\nNfe+DoEjknRyIcTg2wmKH5EA+GRwmfyRxcY4jHYSOE/86iUagvSnJlTWUWBj\r\nrCo7jrhCgKU4rcKotYsc5OVaodfwNa40lehVD7TYIpaKYZNgeGqvxWoy+kDw\r\n8YCeFE2azVX1oXZpd+Z6H5fTe5WARoeCVQ0=\r\n=3ERN\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"90e12eca57ba6e38c24aea2081fae73f428e1b11","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"^0.8.0","@whatwg-node/server":"^0.7.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.4.0-rc-20230222123132-90e12ec_1677069107483_0.6779405455548049","host":"s3://npm-registry-packages"}},"0.4.0-alpha-20230222123356-1c93bff":{"name":"@whatwg-node/router","version":"0.4.0-alpha-20230222123356-1c93bff","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.4.0-alpha-20230222123356-1c93bff","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"1f870bb9d836aedfbf58c797aba9e0471578bb2a","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.4.0-alpha-20230222123356-1c93bff.tgz","fileCount":7,"integrity":"sha512-62nUU5GuTN8aGkPhyPJHvAOjRUwvqjrCP8KJ/KFW8D2yfpMM+rHFc5jjqsx89aKp7zVPBDss++H45Ecblrylcg==","signatures":[{"sig":"MEUCIQC5J72ekU9yn3KSLzNls9+Cx2Un2hGgt0xrz0YajvAIaAIgawkn+AJ7LSDunUWWxKXNNpsPGhaY/YdVU1diowXf0S0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20412,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj9gvFACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqkhRAAkIUFdNsiNEFaZJtl/1ENse3CKPyQ4Fe88dVXpr3UM4FK2PA8\r\nge/3q/qV1gNQlxA9z7IwVPXxFZnxFlYbEipCIW6nfQh2BE1ZPOGnKP1tEcxu\r\n04di3sUgM0sCmIKaISaTQnGhUSfnJLoYr+LbxiIBGnrhjc6GlnhJxVSoPmn9\r\n12qpBnu7WxS4glO+SughsOHGorjdt7BSlADd6EobVYkZ5cnDoz1Ukx4U7GZ9\r\nNiGw2ZFvpCdUNYqucT7TJoc1loHeP7YGzPhjt3nb9ocyYjeTcysg8x1AbSdt\r\ndpP1rmjduH1aZOrK1KhmUBpaWQ5q0eiJp9tYSSyIuUoJnryPmRnpJymk8GD4\r\n4NJ/iVC0wz8r2SINxq1QVWrIGZnfDO9zBOCbwIjsR0jYYMwphfdPIvSHBzkH\r\np6fKjNE+/NMZ2ZsoFK1hyLvjF7U0oS53v8dW93YLO+04L1yq4NjVTL795R8S\r\n4QblGAR0KBmyPHMU9Sxh5Aq6Z/WgEhw8jHFcgBnBelhhRVWW8cXWTbH09vRK\r\ny5bbQz19ifOjd+ZI++6AjPSeM0NrrHRPXWKZHjN2IvMke3MVTCE2yU0zHU8F\r\n9OA3amobOWUZWqRD2Dfge6OUc2OSkUz7eYbfVBK6dOW5T1eL81iDB9YmpDlA\r\nwCYeSuKQ76d141FTCyzVdmp2BQONrEVqYtQ=\r\n=vYvj\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"1c93bffa80f14a13888a9934d7c3f0beb4c5eb8e","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.8.2-alpha-20230222123356-1c93bff","@whatwg-node/server":"^0.7.0","@whatwg-node/typed-fetch":"0.0.1-alpha-20230222123356-1c93bff"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.4.0-alpha-20230222123356-1c93bff_1677069253312_0.5418589424204006","host":"s3://npm-registry-packages"}},"0.4.0-alpha-20230222134347-496b85e":{"name":"@whatwg-node/router","version":"0.4.0-alpha-20230222134347-496b85e","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.4.0-alpha-20230222134347-496b85e","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"d3e818d11112e13595f43e7ee98093ada01cb5aa","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.4.0-alpha-20230222134347-496b85e.tgz","fileCount":7,"integrity":"sha512-JPqGV/BuOxKeF/dJ2OXCppLOpDHOxILeXqV+J9fmJGUIW+jflM/48pYu2CcBmFJvJe6fCMD7by3xBpZpFEfxqg==","signatures":[{"sig":"MEQCIEVZq18x/UaOV9Vnud88415iQYkZ+qlSy56AmlB+yJKGAiAakZLWQdZr6Hrynh88Wt+UYqCQn3dNGPD2DdRQwoLT5g==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20401,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj9hwjACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrbGRAAi5c0XIy2fsK6/R+4EgQWu60cVBsX/NzGji6n9/XStm/wR8C2\r\nzLUcFvazqUSt45wLdZX1Viuj3weeN3wNzcnh28lROMD1zzgT2fDDU25syjJK\r\nTqpP5jHQx+E9+ceL6GQr8oioGVbhWB/2EV549Q9QHIVrmOCORpuFzE6zv7OP\r\nlwJgi+z8VsVBs+wJjGRTmIIeayg0gYeajqdzFemNeG1h5d//LOaxOjz6J+IR\r\nzgId7XZiKmjBonNYJECzgrdhlH/9whea3Cew7zYI+0SKcQGBNnIXQHmCNsZ9\r\n0ouQAgnmX/A9q10CPAN28meVZeFfsNMMvUP3DHoQr+nkf1d05UL8g2T1UFgN\r\nVTFqg+q9FDJ2afWJ+qrIsiBPrj4gdlhpF1gMtAPnS6GiYiMgt/jxmsEMVBTa\r\nT3Qq5ToV0DKsY+Div3XsjxNZlX9NiGXrt2lEI5LRIEFweVV6/KqOz/CaedDM\r\n/kL0vG96PYqOZAlC/F0oA49tRKNx7M6fWhrVN5/Ym7zFkGA4gPpIglOqya/W\r\ny9DW5S9fMfjxkt6GXd47TNrUQlbbxZveY1/KF6sahubUYvoTH9C4HcCnV/ZX\r\ng55zLfTEbwsFB1i4++Y89VSMIWXY2OMrDR31fr35dQUkDlAmuUSzcRNWl5Hz\r\nIwiuUPkPIBJTYXXiYbvgqa6Eens4VNrMRew=\r\n=8ERE\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"496b85e41cf891bf50aaaea86854b3cfc0e9e1a6","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.0","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"0.8.2-alpha-20230222134347-496b85e","@whatwg-node/server":"^0.7.0","@whatwg-node/typed-fetch":"0.0.1-alpha-20230222134347-496b85e"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.4.0-alpha-20230222134347-496b85e_1677073443683_0.5668900453876962","host":"s3://npm-registry-packages"}},"0.4.0-alpha-20230222165405-b7f3333":{"name":"@whatwg-node/router","version":"0.4.0-alpha-20230222165405-b7f3333","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.4.0-alpha-20230222165405-b7f3333","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"2497d7c3aae360b18622d823910182a8661360f9","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.4.0-alpha-20230222165405-b7f3333.tgz","fileCount":8,"integrity":"sha512-ngT7tgg0LyNqskrQWmrJnzVHnHmG7FsBmeNCbwwDVGaUnQ4unEIpgAcDGROXAX03++9PB16pBZTwetSKOQp7Ww==","signatures":[{"sig":"MEYCIQDVAwJF4ZZOD1BTuLML85tz5yzYoS2R0pP9e4Odhe/JUAIhAIa/1BggzoTUVmOUiu3RhTAxsf4Vay32qwemgmr41pBe","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":35839,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj9ki/ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqkoQ/6A1rFvOWgQwFBNLIxtm36EzYequPfL/GBTZj7FN+88dguRObi\r\nAgRhA5DdMvOhSHy+vKo0o3kvi0HbBIxkHHIMgVfCcXNZZCBGLkrOziaTx6jz\r\n1Nq+6SqyJJWteTzW0ualGm5hd9jyRLbGxAKJzcLz4deRHY0xARYtCmLOJtoR\r\nwYj3FF6P9g+E8NZEbBKthBofXT2SHCrp8U/Jqal69eqmuDsRWwux2USwXk5j\r\nA9vFGhrUcQUu+ILZ9Q9Mf4L6ZqH74OR2OnuUopzrF/kiGEl7XUrSqOR4C4X7\r\nke/Pn7g7kUdzNrjGIXTa0qTYs1vJj0hQRnR7gQwS69f1uRiP+9DM7A21JHYj\r\nmjOFShrEi1G2YR7FE+APr6hQYYL9O0o7NPNvJNzRRx4MV3//GGDnPF3EVH8P\r\njxv9g4ZrLvS40fPktoNJdshT+7eXwUCOWSodop1SeUjVKA0EkHimSJ515kIL\r\nUmElSNh3PhdwV0D6lwgoNKol5e8p+CaM1IEQhvLvwy/mFqZ2QzWYmO+nnTax\r\nAKpI8+BkJe0d+8c/OL9/uGnUOlHTg0LOmRsst8L7RZDTv3Qb9OFBh6GZzwEL\r\naH+VbV2p9suQKEzcZ1Q21iD2CwLhM4DykV9WYK/QrrwcPciU4Z2Qyb8C6fj2\r\nfZtjvU7I+b0MZVgIAYTmiF0FF2VdyjRxglE=\r\n=JelQ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"b7f3333efc6a17a163f411e268c49fcf658568f0","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.1","dependencies":{"tslib":"^2.3.1","openapi-types":"12.1.0","json-schema-to-ts":"2.6.2","@whatwg-node/fetch":"0.8.2-alpha-20230222165405-b7f3333","@whatwg-node/server":"^0.7.0","@whatwg-node/typed-fetch":"0.0.1-alpha-20230222165405-b7f3333"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.4.0-alpha-20230222165405-b7f3333_1677084863779_0.6802094143236916","host":"s3://npm-registry-packages"}},"0.4.0-alpha-20230222172456-a1adb6d":{"name":"@whatwg-node/router","version":"0.4.0-alpha-20230222172456-a1adb6d","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.4.0-alpha-20230222172456-a1adb6d","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"e9712ba53f060eba5e8f76578accf43a4aef5f40","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.4.0-alpha-20230222172456-a1adb6d.tgz","fileCount":9,"integrity":"sha512-XIckH6QQlrva25jweyYeiUTburIzIzCi9eIf/Rmo1tF7RlCVQfOBEaW+FqNZKJ8C+xP44R6KBFTaY2sfC1Be3w==","signatures":[{"sig":"MEYCIQC9LTEPULE7wCEaaJpkqsXTJ4/hokFztZn18DVvCJGj6wIhAL54VoNhUrPgW23nsbBdE2z5Z+jsgF7KplmtxYcQfFkT","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":37497,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj9k/5ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrTUQ/9HslaUp9lgEnsxWmgkT3J5YpGOLPD+Tf5q59OlwwJnHnMWGuB\r\n0OTziyFoNhcYiMZC4czlsijSKrLAnzaXbhIHsJ6tXRJjChE2cLA8RUjLifgq\r\nKVBFrna1VYqXzhyRfE+5s7fnPFH4tsjq4dFN68LJX7V6AC+nff5BsVtZSsb0\r\nbxKMsQkR93JOTs2IY0Sj7pAeUci9o3+tKtiEHq89qgUPy6aQ+R6GfsmnUhnu\r\ngrKBgpfNNhhyao98s6A4d1oOl+HkvZJ13D+sQNF8cWyj8Ri5LSwnpyHh69oZ\r\nqtdw+0VFqjrctJfkcXCg9287gfzK6bnMa2qyDTNbNoJUZbrhWLZdSIUpvn1J\r\nu2aoibEm+PjmzVZ4BKHWqv5u0byOnLLEqsHfCo27z33x/WWOZ8XlxuPYbZYD\r\nHg5z9tuZ3y2DtCpjdHWSgwE1xcykUZBQIaR9ADQK95gkkNxS8nyQKw384Lq3\r\nf454ktmHE/tgp9MdFirp02xczkPsXJvYWOjPsCZFIFoBP4FLPboUfxzlTd5y\r\n1LKJojK4sJmfuwBCVgMP0xvKi/Mf44uYMpGKOAhVh2VDrekQ7J+Tb+RnW/Lk\r\nSh+SXaxG/nhgTEquKjCT0ecsyTuVhfYxnOXcxhoj9/tC0QECmFepuquJOzKb\r\nOlVvG/qTybi1oieTPqWZsbLr3PATRBb3+dw=\r\n=eG88\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"a1adb6db71bb1afd2de146248d67036a2dbf43af","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.1","dependencies":{"tslib":"^2.3.1","openapi-types":"12.1.0","json-schema-to-ts":"2.6.2","@whatwg-node/fetch":"0.8.2-alpha-20230222172456-a1adb6d","@whatwg-node/server":"^0.7.0","@whatwg-node/typed-fetch":"0.0.1-alpha-20230222172456-a1adb6d"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.4.0-alpha-20230222172456-a1adb6d_1677086712851_0.3683001262024461","host":"s3://npm-registry-packages"}},"0.4.0-alpha-20230222174610-1d1aaed":{"name":"@whatwg-node/router","version":"0.4.0-alpha-20230222174610-1d1aaed","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.4.0-alpha-20230222174610-1d1aaed","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"54271fb5caced113b745f1a7ddf21e045f58cec9","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.4.0-alpha-20230222174610-1d1aaed.tgz","fileCount":9,"integrity":"sha512-A5b44a1Dnq/NcJQMhnGXbNqrZyoKrknmpUIYVHncyk0rBb1ZFqk5RYXlOp1WOUj9q50lgTutPNoqKMtH/dqYOw==","signatures":[{"sig":"MEQCIG1KanBqQmNli0K0juhLNhJ290sYlYqOUWAeaaXywl1DAiA5tEtU72/nNnolQv/Fe5J+GonMazLEm7Tye/6hhlhcmA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":37497,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj9lTzACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoJRhAAnSsXvsvsr/USCqZPbj/s22MaViPOBzfDJCYviytHHgboVWBd\r\n46F/JX6lNH01658YUXTIAyAkE6J2Ga/VDQ2FO6QKqUrXuIiqfqEcdwHgOMAh\r\nqlwKDxU/NLVZf94VQki+0JrH5TEtYl7KXrTi32wBNujI2oQO//1BY7rgTNA1\r\nD7sf+f/G0Gjbk0xe6GuLRyGYHb8AvNOu4kKZNAA3TQPUYahQSp+kqPtz42CO\r\nICBn9a5ZEUaBNsqkmOyrDKrlUK2hIg7ywIHLGRgMtgtaUBPxI9ow9NDfDvkz\r\n9T3bIW93xFWDwQkL52OGU5xtaEXmo2/JRcsW7KyC9s2dNBjEg5tUwPxMjA5h\r\nOsMYZTLnw2TgjbrZI7qSIogn52jtChLHwIEUI/t2+DlfzdDgh8HVl9AHuOum\r\nUWdGmtOWOR+V+mxqVzX2R9lBhCF44DNaz6ObPxCAHscwnkI/KiuQDAd0F6my\r\nr/zxF7YWPPR+No361Q8b+h3V9/ODofmPMy7s2Yjt946l6qFIJnWjtqCwDQAQ\r\nBGfukt93l0gd5lD6ykzjqO3MtvIHG0Byv9HzUYITsfG6C+EogW50MJwAVB5f\r\nZnA6LyxcRAIPi1vdDH949sjl+6s42npF9HnyQZTja6QmkIqU6ykaDaNMsJIK\r\nVgR2zOaeLKLbplIyliVCQHqZicscwfx3yzE=\r\n=q/o+\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"1d1aaed0ce5a4d5ddd26e91fb43c28946c966e25","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.0","dependencies":{"tslib":"^2.3.1","openapi-types":"12.1.0","json-schema-to-ts":"2.6.2","@whatwg-node/fetch":"0.8.2-alpha-20230222174610-1d1aaed","@whatwg-node/server":"^0.7.0","@whatwg-node/typed-fetch":"0.0.1-alpha-20230222174610-1d1aaed"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.4.0-alpha-20230222174610-1d1aaed_1677087987524_0.6804618606780903","host":"s3://npm-registry-packages"}},"0.4.0-alpha-20230222180513-791bc09":{"name":"@whatwg-node/router","version":"0.4.0-alpha-20230222180513-791bc09","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.4.0-alpha-20230222180513-791bc09","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"7d0c1962fbe4a9b2364b0f4409408f6d166ab9b8","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.4.0-alpha-20230222180513-791bc09.tgz","fileCount":9,"integrity":"sha512-jUICBSji5ItXAQTeaaGaFjhVcYbS/e5l4+XBdQ0SU4xmP1peMcXfw447jGLX3p3PNs1q2Jgm5mv3eJPqWdeLqQ==","signatures":[{"sig":"MEQCIGe3twAtE9xySr7DfpWZY1xtSvyzAkPi1NSMJCHrgH7lAiAAlGQjfi28B38p/9turXuyoV46HxK8/JiFN/TDvFkH3w==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":37497,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj9llvACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqWtw/8CJASwYW5rokiH+KGEdM6U6nxivtq/IHIktGfKLCazzfWtl3N\r\nR7ehkKnf8P7ky208hus6EOjhsPPq3zwIy9X9w6CRyZDeKufG13qW9dRECTWh\r\nGY390djH7fx8PcfOmXVuP8tMV8jC5TwUJihI9ldyLcBETBB5FFJJ9f5NYUBe\r\nVR1+Ko67JABH0ApfmCIXDMzdrO4duiYpSD6hZfkM92DvqiHzVHsSX2eggwyw\r\np+9DBnpH+DzEIYE0A6KB1yBYtuFo3COP4eiwh1bXQDqUCzDNU9rXv3J82HNJ\r\nwmDG4xgHj4UZCI0XCFg7HSn+PSDH4hqa5nwwzqGbx1D8d9aGK1J9ywI3jvwm\r\nqYsOksMLkJLUxAOD9rpzQUxxtfvEtA4zRftp4L75Ge1DadjtAUGJSQr39GMd\r\nGlVd+zKlcxxwlIDp0UoUon64BoHYx2mRhlcJ+zMnfxm0G8kacNkxcz8/XM9K\r\nYAQheJprSKdPQX2aAf1Xv1uq5ZoHHmHKHYJDS8I9K4qdV8Qote5Thn/We354\r\nrqH34+ht9sPPd/rBynf9rX5fj8cMVit8lqm680CMBjnUXpotrA6u6R+caXpB\r\nvv2wocvic3gli4kDDzKQW4bVUWt0rnN4U6k55cA+vTiIIL7PjqQrgV8gZtJn\r\n4DYGKcjPs61aWtAnp/6kT/+2Eu2MkPlj0Cg=\r\n=6wb7\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"791bc09a533b94a2e40a31d6f62bdc19b11f8117","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.0","dependencies":{"tslib":"^2.3.1","openapi-types":"12.1.0","json-schema-to-ts":"2.6.2","@whatwg-node/fetch":"0.8.2-alpha-20230222180513-791bc09","@whatwg-node/server":"^0.7.0","@whatwg-node/typed-fetch":"0.0.1-alpha-20230222180513-791bc09"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.4.0-alpha-20230222180513-791bc09_1677089135137_0.17722221630720814","host":"s3://npm-registry-packages"}},"0.4.0-alpha-20230223104455-93c17a9":{"name":"@whatwg-node/router","version":"0.4.0-alpha-20230223104455-93c17a9","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.4.0-alpha-20230223104455-93c17a9","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"6fde5690ae9180b040aaecfec5df7ede65fd64c4","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.4.0-alpha-20230223104455-93c17a9.tgz","fileCount":9,"integrity":"sha512-i7Mude8nAT7zR6So2YaHvHJgmIlqZB1dvqyqEqSUwj/MAqUEWMZdlc5XfmetbD7F9QqTtdgLYMfR7acAD0bhLg==","signatures":[{"sig":"MEYCIQCJnaGJL6H9n49OmZSEzK5EutfKJj+2qQTVfFQFxiiQRgIhAMpAcF2qnr9uogWxJPJtM+16V0ipsgpX/tmTdIuu7js6","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":45233,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj90O6ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpfWA//XbEyYESTlU3l7GdwMTPG8lC8ZGQm3jYXdbsimVwyk2/kQuCf\r\n2FbvTvV/vufpKTWEhV/GjhwO21O9yoXJUBHO1TTVSFQRdgWcMjSua37TxIrS\r\nuG6Cn378lOOL5XMtd9ogAMs5PCWF0RfUOEyoZpJ94dEibEv0qMyzGmY0LRGu\r\n3ytZxYDN5mKUH8DU/JZ9Hw7/5012YKN64Qb9t7wd7adNWGE6dhWsvdeGZ0r9\r\nGrI2/8W8WJIIvg6mSrzORfBL+z3eqzEitu2P37w6V47kkug6JOr/pb8LmEb8\r\nFTdOv4UdOjbE7r5sGqnbu6rFIPHfBdeOQYgbvyJYyaFGJI2oAVGWp0q2q8Ib\r\nUxqgIciiCGyWWah8rnThCoZM4aEPGrtO61yh3a7BfJXqFp1FfwSH6e7A5JSV\r\nhIo3/X17scyWVAgMD5nN9qWHehJ0w8370UmOFhuSbIxq/o5qcapuKjWn2pjK\r\nHPrP4QRqdHS3ws2dIXYRlPKTQd8e2rW1rPVmT9m37JrRv34HK1ZiY8dw1NX0\r\nwcr3JuJ/V+I0t1ukAOdt74V51htK3rHhJhaPp9tu0VbENE5WU5aP/EvH0Vk4\r\n42GjXLv0/vokuODswxyip8CIPKrb/6PNNRgmVdISevtKeJMucSMsOuaBB1/4\r\n+n4uhpRItTmfXGAJp4REFLpnyH0dPSPvyc0=\r\n=D0th\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\n### Basic Routing\n\n```ts\n// Then use it in any environment\nimport { createServer } from 'http'\nimport { createRouter, Router } from '@whatwg-node/router'\n\nconst router = createRouter()\n// GET collection index\nrouter.get('/todos', () => new Response('Todos Index!'))\n// GET item\nrouter.get('/todos/:id', ({ params }) => new Response(`Todo #${params.id}`))\n// POST to the collection (we'll use async here)\nrouter.post('/todos', async request => {\n  const content = await request.json()\n  return new Response('Creating Todo: ' + JSON.stringify(content))\n})\n\n// Redirect to a URL\nrouter.get('/google', () => Response.redirect('http://www.google.com'))\n\n// 404 for everything else\nrouter.all('*', () => new Response('Not Found.', { status: 404 }))\n\nconst httpServer = createServer(router)\nhttpServer.listen(4000)\n```\n\n## Example\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors. Or you can use the plugins to handle errors like below.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Plugins to handle CORS, cookies and more\n\nThis library also provides a plugin system that allows you hook into the request/response lifecycle.\n\n- `onRequest` - Called before the request is handled by the router\n- - It has `endResponse` method that accepts a `Response` object to short-circuit the request\n- `onResponse` - Called after the request is handled by the router\n- - It allows you to modify the response before it is sent to the client\n\n### Cookie Management\n\nYou can use `useCookies` to parse cookies from the request header and set cookies in the response by using Web Standard [CookieStore](https://developer.mozilla.org/en-US/docs/Web/API/CookieStore).\n\n```ts\nimport { createRouter, useCookies, Response } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [\n    useCookies()\n  ]\n})\n\nrouter.get('/me', async req => {\n  const sessionId = await request.cookieStore.get('session_id')\n  if (!sessionId) {\n    return Response.json({ error: 'Unauthorized' }, { status: 401 })\n  }\n  const user = await getUserBySessionId(sessionId)\n  return Response.json(user)  \n})\n\nrouter.post('/login', async req => {\n  const { username, password } = await req.json()\n  const sessionId = await createSessionForUser({ username, password })\n  await request.cookieStore.set('session_id', sessionId)\n  return Response.json({ message: 'ok' })\n})\n```\n\n### CORS Management\n\nYou can also setup a CORS middleware to handle preflight CORS requests.\n\n```ts\nimport { useCORS, createRouter } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [\n    useCORS({\n      origin: '*',\n      methods: ['GET', 'POST', 'PUT', 'DELETE'],\n      headers: ['Content-Type', 'Authorization']\n    })\n  ]\n})\n```\n\n### Custom plugins\n\nYou can also create your own plugins to handle errors, logging, etc.\n\n```ts\nimport { createRouter } from '@whatwg-node/router'\n\nconst useRequestId = (): RoutePlugin => {\n  return {\n    onRequest({ request, fetchAPI }) {\n      let requestId = request.headers.get('X-Request-ID')\n      if (!requestId) {\n        requestId = fetchAPI.crypto.randomUUID()\n        request.headers.set('X-Request-ID', requestId)\n      }\n    },\n    onResponse({ response, fetchAPI }) {\n      response.headers.set('X-Request-ID', request.headers.get('X-Request-ID'))\n    }\n  }\n}\n\nconst router = createRouter({\n  plugins: [\n    useRequestId(),\n  ]\n})\n```\n\n## Type Safety with TypeScript, JSON Schema and OpenAPI\n\nThis library is written in TypeScript and it provides type safety for your request and response with the power of JSON Schema.\n\nTo define type-safe routes, we use `addRoute` method with specific parameters.\n\n#### Typing the request\n\nYou can type individual parts of the `Request` object including JSON body, headers, query parameters, and URL parameters.\n\n##### JSON Body\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nrouter.addRoute({\n  method: 'post',\n  path: '/todos',\n  // Define the request body schema\n  schemas: {\n    Request: {\n      JSONBody: {\n        type: 'object',\n        properties: {\n          title: { type: 'string' },\n          completed: { type: 'boolean' }\n        },\n        additionalProperties: false,\n        required: ['title']\n      },\n    }\n  }\n}, async request => {\n  // This part is fully typed\n  const { title, completed } = await request.json()\n  // ...\n  return Response.json({ message: 'ok' })\n})\n```\n\n##### Headers\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nrouter.addRoute({\n  method: 'post',\n  path: '/todos',\n  // Define the request body schema\n  schemas: {\n    Request: {\n      Headers: {\n        type: 'object',\n        properties: {\n          'x-api-key': { type: 'string' }\n        },\n        additionalProperties: false,\n        required: ['x-api-key']\n      },\n    }\n  }\n}, async request => {\n  // This part is fully typed\n  const apiKey = request.headers.get('x-api-key')\n  // Would fail on TypeScript compilation\n  const wrongHeaderName = request.headers.get('x-api-key-wrong')\n  // ...\n  return Response.json({ message: 'ok' })\n})\n```\n\n##### Path Parameters\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nrouter.addRoute({\n  method: 'get',\n  path: '/todos/:id',\n  // Define the request body schema\n  schemas: {\n    Request: {\n      PathParams: {\n        type: 'object',\n        properties: {\n          id: { type: 'string' }\n        },\n        additionalProperties: false,\n        required: ['id']\n      },\n    }\n  }\n}, async request => {\n  // This part is fully typed\n  const { id } = request.params\n  // ...\n  return Response.json({ message: 'ok' })\n})\n```\n\n##### Query Parameters\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nrouter.addRoute({\n  method: 'get',\n  path: '/todos',\n  // Define the request body schema\n  schemas: {\n    Request: {\n      QueryParams: {\n        type: 'object',\n        properties: {\n          limit: { type: 'number' },\n          offset: { type: 'number' }\n        },\n        additionalProperties: false,\n        required: ['limit']\n      },\n    }\n  }\n}, async request => {\n  // This part is fully typed\n  const { limit, offset } = request.query\n  // You can also use `URLSearchParams` API\n  const limit = request.parsedURL.searchParams.get('limit')\n  // ...\n  return Response.json({ message: 'ok' })\n})\n```\n\n#### Typing the response\n\nYou can also type the response body by the status code. We strongly recommend to explicitly define the status codes.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nrouter.addRoute({\n  method: 'get',\n  path: '/todos',\n  // Define the request body schema\n  schemas: {\n    Request: {\n      Headers: {\n        type: 'object',\n        properties: {\n          'x-api-key': { type: 'string' }\n        },\n        additionalProperties: false,\n        required: ['x-api-key']\n      }\n    },\n    Response: {\n      200: {\n        type: 'array',\n        items: {\n          type: 'object',\n          properties: {\n            id: { type: 'string' },\n            title: { type: 'string' },\n            completed: { type: 'boolean' }\n          },\n          additionalProperties: false,\n          required: ['id', 'title', 'completed']\n        }\n      },\n      401: {\n        type: 'object',\n        properties: {\n          message: { type: 'string' }\n        },\n        additionalProperties: false,\n        required: ['message']\n      }\n    }\n  }\n}, async request => {\n  const apiKey = request.headers.get('x-api-key')\n  if (!apiKey) {\n    return Response.json({ message: 'API key is required' }, {\n      status: 401\n    })\n  }\n  const todos = await getTodos({\n    apiKey\n  })\n  // This part is fully typed\n  return Response.json(todos, {\n    status: 200\n  })\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"93c17a9ab925fad16db5c14a09b32d4fc59a52ff","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.1","dependencies":{"tslib":"^2.3.1","openapi-types":"12.1.0","json-schema-to-ts":"2.6.2","@whatwg-node/fetch":"0.8.2-alpha-20230223104455-93c17a9","@whatwg-node/server":"^0.7.0","@whatwg-node/typed-fetch":"0.0.1-alpha-20230223104455-93c17a9"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.4.0-alpha-20230223104455-93c17a9_1677149114330_0.23255861443831183","host":"s3://npm-registry-packages"}},"0.4.0-alpha-20230223105049-e2a7bfd":{"name":"@whatwg-node/router","version":"0.4.0-alpha-20230223105049-e2a7bfd","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.4.0-alpha-20230223105049-e2a7bfd","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"3fca805327546cdaac6c70084fbdbd62c76b2d67","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.4.0-alpha-20230223105049-e2a7bfd.tgz","fileCount":9,"integrity":"sha512-qDDyccSB/b/VvH+Azo00IIqTbgeYWsdbAG4sqKKvWCo2I5e8eOc8+IyGp+3OVFBIrn7zXGzDa5HCGtaVWNekGw==","signatures":[{"sig":"MEUCIFfc7OVapBd2aH8vbXGbSSmU82bRL9qG6wOqQrUCGjkzAiEA8us5QCbG/mkQU3VTBg2y0ht8ciFX14bggP6A1RDG42E=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":45501,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj90UcACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpWLBAAo3syP9P7Tx3V2SerpB+Cg3LBp1+GpLLxbEhxGRBLRoaQNBuG\r\n0d4cwpMC0ZLRk28/Z7ySYLEGD9+PsFf4bjP2hEgObAvtNanq7HJEeOC8tgBS\r\ndPbijxTMyPKzy+f4svph4vmpjKDDWHllg85rjVvjzNQda3VRXYVkpwtuGkrT\r\nv/pQc7tMvVIBpIKb+OWL/B8vga7seO4bsXVVzd8A+55hcJiwuEhYK9JnncIF\r\nYehB2TRkl/Gm1i2dNYyIveOkCObAqhqCyxb+VI7zVdedCq/EPm13vaeHnDdK\r\nySFflbBcNynpw0bE69eI3FkMe6gEJTVUyf/cpCpNlIPFAYR6E7rLd5DGtkb+\r\n5gzORaqXT+S60L90GG2iOc2aZ+ui5XA0p5GsMYpZRIWIK+U9LJPCcKX6W3q5\r\nPen2znMEhDhpGi9+khUKjmhyjlQDEcQi31B6HaguI4AP9DbAzPgyz9G2lMbM\r\nnzsEMR0hrSXtiT0b4USsgBMJMVo5aExVf9XTdH3ylxs4/CUx9uzupTP09U2z\r\nn661wLtnSm5P2wBlW/zLc4eNi5yfbB7XxDIQ3b1ZBvYlKGtLEyq25qYYlONY\r\nEI1tTWAiVShdpdltr/3PPTV18xkX6bF5anNn2+OrCnSPxdA5krxK2RkOI6Zt\r\noyEZkw3H+sMqLHLlebnqo150DYBr0Kdc5p8=\r\n=tDM+\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\n### Basic Routing\n\n```ts\n// Then use it in any environment\nimport { createServer } from 'http'\nimport { createRouter, Router } from '@whatwg-node/router'\n\nconst router = createRouter()\n// GET collection index\nrouter.get('/todos', () => new Response('Todos Index!'))\n// GET item\nrouter.get('/todos/:id', ({ params }) => new Response(`Todo #${params.id}`))\n// POST to the collection (we'll use async here)\nrouter.post('/todos', async request => {\n  const content = await request.json()\n  return new Response('Creating Todo: ' + JSON.stringify(content))\n})\n\n// Redirect to a URL\nrouter.get('/google', () => Response.redirect('http://www.google.com'))\n\n// 404 for everything else\nrouter.all('*', () => new Response('Not Found.', { status: 404 }))\n\nconst httpServer = createServer(router)\nhttpServer.listen(4000)\n```\n\n## Example\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors. Or you can use the plugins to handle errors like below.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Plugins to handle CORS, cookies and more\n\nThis library also provides a plugin system that allows you hook into the request/response lifecycle.\n\n- `onRequest` - Called before the request is handled by the router\n- - It has `endResponse` method that accepts a `Response` object to short-circuit the request\n- `onResponse` - Called after the request is handled by the router\n- - It allows you to modify the response before it is sent to the client\n\n### Cookie Management\n\nYou can use `useCookies` to parse cookies from the request header and set cookies in the response by\nusing Web Standard [CookieStore](https://developer.mozilla.org/en-US/docs/Web/API/CookieStore).\n\n```ts\nimport { createRouter, Response, useCookies } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [useCookies()]\n})\n\nrouter.get('/me', async req => {\n  const sessionId = await request.cookieStore.get('session_id')\n  if (!sessionId) {\n    return Response.json({ error: 'Unauthorized' }, { status: 401 })\n  }\n  const user = await getUserBySessionId(sessionId)\n  return Response.json(user)\n})\n\nrouter.post('/login', async req => {\n  const { username, password } = await req.json()\n  const sessionId = await createSessionForUser({ username, password })\n  await request.cookieStore.set('session_id', sessionId)\n  return Response.json({ message: 'ok' })\n})\n```\n\n### CORS Management\n\nYou can also setup a CORS middleware to handle preflight CORS requests.\n\n```ts\nimport { createRouter, useCORS } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [\n    useCORS({\n      origin: '*',\n      methods: ['GET', 'POST', 'PUT', 'DELETE'],\n      headers: ['Content-Type', 'Authorization']\n    })\n  ]\n})\n```\n\n### Custom plugins\n\nYou can also create your own plugins to handle errors, logging, etc.\n\n```ts\nimport { createRouter } from '@whatwg-node/router'\n\nconst useRequestId = (): RoutePlugin => {\n  return {\n    onRequest({ request, fetchAPI }) {\n      let requestId = request.headers.get('X-Request-ID')\n      if (!requestId) {\n        requestId = fetchAPI.crypto.randomUUID()\n        request.headers.set('X-Request-ID', requestId)\n      }\n    },\n    onResponse({ response, fetchAPI }) {\n      response.headers.set('X-Request-ID', request.headers.get('X-Request-ID'))\n    }\n  }\n}\n\nconst router = createRouter({\n  plugins: [useRequestId()]\n})\n```\n\n## Type Safety with TypeScript, JSON Schema and OpenAPI\n\nThis library is written in TypeScript and it provides type safety for your request and response with\nthe power of JSON Schema.\n\nTo define type-safe routes, we use `addRoute` method with specific parameters.\n\n#### Typing the request\n\nYou can type individual parts of the `Request` object including JSON body, headers, query\nparameters, and URL parameters.\n\n##### JSON Body\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nrouter.addRoute(\n  {\n    method: 'post',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        JSONBody: {\n          type: 'object',\n          properties: {\n            title: { type: 'string' },\n            completed: { type: 'boolean' }\n          },\n          additionalProperties: false,\n          required: ['title']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const { title, completed } = await request.json()\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Headers\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nrouter.addRoute(\n  {\n    method: 'post',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        Headers: {\n          type: 'object',\n          properties: {\n            'x-api-key': { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['x-api-key']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const apiKey = request.headers.get('x-api-key')\n    // Would fail on TypeScript compilation\n    const wrongHeaderName = request.headers.get('x-api-key-wrong')\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Path Parameters\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nrouter.addRoute(\n  {\n    method: 'get',\n    path: '/todos/:id',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        PathParams: {\n          type: 'object',\n          properties: {\n            id: { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['id']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const { id } = request.params\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Query Parameters\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nrouter.addRoute({\n  method: 'get',\n  path: '/todos',\n  // Define the request body schema\n  schemas: {\n    Request: {\n      QueryParams: {\n        type: 'object',\n        properties: {\n          limit: { type: 'number' },\n          offset: { type: 'number' }\n        },\n        additionalProperties: false,\n        required: ['limit']\n      },\n    }\n  }\n}, async request => {\n  // This part is fully typed\n  const { limit, offset } = request.query\n  // You can also use `URLSearchParams` API\n  const limit = request.parsedURL.searchParams.get('limit')\n  // ...\n  return Response.json({ message: 'ok' })\n})\n```\n\n#### Typing the response\n\nYou can also type the response body by the status code. We strongly recommend to explicitly define\nthe status codes.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nrouter.addRoute(\n  {\n    method: 'get',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        Headers: {\n          type: 'object',\n          properties: {\n            'x-api-key': { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['x-api-key']\n        }\n      },\n      Response: {\n        200: {\n          type: 'array',\n          items: {\n            type: 'object',\n            properties: {\n              id: { type: 'string' },\n              title: { type: 'string' },\n              completed: { type: 'boolean' }\n            },\n            additionalProperties: false,\n            required: ['id', 'title', 'completed']\n          }\n        },\n        401: {\n          type: 'object',\n          properties: {\n            message: { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['message']\n        }\n      }\n    }\n  },\n  async request => {\n    const apiKey = request.headers.get('x-api-key')\n    if (!apiKey) {\n      return Response.json(\n        { message: 'API key is required' },\n        {\n          status: 401\n        }\n      )\n    }\n    const todos = await getTodos({\n      apiKey\n    })\n    // This part is fully typed\n    return Response.json(todos, {\n      status: 200\n    })\n  }\n)\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"e2a7bfd19e29b37ead34e972b357995c584fb198","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.1","dependencies":{"tslib":"^2.3.1","openapi-types":"12.1.0","json-schema-to-ts":"2.6.2","@whatwg-node/fetch":"0.8.2-alpha-20230223105049-e2a7bfd","@whatwg-node/server":"^0.7.0","@whatwg-node/typed-fetch":"0.0.1-alpha-20230223105049-e2a7bfd"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.4.0-alpha-20230223105049-e2a7bfd_1677149468545_0.9825198147039411","host":"s3://npm-registry-packages"}},"0.4.0-alpha-20230223141917-77f3e42":{"name":"@whatwg-node/router","version":"0.4.0-alpha-20230223141917-77f3e42","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.4.0-alpha-20230223141917-77f3e42","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"681e5600355cb8257f95e6bce4187c83f02c233c","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.4.0-alpha-20230223141917-77f3e42.tgz","fileCount":9,"integrity":"sha512-blLBLSspSP2ksY0TtDp5ZbMcivJxOumMynOdQOe3Kas7szQwmyFbGYoSk7VM4COTBR88H96zd8ge1qiSE4I4ag==","signatures":[{"sig":"MEUCIEmXtCU3ce4yTDFQ9qQFDZjK8qQmuWLqbMZJhpI13H29AiEA8tjBCTxE/lsMCtP8G6miBKnSxF7upwU8FZBi2t7DTDM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":45501,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj93YDACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqG/Q//fNGjW9f/qpnrEkQZ+fBmnmHHA8ESLLuMff2dfmHBQGw28h4B\r\n4JINBP2rANz7ZPbBv27T/DEDeyjNyhGPMUB8ptMQl0C4xQ786a1G1oara8Gs\r\nxOt68uLwUHxuq5lJC+JUk9OICNMRTcPwEJdSuqRHwbG7sbFDJejcVirHgTYt\r\nWCewy67UGb9YOKJwQLwlx3z8+lzFb3Z1oVLL6XUZhzrEG6KXRJ5yGjHz1xVd\r\nsWI7EU2IctnPn5Jz28l6c7bkeNbXyapfo0aVbQ8I9/aFat4FLSluj/VZISu5\r\ni8V9ycwKG+yJv4Df4xnCc6yuHX47QLGFWWuccTVuaZV2rDj4azi82eXqhNV6\r\nOciY6Zv/pe82ibYdnYSBAIlIa0W92pZl5+iQoFiOxZ4YlK/U9x6dh9DzYgGG\r\nZfwplPBIX2xNgUGC5HFniljAjpYo+u0tCmwsNHOIA0Cs3W3++RVgt+vJGqSg\r\ndX1LwIDmJsGMggZ2YUTdHBcHgCIuHo0DxahPGqBt3ehCxZMZCs646oYp0ACg\r\n0G37e/TkeWFhNeyzb/kj9pPJ+KGSdHboiGcuqUp5K2J0bgrLZUZ0OqNGfeCz\r\nFT7yEbhAOyznTtw+QIi9b62n+yxFB2c7xCcr7bU3qooaQSDtZfTISxnRh5QB\r\nvhpZScfdgOIxh5+IVzGxI/NcYjM/x/juS7c=\r\n=dX5Y\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\n### Basic Routing\n\n```ts\n// Then use it in any environment\nimport { createServer } from 'http'\nimport { createRouter, Router } from '@whatwg-node/router'\n\nconst router = createRouter()\n// GET collection index\nrouter.get('/todos', () => new Response('Todos Index!'))\n// GET item\nrouter.get('/todos/:id', ({ params }) => new Response(`Todo #${params.id}`))\n// POST to the collection (we'll use async here)\nrouter.post('/todos', async request => {\n  const content = await request.json()\n  return new Response('Creating Todo: ' + JSON.stringify(content))\n})\n\n// Redirect to a URL\nrouter.get('/google', () => Response.redirect('http://www.google.com'))\n\n// 404 for everything else\nrouter.all('*', () => new Response('Not Found.', { status: 404 }))\n\nconst httpServer = createServer(router)\nhttpServer.listen(4000)\n```\n\n## Example\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors. Or you can use the plugins to handle errors like below.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Plugins to handle CORS, cookies and more\n\nThis library also provides a plugin system that allows you hook into the request/response lifecycle.\n\n- `onRequest` - Called before the request is handled by the router\n- - It has `endResponse` method that accepts a `Response` object to short-circuit the request\n- `onResponse` - Called after the request is handled by the router\n- - It allows you to modify the response before it is sent to the client\n\n### Cookie Management\n\nYou can use `useCookies` to parse cookies from the request header and set cookies in the response by\nusing Web Standard [CookieStore](https://developer.mozilla.org/en-US/docs/Web/API/CookieStore).\n\n```ts\nimport { createRouter, Response, useCookies } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [useCookies()]\n})\n\nrouter.get('/me', async req => {\n  const sessionId = await request.cookieStore.get('session_id')\n  if (!sessionId) {\n    return Response.json({ error: 'Unauthorized' }, { status: 401 })\n  }\n  const user = await getUserBySessionId(sessionId)\n  return Response.json(user)\n})\n\nrouter.post('/login', async req => {\n  const { username, password } = await req.json()\n  const sessionId = await createSessionForUser({ username, password })\n  await request.cookieStore.set('session_id', sessionId)\n  return Response.json({ message: 'ok' })\n})\n```\n\n### CORS Management\n\nYou can also setup a CORS middleware to handle preflight CORS requests.\n\n```ts\nimport { createRouter, useCORS } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [\n    useCORS({\n      origin: '*',\n      methods: ['GET', 'POST', 'PUT', 'DELETE'],\n      headers: ['Content-Type', 'Authorization']\n    })\n  ]\n})\n```\n\n### Custom plugins\n\nYou can also create your own plugins to handle errors, logging, etc.\n\n```ts\nimport { createRouter } from '@whatwg-node/router'\n\nconst useRequestId = (): RoutePlugin => {\n  return {\n    onRequest({ request, fetchAPI }) {\n      let requestId = request.headers.get('X-Request-ID')\n      if (!requestId) {\n        requestId = fetchAPI.crypto.randomUUID()\n        request.headers.set('X-Request-ID', requestId)\n      }\n    },\n    onResponse({ response, fetchAPI }) {\n      response.headers.set('X-Request-ID', request.headers.get('X-Request-ID'))\n    }\n  }\n}\n\nconst router = createRouter({\n  plugins: [useRequestId()]\n})\n```\n\n## Type Safety with TypeScript, JSON Schema and OpenAPI\n\nThis library is written in TypeScript and it provides type safety for your request and response with\nthe power of JSON Schema.\n\nTo define type-safe routes, we use `addRoute` method with specific parameters.\n\n#### Typing the request\n\nYou can type individual parts of the `Request` object including JSON body, headers, query\nparameters, and URL parameters.\n\n##### JSON Body\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nrouter.addRoute(\n  {\n    method: 'post',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        JSONBody: {\n          type: 'object',\n          properties: {\n            title: { type: 'string' },\n            completed: { type: 'boolean' }\n          },\n          additionalProperties: false,\n          required: ['title']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const { title, completed } = await request.json()\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Headers\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nrouter.addRoute(\n  {\n    method: 'post',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        Headers: {\n          type: 'object',\n          properties: {\n            'x-api-key': { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['x-api-key']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const apiKey = request.headers.get('x-api-key')\n    // Would fail on TypeScript compilation\n    const wrongHeaderName = request.headers.get('x-api-key-wrong')\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Path Parameters\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nrouter.addRoute(\n  {\n    method: 'get',\n    path: '/todos/:id',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        PathParams: {\n          type: 'object',\n          properties: {\n            id: { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['id']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const { id } = request.params\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Query Parameters\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nrouter.addRoute({\n  method: 'get',\n  path: '/todos',\n  // Define the request body schema\n  schemas: {\n    Request: {\n      QueryParams: {\n        type: 'object',\n        properties: {\n          limit: { type: 'number' },\n          offset: { type: 'number' }\n        },\n        additionalProperties: false,\n        required: ['limit']\n      },\n    }\n  }\n}, async request => {\n  // This part is fully typed\n  const { limit, offset } = request.query\n  // You can also use `URLSearchParams` API\n  const limit = request.parsedURL.searchParams.get('limit')\n  // ...\n  return Response.json({ message: 'ok' })\n})\n```\n\n#### Typing the response\n\nYou can also type the response body by the status code. We strongly recommend to explicitly define\nthe status codes.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nrouter.addRoute(\n  {\n    method: 'get',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        Headers: {\n          type: 'object',\n          properties: {\n            'x-api-key': { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['x-api-key']\n        }\n      },\n      Response: {\n        200: {\n          type: 'array',\n          items: {\n            type: 'object',\n            properties: {\n              id: { type: 'string' },\n              title: { type: 'string' },\n              completed: { type: 'boolean' }\n            },\n            additionalProperties: false,\n            required: ['id', 'title', 'completed']\n          }\n        },\n        401: {\n          type: 'object',\n          properties: {\n            message: { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['message']\n        }\n      }\n    }\n  },\n  async request => {\n    const apiKey = request.headers.get('x-api-key')\n    if (!apiKey) {\n      return Response.json(\n        { message: 'API key is required' },\n        {\n          status: 401\n        }\n      )\n    }\n    const todos = await getTodos({\n      apiKey\n    })\n    // This part is fully typed\n    return Response.json(todos, {\n      status: 200\n    })\n  }\n)\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"77f3e42ba4100fd008d5d686b21a8145f3e20efe","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.1","dependencies":{"tslib":"^2.3.1","openapi-types":"12.1.0","json-schema-to-ts":"2.6.2","@whatwg-node/fetch":"0.8.2-alpha-20230223141917-77f3e42","@whatwg-node/server":"^0.7.0","@whatwg-node/typed-fetch":"0.0.1-alpha-20230223141917-77f3e42"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.4.0-alpha-20230223141917-77f3e42_1677161986915_0.8913587345199556","host":"s3://npm-registry-packages"}},"0.4.0-alpha-20230223143304-9f436b0":{"name":"@whatwg-node/router","version":"0.4.0-alpha-20230223143304-9f436b0","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.4.0-alpha-20230223143304-9f436b0","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"e501f4c105cfeb524e11595c1111b645230d287b","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.4.0-alpha-20230223143304-9f436b0.tgz","fileCount":9,"integrity":"sha512-gU5EenUsJZ6TnRwLDwqrb4p8+I01+GTe7NQUeXjV+XcE7Me9qZaJeWIo13Qv2g+ikRuQpIO4oSlR9+qr2ohWVw==","signatures":[{"sig":"MEUCIFaR/Z+TwbTfyY5BqCXe5NFe5srBhBDxkpZzq2kDYkzpAiEAhQRtB9QgxWbDBxZpeXKMB4FuuKwApRcscx22S50HgAI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":45501,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj93k5ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmqk1g/+N+TpOQZyZP/pAC+zguojXX30mTCYa07aeIa5DlZGNc8SASKS\r\nEFg0GVqGE+bI8mOJZ1bzXjRdhYIABuFwd0PLa5dTcSZ6KdKjwXK5KD7uBpY0\r\nw30x1WBpamzAbZC7Xp1X3jVC07dYQfC7T5eyAvQVg2/SsE1f1tbZXv19sI7B\r\nIQNoo1dSqqiGik7CytVu8Sv/dY6W6Gp8vgPvzl08wE3bgxs/FnY+Y8IfJuIR\r\nBRbyW3LCFcWgMCht+c0HZpyP3da+ADu8hMOaW8CFxZtGOQyrkTi2BdxVe6Nz\r\nW6373CfmDOc36eYj0ZFzS3yT5clbrfNE+53MpB6klX0IWYdY6io/S/ZADk3s\r\n+Ip5JTL4lAg7MrppmMw9snEATToi8qfLyc2WQ8CET2Wx7R11+hok5LggOevb\r\nVOMT+/uGQSOPvIeYWQuXsrD3POJXNvXiI9GRarJhAcjdwYru5slRDvf7I5nc\r\nRJNDlqjWMMCpGOyACYKcf95FnwIVCjxDUfhacFHN5ua2IzdDwIVG7rJVE+vJ\r\nQNY9TI+QDVPJideeNLLkoyHcL9EzEMT5f3rVKJNqBdFhTKZ8XS8HsrkbBXkN\r\ng2LyjKu7uYLdQGIhleXVcaVTUEfkIVhZIWIIBOpyVOr/U/yTljanhuopXxnF\r\nN6yK6BWAvimZ/iiyyprV38eMIXXUn8U4GdI=\r\n=mRQB\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\n### Basic Routing\n\n```ts\n// Then use it in any environment\nimport { createServer } from 'http'\nimport { createRouter, Router } from '@whatwg-node/router'\n\nconst router = createRouter()\n// GET collection index\nrouter.get('/todos', () => new Response('Todos Index!'))\n// GET item\nrouter.get('/todos/:id', ({ params }) => new Response(`Todo #${params.id}`))\n// POST to the collection (we'll use async here)\nrouter.post('/todos', async request => {\n  const content = await request.json()\n  return new Response('Creating Todo: ' + JSON.stringify(content))\n})\n\n// Redirect to a URL\nrouter.get('/google', () => Response.redirect('http://www.google.com'))\n\n// 404 for everything else\nrouter.all('*', () => new Response('Not Found.', { status: 404 }))\n\nconst httpServer = createServer(router)\nhttpServer.listen(4000)\n```\n\n## Example\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors. Or you can use the plugins to handle errors like below.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Plugins to handle CORS, cookies and more\n\nThis library also provides a plugin system that allows you hook into the request/response lifecycle.\n\n- `onRequest` - Called before the request is handled by the router\n- - It has `endResponse` method that accepts a `Response` object to short-circuit the request\n- `onResponse` - Called after the request is handled by the router\n- - It allows you to modify the response before it is sent to the client\n\n### Cookie Management\n\nYou can use `useCookies` to parse cookies from the request header and set cookies in the response by\nusing Web Standard [CookieStore](https://developer.mozilla.org/en-US/docs/Web/API/CookieStore).\n\n```ts\nimport { createRouter, Response, useCookies } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [useCookies()]\n})\n\nrouter.get('/me', async req => {\n  const sessionId = await request.cookieStore.get('session_id')\n  if (!sessionId) {\n    return Response.json({ error: 'Unauthorized' }, { status: 401 })\n  }\n  const user = await getUserBySessionId(sessionId)\n  return Response.json(user)\n})\n\nrouter.post('/login', async req => {\n  const { username, password } = await req.json()\n  const sessionId = await createSessionForUser({ username, password })\n  await request.cookieStore.set('session_id', sessionId)\n  return Response.json({ message: 'ok' })\n})\n```\n\n### CORS Management\n\nYou can also setup a CORS middleware to handle preflight CORS requests.\n\n```ts\nimport { createRouter, useCORS } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [\n    useCORS({\n      origin: '*',\n      methods: ['GET', 'POST', 'PUT', 'DELETE'],\n      headers: ['Content-Type', 'Authorization']\n    })\n  ]\n})\n```\n\n### Custom plugins\n\nYou can also create your own plugins to handle errors, logging, etc.\n\n```ts\nimport { createRouter } from '@whatwg-node/router'\n\nconst useRequestId = (): RoutePlugin => {\n  return {\n    onRequest({ request, fetchAPI }) {\n      let requestId = request.headers.get('X-Request-ID')\n      if (!requestId) {\n        requestId = fetchAPI.crypto.randomUUID()\n        request.headers.set('X-Request-ID', requestId)\n      }\n    },\n    onResponse({ response, fetchAPI }) {\n      response.headers.set('X-Request-ID', request.headers.get('X-Request-ID'))\n    }\n  }\n}\n\nconst router = createRouter({\n  plugins: [useRequestId()]\n})\n```\n\n## Type Safety with TypeScript, JSON Schema and OpenAPI\n\nThis library is written in TypeScript and it provides type safety for your request and response with\nthe power of JSON Schema.\n\nTo define type-safe routes, we use `addRoute` method with specific parameters.\n\n#### Typing the request\n\nYou can type individual parts of the `Request` object including JSON body, headers, query\nparameters, and URL parameters.\n\n##### JSON Body\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nrouter.addRoute(\n  {\n    method: 'post',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        JSONBody: {\n          type: 'object',\n          properties: {\n            title: { type: 'string' },\n            completed: { type: 'boolean' }\n          },\n          additionalProperties: false,\n          required: ['title']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const { title, completed } = await request.json()\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Headers\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nrouter.addRoute(\n  {\n    method: 'post',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        Headers: {\n          type: 'object',\n          properties: {\n            'x-api-key': { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['x-api-key']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const apiKey = request.headers.get('x-api-key')\n    // Would fail on TypeScript compilation\n    const wrongHeaderName = request.headers.get('x-api-key-wrong')\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Path Parameters\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nrouter.addRoute(\n  {\n    method: 'get',\n    path: '/todos/:id',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        PathParams: {\n          type: 'object',\n          properties: {\n            id: { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['id']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const { id } = request.params\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Query Parameters\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nrouter.addRoute({\n  method: 'get',\n  path: '/todos',\n  // Define the request body schema\n  schemas: {\n    Request: {\n      QueryParams: {\n        type: 'object',\n        properties: {\n          limit: { type: 'number' },\n          offset: { type: 'number' }\n        },\n        additionalProperties: false,\n        required: ['limit']\n      },\n    }\n  }\n}, async request => {\n  // This part is fully typed\n  const { limit, offset } = request.query\n  // You can also use `URLSearchParams` API\n  const limit = request.parsedURL.searchParams.get('limit')\n  // ...\n  return Response.json({ message: 'ok' })\n})\n```\n\n#### Typing the response\n\nYou can also type the response body by the status code. We strongly recommend to explicitly define\nthe status codes.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nrouter.addRoute(\n  {\n    method: 'get',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        Headers: {\n          type: 'object',\n          properties: {\n            'x-api-key': { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['x-api-key']\n        }\n      },\n      Response: {\n        200: {\n          type: 'array',\n          items: {\n            type: 'object',\n            properties: {\n              id: { type: 'string' },\n              title: { type: 'string' },\n              completed: { type: 'boolean' }\n            },\n            additionalProperties: false,\n            required: ['id', 'title', 'completed']\n          }\n        },\n        401: {\n          type: 'object',\n          properties: {\n            message: { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['message']\n        }\n      }\n    }\n  },\n  async request => {\n    const apiKey = request.headers.get('x-api-key')\n    if (!apiKey) {\n      return Response.json(\n        { message: 'API key is required' },\n        {\n          status: 401\n        }\n      )\n    }\n    const todos = await getTodos({\n      apiKey\n    })\n    // This part is fully typed\n    return Response.json(todos, {\n      status: 200\n    })\n  }\n)\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"9f436b01ea0c3820f926f22397da28060b7fdba5","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.1","dependencies":{"tslib":"^2.3.1","openapi-types":"12.1.0","json-schema-to-ts":"2.6.2","@whatwg-node/fetch":"0.8.2-alpha-20230223143304-9f436b0","@whatwg-node/server":"^0.7.0","@whatwg-node/typed-fetch":"0.0.1-alpha-20230223143304-9f436b0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.4.0-alpha-20230223143304-9f436b0_1677162809036_0.4478997340493507","host":"s3://npm-registry-packages"}},"0.4.0-alpha-20230223162156-200d60c":{"name":"@whatwg-node/router","version":"0.4.0-alpha-20230223162156-200d60c","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.4.0-alpha-20230223162156-200d60c","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"88c022d03c96f065d91fb52d199d658b0fa933b6","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.4.0-alpha-20230223162156-200d60c.tgz","fileCount":7,"integrity":"sha512-EcuWfPWhZD0LAKL3OzfD46Enf9UEg/wJjkOLXDyTtfXGNZFaqMvO7+1NovsHCk8QwehWanNl8SR4S89zQwmg+A==","signatures":[{"sig":"MEQCIC/fd+uMRy2jkBtN7LLJN8qSU56oLtM90TjO9OZyFrgOAiA4qcZ8+aD1M9zKMKeVz1CvGH95eGIdpXgJJcUWP3UUiw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19308,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj95K3ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrbWhAAnEdYr6nryFG12oQ+LnpMUodJBEqPyeb4gp3Dt54CEjBLppVH\r\n7MvrDrgUDhzm8iabjxJJJZdzAwEY27C2D4XZ77KZhTKHBz23P8Pm7sPvLg2a\r\ngkUHbdQ5ZH7jVqiwcVr9BTQYTeTHHv+Wq8KC1JX8smJUBnd9WMDOiKNAGJp8\r\n2sswVks3kq4l2Z3s/NhqEPQq6JJHP+9BPaKAHbwie+bM333wkAORcVzJdbb6\r\ncJy5tzzgGvqzfLawb2atxPfgjD040yvDMaZN+G54hN/2ot1g7tC4mKM0vrAX\r\nFre6HosA5Xds2qTyC6Ka9zdia5LatrITmSEk0dZSVY8nYOxyULESZ9wYoNNx\r\ndDiRrE/adTkqkF2B6vfEfHImMg15vlvcB/i2h6Y+p+At+vOp8gnzme+bRdVv\r\nfjMSjyHeINjtwwFUvkrnL58FBPwNROI32pjaMuTc2koC/JYJfjr5sjZNLwgZ\r\nsD8m8Iu1s/ArhWGTdCGmD7kX+9tmesi2rvUn0fpgBywqav/aaG82IRB+YCvL\r\nyplUzDwd41s4m5VqA9GKK9bg96dPl9chYateiNSj9Mb4zDP/jSf7p6sZs86J\r\npIEA9Lvr+1FA6g6c/HTbHx0Z+osAxwA6k4CtmbfcasokBRtl5Mn9NWQfxagc\r\nEzDWx4wDu7T3QD0tuSHDruB/4Ef1tZ9GIMU=\r\n=fBVZ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"200d60c95278db84aa6559b14e933365415dcacc","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.1","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"^0.8.0","@whatwg-node/server":"^0.7.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.4.0-alpha-20230223162156-200d60c_1677169334845_0.09866201970127908","host":"s3://npm-registry-packages"}},"0.4.0-alpha-20230223202135-67801d4":{"name":"@whatwg-node/router","version":"0.4.0-alpha-20230223202135-67801d4","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.4.0-alpha-20230223202135-67801d4","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"5af1d978f7bd2e7c399f2d9e710ab0cdbb94d9d6","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.4.0-alpha-20230223202135-67801d4.tgz","fileCount":7,"integrity":"sha512-KIvYK+2TlsmlDWlc4frnQHehbqtKfnF5pPfZ6iXyWMUezGDHihqbCWE7m4nFODi7s/XSXOnWZ/CF8CZvjkwLcg==","signatures":[{"sig":"MEUCIECHjEQ5No6esmiZstZYgx7UYwVYlCQ6NsIP4hRmd2Y7AiEAvaEiueMEydNfQELzE0nVAHo8PTfnd4aaHyhKM27Lzdg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19308,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj98rdACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrlqQ/+IYLG/ZEmGkNw+s9BX1a3osWu2OR7NqYbBCXrcY+rzqKtjJlX\r\n0DQ4BkMJVNDVFbohXMxyTocpustmDmPetHnYFrwOY5guN13kH6sfFKVwhURR\r\nAl1oQY7Ba9BbG2oCez5R5/1zD6NTAki94Zr0jvANsT3kmEmYHMPuAJDMSR8K\r\n6coMj0vcQ/GxiIi3mSuG8hCD4FPiejj5o+ceLyOzpPGCM2vaovDyNC8ti2oj\r\nZ84I7dcNKfrsbzWxQ8fJ5yZtkmXrBBHJ/QjSq+idaYdnVtRZoe3y9pvKvi/x\r\nUcG13YDNqXOJyXm7LFSg54/asoga4QkWM5rHFeVW5WxTIquIVp7ygaTPkICj\r\nzT4gv2pBKL81NgLWxq6hV/JcZp3MmwkBadKVoScHA72SoPJg1Rzipi4HENZK\r\ngR5MPdnTeKleXQLaApLsLqjWrseHIEC7tXB+I0L3QkekBcszPFEAVAKMEfrw\r\n1P6WTV54P40GYBP3AeEzhcPCbNpiQtXJhTzK7NUYg1LZT+I07ZuHQtJW86r2\r\nlJHqCbuV5aVt1gRVnQrCrOUaIreHbgLBgnZWVl9LqO+3iAVjykyg6GiJxHfb\r\nETZDWTY+nbP86s5YULjo8NFvwHZ3uSIgxeM7b/O2tRMtnhBCQ1+hiDf1zJx4\r\nYoDZFBBPxFPbrQw8ZqV3bG+qb5RU+2F0HKE=\r\n=xCuR\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"67801d481b09315095711e5485989fd0aa770002","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.1","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"^0.8.0","@whatwg-node/server":"^0.7.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.4.0-alpha-20230223202135-67801d4_1677183709449_0.19082715257995497","host":"s3://npm-registry-packages"}},"0.4.0-rc-20230223204558-baafc65":{"name":"@whatwg-node/router","version":"0.4.0-rc-20230223204558-baafc65","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.4.0-rc-20230223204558-baafc65","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"f2bc52b04cff92b4eb6b2a9b79ec087fd3352474","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.4.0-rc-20230223204558-baafc65.tgz","fileCount":7,"integrity":"sha512-uoV6SkXzHEaPs6RgB4wtfuGcoqwLsBckDXZNYQLl9QiYZFa9VXWsbiDqdDlfHatebfEc+7QthmecSkDV5XBxrg==","signatures":[{"sig":"MEQCIBQ48H1Ie+jPUt8Qds/H1881y4QUFAQuEMWMnjzU0dWmAiBhuTr3pgjO5yQoszA2ScZwXVHw35r/yQfRD1+rnjFNFw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19305,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj99CVACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqmvBAAnjKKpTFhM1uRRQMqdG4hcT+kyx/+OPM8SWomXWs703cscg/H\r\n0l7VtqUtCSO5yqK4G5hwnbcP3fKifvHK5Gn6RliMkdyYhgssekv7kJUK9qzA\r\n09bmGp2FclhM5Z6JJLDV6FdslHNMzU5uRPDVVT9mi0kG5Saf95GhFGAeNtrR\r\nolHlTfmOkT2qHhrupniN3j6UrGVnDhRxTh7e5BnqLgFCk/m2IrT2bXQ+2eNQ\r\nWXJlMPSvObq7Tq7jB5rzZHgAXDWmsqDxe0F0XIDCvSitgawwo57TIkWUc0Cu\r\ntj7wiep45gQqSYTx93aJUzz0iNxb+vhZoRAs++Miv44N63I2Ve8FyD8qEmry\r\nnZQuMcLdv7zWGHBDTtvciK02E2Y/m5ZbN/fn23VwnRUuzPRMg9xp4Uy6hQm7\r\nUYAOMAic3aNGZsGzjD4uC7bUWaCdXwyqm/aw2yxcOINQHtEXTX1fWvxVQt2a\r\nuR915jNfMwqI4EXc+RCVTIuvQMf+lpYklxe1skoPzRuGt564KCP4cI3uKuFR\r\neiRpRjgOd/jz1wt5xSUCnv94GETcZMlaDq3YlXDzZg17Ly8zWHDNG75y35l5\r\nq3rGG8CIfp0Sa6PqCqzrIS6nDOtQLUlJ/hDQ5Ph2MmKF52H1mgRg8pwFc3i0\r\n/cRlZ9ODwJliGdfEsTMAJPTbgNZfxdmofpY=\r\n=6rn9\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"baafc65cff42ddcae5cf614abd7b09094d903c6b","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.1","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"^0.8.0","@whatwg-node/server":"^0.7.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.4.0-rc-20230223204558-baafc65_1677185172889_0.06542613167259237","host":"s3://npm-registry-packages"}},"0.4.0-alpha-20230224012919-d66ad8a":{"name":"@whatwg-node/router","version":"0.4.0-alpha-20230224012919-d66ad8a","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.4.0-alpha-20230224012919-d66ad8a","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"f6a3378d5d05f52ce2d38195f99fde57b65ee49a","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.4.0-alpha-20230224012919-d66ad8a.tgz","fileCount":7,"integrity":"sha512-nBA8dLxwWglPBQpjGRzQbfFy/Y58GsBmiXna6mVlEbEIh6wRdQS+tDkt/oqm8al0l76am75fKRVPDi5RnheTZg==","signatures":[{"sig":"MEQCIGs3CK+8MpBaPwpfewLLgVa5mftfk+/89ZMBSwVix14mAiAchq5ZmL2n8MepNsz8qqo/EHUvPMwaCywaUewDmhAe3Q==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19308,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj+BL9ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqtaBAAlE08dpm7ynGdAlbAI6/IgaWYWhq2W28W02OVKG2N7w4eKldW\r\n4KdDjIIbh99HWiuW4nHnvlnh5T/PX0+32ZGG6SjvmeG/sw0K6forfi/VpsY5\r\nYKPpZ+XMTpQUoqjZs4Gmgi7MYhhthBMuoTsDJ6vLRq78wlV6m80Z5SofZ1F8\r\nduCnhwmwzD8Kypv5muy84vbODKHKdcGJDFhjJSeO0okFiIa1cgWF40AwEEiV\r\nZaBfof9xM+7fYpwRfDFBe8EW438EGcvxfCHC6UbFkGILnuvuZMJPbq9jiu0r\r\nJwsMPqChTetbCF2BjlOmHTCjaph360k/+7lcYJlDZzAyKPb6ePYQ4/1qLsg2\r\nrPwC7EEnhkHhktZBKJAeR6CDczgp5lAkD/kgWlFBCvomGExM3xO6xPV1sg4s\r\npV5emFz+hmT0fAWkgJo7wKVki0OFW251sm4ys7sM+wsLED6aGqVjOFIbvpAC\r\no7S1FIPi3eVBDE2apwjSLZfn/5MHDcET7FiMsp6q0XXfIoUxLFqhmV0vWd37\r\nhqviqU1Vj3v80aMGJpjbquGOghhfkC16xBdx11JVMuggPyBEqxpRmLPXexsV\r\n7FDKUEd+ngNUdgcaFSBPUp+HtcAAvKLtpMUc7dLqnxBqEC7dpxnBqhtwxm4f\r\nupviIx/BH2OoyW/rgL38j4iDh+n1ep2CgXA=\r\n=BGB4\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"d66ad8ab931a14ec7ec682378f869e43b7a63ef2","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.1","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"^0.8.0","@whatwg-node/server":"^0.7.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.4.0-alpha-20230224012919-d66ad8a_1677202173699_0.6611296338916257","host":"s3://npm-registry-packages"}},"0.4.0-alpha-20230224053228-01ba7b6":{"name":"@whatwg-node/router","version":"0.4.0-alpha-20230224053228-01ba7b6","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.4.0-alpha-20230224053228-01ba7b6","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"86bb7dbdbb57b1bf1f2d889f1449c702228b9abf","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.4.0-alpha-20230224053228-01ba7b6.tgz","fileCount":7,"integrity":"sha512-CC4oQteUc1weaIDpaJPWL93XbpcqxMC8sxjnME2xfaTlWL5lhJwFPfZLnDV5vs3pNg5aHia2Mr4sQn3++mTQug==","signatures":[{"sig":"MEUCIDZ+r1oMDn/rWAa68p6MTlqc7eXr11zggxMsudGgL5mnAiEAms3Odmsc+fMsjGwYwEXS+LOdG9D8BLtmexzSzHDy8/k=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19308,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj+Ev8ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpLwQ/+Ix5lJOnY7KGkSMNfL6uSwARrWVUPpWsn86kvys4qy0H6t0HJ\r\nbg0lyn40pWP7yeP+f8VG1tVDNNR/G9T4og6+3emVDdHsNsLrbzAhklOVVQIU\r\nzwAqJXLMS1VagLzA3KY+ZMjGl7AnBrwDTEcpMwb5dr+W3fbsA8WpUfFMk8se\r\ncj/nhPYW3cTEtdAtUTqEHrevOteCdDvfrWZu7GMFnN7TjNDK09wc9ct0NQU3\r\n0UzST62GdvD+lKEKg70PC+FwLTRKst3wcEQAm6coyNtpbF2xktRImEmaRYvi\r\n10IbAR8Bf2qpW6oAMcS17fzHIiX+bIz73T/INDtw29Fex1LCZ+rOKEYssknu\r\niWnDj4IE9j6IQA+eUsREP06GFNgoRGKhdFkcRqwIwLvo1s2VX3xEhLLrKCIh\r\npyRiNttbRhd4rvaA8GXEMwxqJ0cBzEFddhY8xWpaohzGogHp+V7WE+G3D9VL\r\nedOsKGYtd8drKTiyPX0V8VhHE9sTjaddGR7t3D3C3UrqSJy5B1TzfJFvD1d4\r\nAYe2I3Frd2O3kc6zY4H1i+bbIh42WSwKuqux2exmFM/1kvMjLonfls0YjysY\r\ndwsiYkc49LMTuJZwGg46Grdy0XYopPqEWsUcWskIt9NEtXBkPRBG1vJuiC74\r\n4Wx4Cw4TZ/OFxWPGAtEwzXZchpmQ5+4HW0o=\r\n=rnrm\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"01ba7b6f929f4e5e0ded7166cf7a22305c6d2f28","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.1","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"^0.8.0","@whatwg-node/server":"^0.7.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.4.0-alpha-20230224053228-01ba7b6_1677216764426_0.9863722730682098","host":"s3://npm-registry-packages"}},"0.4.0-rc-20230224053308-85b327d":{"name":"@whatwg-node/router","version":"0.4.0-rc-20230224053308-85b327d","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.4.0-rc-20230224053308-85b327d","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"19880fe1bdb7943934e06350e2fdd45527dad125","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.4.0-rc-20230224053308-85b327d.tgz","fileCount":7,"integrity":"sha512-FHqQtfRzavw19XYEGrHnmJFrHH4V9u/lVlhQ9ihaefCMGETt7g+hW/p9bA90a6pIkaAXjCl8yg/sJzLpQmYfqg==","signatures":[{"sig":"MEUCIQCTBQIx6stEly4X8mXd7P+yjTAf1CgbVdxMKzZshsFUXAIgZQyffoMcyGIZ1Sx1KMkYTpdzTPI2sporJG4PteaSyWc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19305,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj+EwjACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrepBAAgs536p3GIXs5+0OLHXt+479h6u/2l7B4oakacTVwj/c3at/B\r\nRZ/nCoVM9y87PejfvsRNO1fDLQEzdpS3F421Ba6SArPBTklc/R0+NB8CaoMU\r\nqC9UwmqPnJYyLkt+nVmyii8IYQnNGk/m/s0StLsoNekeIJzWvLqhV3g+8ey3\r\nZvXJhBqZi4Le24yjqT7avHwSdT/vZIAF1XGCKTEQbWlBl18HVbreugHrRpIT\r\njxVya7qDo0w6+dRJiE+fss7wvN1FhslSfdsByDla8LaBdpNDxe5vwkVGieE7\r\nlj7PpfOCmCdVVRV5fMsv84dS34nauQlsY2Q1DjpwsQv0QQ3iudWuJ1TKMU9U\r\nitQj8dRGmVxHFzsclGiIzQS7fEzoHeJjOyk5B0xBy7aC1DGm3AXvRw/Ujjw4\r\nY0UviB5ztEmYiEvGqSzCXszJd9eS+PZeAvmXt5gruUUovu/BmeZeT9FuPv4/\r\n3TVS0xwJBkQlGH3JmJFYYnF+53e2rGnwbIjoGgmNfXs/qTDQshK7jP+NczhF\r\n9am9hGYr1OURf3wsK0GzNF0M83NqnxTwvbLim7PcvzXriba7Tc3Zfnyd6Uj5\r\nwR/tCnMRNtpS/oZAYOyfAn644hrV1fEIYBhmLKI14T5MCWzVHOMQ5lkPbc9y\r\nhuauXkZqlD5jVayBqdhFINctBrGTGlNswyg=\r\n=MdJb\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"85b327d698e3f820ce25f72a9f04274eadf20138","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.1","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"^0.8.0","@whatwg-node/server":"^0.7.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.4.0-rc-20230224053308-85b327d_1677216803799_0.0301707982614301","host":"s3://npm-registry-packages"}},"0.4.0-rc-20230224070404-60c7fd4":{"name":"@whatwg-node/router","version":"0.4.0-rc-20230224070404-60c7fd4","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.4.0-rc-20230224070404-60c7fd4","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"42e47b6eaefa91042c2b4fb6a91f9aaab3cf07cc","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.4.0-rc-20230224070404-60c7fd4.tgz","fileCount":7,"integrity":"sha512-1ZvLcc9RSaGq6u58nRH/4yecNXUslquDTc6NlUDTwKnSRmbVTRYS8OcjVBFya4R8gx07ku3ybeh2+hAn0vNjhg==","signatures":[{"sig":"MEQCIFwgXF/f6fb66jrkGlrtMS6JMg7ptDk0/dPwzI7UJ2HcAiAYzOeci2P++K/K4A7A2DzlRkpy0zTixf7MA2j73KmE5w==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19305,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj+GF1ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpEDg//bXmCTgxCIpirWvnoWaHLZ0juWGp3q2plCMXlZYuxw/zpS8Lj\r\nz1zIRSWVm9R2BaJ0GB3wkpKEwXcnz80EtE9sHu+wNmA36XWcW1xkWoaTOmLD\r\ndVlsbrJ6IBcNVIC1rghRTJB5QvyKJOK/z+ST1Wnflrtg+LZzOLxzYhh3Q2oh\r\nTZGRf6ylxD9tzdSwztynp1laXof6WG05UYJbSt9F/uiJUdq+Gdig3EL0KDCx\r\napyro4YEBGFfXbW52e8xOnhkPy7/P+8pIIrU0nONXG4WakHl8/79JHhBoxgI\r\nqHLb1HrPYGw6vKdYV7LJjsKKPAFtyahsfkAIJfVRCk50QnYJ2Du7kVRLG+5P\r\nZyaFL5sIyRFM9i1Dcr0/nWwpLvJrMlVTYeVzCBac2hBMa2NvFI5J3h2guFDO\r\nzCEXEyCgd9ek76/StbN8V4ydw8b7LPJAKo4muvFt+AKiIhIAZD44NBwXS+7K\r\nKcyit3u83DKzWEBcXnXfKyh02Q6m/h2rvBRgTl++IaBHhumX4785vSQYE+I4\r\nglAtIR6dNB7HwdW9nclkoQsbd7c7oFRGdo4Ru5ZSFPp8Xjm1yJIDTAWAuKkj\r\n4bEqWJ9VpVqaPOY5RznPkd/48aA950fYfGuNpeY1nyuPzbw/mnnX7p99wPl3\r\nhKwu50Ygjs5Pk2Azj8eHWxTp6HO5spKAZRY=\r\n=10Mp\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"60c7fd4aecfcf171ac0281449c9ecffd012ecda7","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.1","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"^0.8.0","@whatwg-node/server":"^0.7.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.4.0-rc-20230224070404-60c7fd4_1677222261426_0.7796692086147843","host":"s3://npm-registry-packages"}},"0.4.0-alpha-20230224121407-a1be8e1":{"name":"@whatwg-node/router","version":"0.4.0-alpha-20230224121407-a1be8e1","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.4.0-alpha-20230224121407-a1be8e1","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"db8c576ee5f1420cab524985c1050c52d7ab56df","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.4.0-alpha-20230224121407-a1be8e1.tgz","fileCount":10,"integrity":"sha512-ipxAOlmX7Kv+HEU8wRZvkl021UHC8zdP8803F8owqnELjeCsrjE2KvEypnk+4wM2BaK0+Q/28aj1XmmmEDo14A==","signatures":[{"sig":"MEUCIDMj+x6UwyYhz6loIL6HphKHeuR/MzJg3w7phOZc5tgnAiEAqEFeNDPyWOzUcVO2kNr7OPlUm9ufrapRCxb2vVPxS5g=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":48235,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj+KooACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmow+A//VhOqqhFDPxMg66xIK9cQfF5qN7Hd/wa3x4YPtcTAiTUyPxv7\r\n9H0Vp//1BTTv9BMRFQGfvsHtR7Lro7n2edSiB8xdKSbL/gGVeNZSO2R/iewJ\r\nyyzzZ/9dzuodPWkE/XIaWX3oLWqfxJZ0jEeHVlpSua/0JW+eWp7/PBypobNz\r\nczQ/ILJ9LoiV8YkgZL2Ork2cSinZbljKgADxWODNIP1iN5vRMMwI1z/hraNU\r\nOpXaFxG9fbLx2BdIcNMsl1KHfn/suKHGh7XYmdAVWb//UsZLt4mK6lEZAnun\r\nNywcG792HTVk/tegKUWeV9/fh/IDrNRG6PTLft8NcrJF6N58XVwlB+kxWbu6\r\nyQSi2YM2muwy61ix5q1QJ9Ic3hqPFTnqQScPzMNbe1XBa+XjiUrPPmEI3K8V\r\noJChgoaBxOyvxxBFOiMeGazkMHAOuSAuKTe9pNNwEDQmaRvdA5hG/CBHXQo2\r\ndS2lF2WVvseqZlAEj59KjArZVlfflSOpngW9seogiIUSRpSmk/K03gGdUUjs\r\n5xirQ0HKZvBDuayZ6HgKt2FlsJclbnU5lCVzmxZSPkwEMcRw9vt1AXp7/uNS\r\nd/cAgJM7dUurIZwc7Fz40hgTMwX+oxXWxb6SlTucuNvYb80dDg/ayCkoxRx1\r\nM7Nc9doNuqBfOA/tXoHZzB9RvZMrQhfAaNs=\r\n=8gp5\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\n### Basic Routing\n\n```ts\n// Then use it in any environment\nimport { createServer } from 'http'\nimport { createRouter, Router } from '@whatwg-node/router'\n\nconst router = createRouter()\n// GET collection index\nrouter.get('/todos', () => new Response('Todos Index!'))\n// GET item\nrouter.get('/todos/:id', ({ params }) => new Response(`Todo #${params.id}`))\n// POST to the collection (we'll use async here)\nrouter.post('/todos', async request => {\n  const content = await request.json()\n  return new Response('Creating Todo: ' + JSON.stringify(content))\n})\n\n// Redirect to a URL\nrouter.get('/google', () => Response.redirect('http://www.google.com'))\n\n// 404 for everything else\nrouter.all('*', () => new Response('Not Found.', { status: 404 }))\n\nconst httpServer = createServer(router)\nhttpServer.listen(4000)\n```\n\n## Example\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors. Or you can use the plugins to handle errors like below.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Plugins to handle CORS, cookies and more\n\nThis library also provides a plugin system that allows you hook into the request/response lifecycle.\n\n- `onRequest` - Called before the request is handled by the router\n- - It has `endResponse` method that accepts a `Response` object to short-circuit the request\n- `onResponse` - Called after the request is handled by the router\n- - It allows you to modify the response before it is sent to the client\n\n### Cookie Management\n\nYou can use `useCookies` to parse cookies from the request header and set cookies in the response by\nusing Web Standard [CookieStore](https://developer.mozilla.org/en-US/docs/Web/API/CookieStore).\n\n```ts\nimport { createRouter, Response, useCookies } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [useCookies()]\n})\n\nrouter.get('/me', async req => {\n  const sessionId = await request.cookieStore.get('session_id')\n  if (!sessionId) {\n    return Response.json({ error: 'Unauthorized' }, { status: 401 })\n  }\n  const user = await getUserBySessionId(sessionId)\n  return Response.json(user)\n})\n\nrouter.post('/login', async req => {\n  const { username, password } = await req.json()\n  const sessionId = await createSessionForUser({ username, password })\n  await request.cookieStore.set('session_id', sessionId)\n  return Response.json({ message: 'ok' })\n})\n```\n\n### CORS Management\n\nYou can also setup a CORS middleware to handle preflight CORS requests.\n\n```ts\nimport { createRouter, useCORS } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [\n    useCORS({\n      origin: '*',\n      methods: ['GET', 'POST', 'PUT', 'DELETE'],\n      headers: ['Content-Type', 'Authorization']\n    })\n  ]\n})\n```\n\n### Custom plugins\n\nYou can also create your own plugins to handle errors, logging, etc.\n\n```ts\nimport { createRouter } from '@whatwg-node/router'\n\nconst useRequestId = (): RoutePlugin => {\n  return {\n    onRequest({ request, fetchAPI }) {\n      let requestId = request.headers.get('X-Request-ID')\n      if (!requestId) {\n        requestId = fetchAPI.crypto.randomUUID()\n        request.headers.set('X-Request-ID', requestId)\n      }\n    },\n    onResponse({ response, fetchAPI }) {\n      response.headers.set('X-Request-ID', request.headers.get('X-Request-ID'))\n    }\n  }\n}\n\nconst router = createRouter({\n  plugins: [useRequestId()]\n})\n```\n\n## Type Safety with TypeScript, JSON Schema and OpenAPI\n\nThis library is written in TypeScript and it provides type safety for your request and response with\nthe power of JSON Schema.\n\nTo define type-safe routes, we use `addRoute` method with specific parameters.\n\n#### Typing the request\n\nYou can type individual parts of the `Request` object including JSON body, headers, query\nparameters, and URL parameters.\n\n##### JSON Body\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'post',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        JSONBody: {\n          type: 'object',\n          properties: {\n            title: { type: 'string' },\n            completed: { type: 'boolean' }\n          },\n          additionalProperties: false,\n          required: ['title']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const { title, completed } = await request.json()\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Headers\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'post',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        Headers: {\n          type: 'object',\n          properties: {\n            'x-api-key': { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['x-api-key']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const apiKey = request.headers.get('x-api-key')\n    // Would fail on TypeScript compilation\n    const wrongHeaderName = request.headers.get('x-api-key-wrong')\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Path Parameters\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'get',\n    path: '/todos/:id',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        PathParams: {\n          type: 'object',\n          properties: {\n            id: { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['id']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const { id } = request.params\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Query Parameters\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute({\n  method: 'get',\n  path: '/todos',\n  // Define the request body schema\n  schemas: {\n    Request: {\n      QueryParams: {\n        type: 'object',\n        properties: {\n          limit: { type: 'number' },\n          offset: { type: 'number' }\n        },\n        additionalProperties: false,\n        required: ['limit']\n      },\n    }\n  }\n}, async request => {\n  // This part is fully typed\n  const { limit, offset } = request.query\n  // You can also use `URLSearchParams` API\n  const limit = request.parsedURL.searchParams.get('limit')\n  // ...\n  return Response.json({ message: 'ok' })\n})\n```\n\n#### Typing the response\n\nYou can also type the response body by the status code. We strongly recommend to explicitly define\nthe status codes.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'get',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        Headers: {\n          type: 'object',\n          properties: {\n            'x-api-key': { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['x-api-key']\n        }\n      },\n      Response: {\n        200: {\n          type: 'array',\n          items: {\n            type: 'object',\n            properties: {\n              id: { type: 'string' },\n              title: { type: 'string' },\n              completed: { type: 'boolean' }\n            },\n            additionalProperties: false,\n            required: ['id', 'title', 'completed']\n          }\n        },\n        401: {\n          type: 'object',\n          properties: {\n            message: { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['message']\n        }\n      }\n    }\n  },\n  async request => {\n    const apiKey = request.headers.get('x-api-key')\n    if (!apiKey) {\n      return Response.json(\n        { message: 'API key is required' },\n        {\n          status: 401\n        }\n      )\n    }\n    const todos = await getTodos({\n      apiKey\n    })\n    // This part is fully typed\n    return Response.json(todos, {\n      status: 200\n    })\n  }\n)\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"a1be8e1c139bf6a519f76c90519730e073b2a4c5","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.1","dependencies":{"tslib":"^2.3.1","openapi-types":"12.1.0","json-schema-to-ts":"2.6.2","@whatwg-node/fetch":"0.8.2-alpha-20230224121407-a1be8e1","@whatwg-node/server":"^0.7.0","@whatwg-node/typed-fetch":"0.0.1-alpha-20230224121407-a1be8e1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.4.0-alpha-20230224121407-a1be8e1_1677240872261_0.29614095727732015","host":"s3://npm-registry-packages"}},"0.4.0-alpha-20230224123711-eff8ac3":{"name":"@whatwg-node/router","version":"0.4.0-alpha-20230224123711-eff8ac3","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.4.0-alpha-20230224123711-eff8ac3","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"13cc6572cc6b8e01d17e80ed385628bf07cc5a76","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.4.0-alpha-20230224123711-eff8ac3.tgz","fileCount":10,"integrity":"sha512-RREELskVDvmD26Ah0UwpdVFytj95c9SGYrbKjaOCoxN6RyAdwMEgZb8wtUF7RjPSElWJPaWj+Wxe6g2/robVFQ==","signatures":[{"sig":"MEQCIErNz2wnyByhU5zG3Ndu1HvHuNEAL2ln7W5KmgxL5+RmAiAcWRbNtxujijfXbvLLi6e+H3zzPFQ1PDIMey4+Jxthcg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":48235,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj+K+NACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqxRg//RBC6tixaF/10SGoNmU0mq6WIBv9/jfnODfgDJoJFGnqR+ccK\r\n0I/t17D8TDR7C11oVRVsXjEh+p+JfytgAhsXShT2pMPPtFCrHr/+HSHNRQkK\r\ngKogG1wcnxGlOA1tHvBYAzdwKVhO5c8ly/kUmev8kp854X2/QbLXtM1rVT8d\r\nhOKPMLRhmNyXGtNQf7kOmWSPdz2FA8Q848RISRQ1K4VAxyGE/BwVi/in7daa\r\nUdxsqfRAYQA70xVI/pFCLetXR93g2TPEr7axbKmEhFPjKJH3b6o8xOS9226J\r\ng/ISYjByNivxgtz/ijBhp2OaF5qcwbzPInXf7n75iVCELt29Qg9pKf2MrLVy\r\nsWnCwzqbKemWHFcNUWw2mD+qZn2quoarBgyVCE3V7rAeqFlJ1ZAs2U1rzSk0\r\n91wqOTLayFbQeBASK0uZlyy2ncanr33wtlaicMgpU73l0mUilvmM/Ed3C17L\r\n4YEcVbxUuWd2zCRxr2NZrTzBG71JUOQ1o2GUUlsXonz4wqPnp+63JY/P5N0F\r\nrNdrNw6lVM2GoBadpH4x15bhPtPJpTRVolyihaU81EtG3pGdKclsd7nFkTHP\r\n15AlDT6YlZBGEtw9fcws258XbZxFaIgtzBeiAngH1lO1fxF+O85fwaUBJgmX\r\n2hM6thHa5RBTu76tnJUAPEPMSEJpa8vF/uk=\r\n=fpaN\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\n### Basic Routing\n\n```ts\n// Then use it in any environment\nimport { createServer } from 'http'\nimport { createRouter, Router } from '@whatwg-node/router'\n\nconst router = createRouter()\n// GET collection index\nrouter.get('/todos', () => new Response('Todos Index!'))\n// GET item\nrouter.get('/todos/:id', ({ params }) => new Response(`Todo #${params.id}`))\n// POST to the collection (we'll use async here)\nrouter.post('/todos', async request => {\n  const content = await request.json()\n  return new Response('Creating Todo: ' + JSON.stringify(content))\n})\n\n// Redirect to a URL\nrouter.get('/google', () => Response.redirect('http://www.google.com'))\n\n// 404 for everything else\nrouter.all('*', () => new Response('Not Found.', { status: 404 }))\n\nconst httpServer = createServer(router)\nhttpServer.listen(4000)\n```\n\n## Example\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors. Or you can use the plugins to handle errors like below.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Plugins to handle CORS, cookies and more\n\nThis library also provides a plugin system that allows you hook into the request/response lifecycle.\n\n- `onRequest` - Called before the request is handled by the router\n- - It has `endResponse` method that accepts a `Response` object to short-circuit the request\n- `onResponse` - Called after the request is handled by the router\n- - It allows you to modify the response before it is sent to the client\n\n### Cookie Management\n\nYou can use `useCookies` to parse cookies from the request header and set cookies in the response by\nusing Web Standard [CookieStore](https://developer.mozilla.org/en-US/docs/Web/API/CookieStore).\n\n```ts\nimport { createRouter, Response, useCookies } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [useCookies()]\n})\n\nrouter.get('/me', async req => {\n  const sessionId = await request.cookieStore.get('session_id')\n  if (!sessionId) {\n    return Response.json({ error: 'Unauthorized' }, { status: 401 })\n  }\n  const user = await getUserBySessionId(sessionId)\n  return Response.json(user)\n})\n\nrouter.post('/login', async req => {\n  const { username, password } = await req.json()\n  const sessionId = await createSessionForUser({ username, password })\n  await request.cookieStore.set('session_id', sessionId)\n  return Response.json({ message: 'ok' })\n})\n```\n\n### CORS Management\n\nYou can also setup a CORS middleware to handle preflight CORS requests.\n\n```ts\nimport { createRouter, useCORS } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [\n    useCORS({\n      origin: '*',\n      methods: ['GET', 'POST', 'PUT', 'DELETE'],\n      headers: ['Content-Type', 'Authorization']\n    })\n  ]\n})\n```\n\n### Custom plugins\n\nYou can also create your own plugins to handle errors, logging, etc.\n\n```ts\nimport { createRouter } from '@whatwg-node/router'\n\nconst useRequestId = (): RoutePlugin => {\n  return {\n    onRequest({ request, fetchAPI }) {\n      let requestId = request.headers.get('X-Request-ID')\n      if (!requestId) {\n        requestId = fetchAPI.crypto.randomUUID()\n        request.headers.set('X-Request-ID', requestId)\n      }\n    },\n    onResponse({ response, fetchAPI }) {\n      response.headers.set('X-Request-ID', request.headers.get('X-Request-ID'))\n    }\n  }\n}\n\nconst router = createRouter({\n  plugins: [useRequestId()]\n})\n```\n\n## Type Safety with TypeScript, JSON Schema and OpenAPI\n\nThis library is written in TypeScript and it provides type safety for your request and response with\nthe power of JSON Schema.\n\nTo define type-safe routes, we use `addRoute` method with specific parameters.\n\n#### Typing the request\n\nYou can type individual parts of the `Request` object including JSON body, headers, query\nparameters, and URL parameters.\n\n##### JSON Body\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'post',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        JSONBody: {\n          type: 'object',\n          properties: {\n            title: { type: 'string' },\n            completed: { type: 'boolean' }\n          },\n          additionalProperties: false,\n          required: ['title']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const { title, completed } = await request.json()\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Headers\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'post',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        Headers: {\n          type: 'object',\n          properties: {\n            'x-api-key': { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['x-api-key']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const apiKey = request.headers.get('x-api-key')\n    // Would fail on TypeScript compilation\n    const wrongHeaderName = request.headers.get('x-api-key-wrong')\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Path Parameters\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'get',\n    path: '/todos/:id',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        PathParams: {\n          type: 'object',\n          properties: {\n            id: { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['id']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const { id } = request.params\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Query Parameters\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute({\n  method: 'get',\n  path: '/todos',\n  // Define the request body schema\n  schemas: {\n    Request: {\n      QueryParams: {\n        type: 'object',\n        properties: {\n          limit: { type: 'number' },\n          offset: { type: 'number' }\n        },\n        additionalProperties: false,\n        required: ['limit']\n      },\n    }\n  }\n}, async request => {\n  // This part is fully typed\n  const { limit, offset } = request.query\n  // You can also use `URLSearchParams` API\n  const limit = request.parsedURL.searchParams.get('limit')\n  // ...\n  return Response.json({ message: 'ok' })\n})\n```\n\n#### Typing the response\n\nYou can also type the response body by the status code. We strongly recommend to explicitly define\nthe status codes.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'get',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        Headers: {\n          type: 'object',\n          properties: {\n            'x-api-key': { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['x-api-key']\n        }\n      },\n      Response: {\n        200: {\n          type: 'array',\n          items: {\n            type: 'object',\n            properties: {\n              id: { type: 'string' },\n              title: { type: 'string' },\n              completed: { type: 'boolean' }\n            },\n            additionalProperties: false,\n            required: ['id', 'title', 'completed']\n          }\n        },\n        401: {\n          type: 'object',\n          properties: {\n            message: { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['message']\n        }\n      }\n    }\n  },\n  async request => {\n    const apiKey = request.headers.get('x-api-key')\n    if (!apiKey) {\n      return Response.json(\n        { message: 'API key is required' },\n        {\n          status: 401\n        }\n      )\n    }\n    const todos = await getTodos({\n      apiKey\n    })\n    // This part is fully typed\n    return Response.json(todos, {\n      status: 200\n    })\n  }\n)\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"eff8ac3542b131311ec50caead8257050164dd13","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.1","dependencies":{"tslib":"^2.3.1","openapi-types":"12.1.0","json-schema-to-ts":"2.6.2","@whatwg-node/fetch":"0.8.2-alpha-20230224123711-eff8ac3","@whatwg-node/server":"^0.7.0","@whatwg-node/typed-fetch":"0.0.1-alpha-20230224123711-eff8ac3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.4.0-alpha-20230224123711-eff8ac3_1677242252973_0.3897497728116246","host":"s3://npm-registry-packages"}},"0.4.0-alpha-20230224130759-d51f621":{"name":"@whatwg-node/router","version":"0.4.0-alpha-20230224130759-d51f621","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.4.0-alpha-20230224130759-d51f621","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"6d2b0d9abe1da3972de0ce1bd777a9dcb55d1f5a","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.4.0-alpha-20230224130759-d51f621.tgz","fileCount":10,"integrity":"sha512-+EwPakB3UWpeLrOhi6CA7nNO7R+S+wyKpPqWwIag56NHwhviZJErMwX2bliA9wzghxh1liGqaJlZfCQSORD/ng==","signatures":[{"sig":"MEUCIFMA67UKoqgTuf1NZ98J74pq3wvAPc9rEHFq2ntvyKeGAiEAs09FhQ3X3x9Duircv8QjN9bm+eUBbXIN5h2iShX2v9g=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":48235,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj+LbDACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmo8vA//eGqXAPMjlPzruF5G0kux5ufWu7sQBD2y7cewKr8/hfP84uyB\r\nEbY+W1loTeD0xq6vvWFjdjTa8XCruxxA9WsVEve2+COLxlfrvzwXKx7dvenl\r\njCSmM0Vo3N4cUp+UdBdnQ9sRykuva4EvddRmK1nxSCWPbesTstFifCK+r9vN\r\nnc9cvFcJ55SPExc9zWZVvZU1/TGsMzcGXx6f6oa84m5hLLf3stB3kIAzYeV/\r\nNCa67h/uDO/pB8r8QQJPfOLUZvqqS2nNzAseiymuL5HwRFpVjTIOrUv1qGUl\r\nfluKW1FGKQcF4q+uHMYOGUI1aIPnGS9KwXvfHk229PN4lCU5lLAxCWX+gLyn\r\n0ZDGjDGe3ysrbDicTFuSMzfLg4oZckhtFxkULmsKdQudA25x2HgJp0gC64wc\r\nHEAbzLreE4qNizgDVoI1Ren5IilSc/7lruaoqFRf0Q6bK/Dq9LFJbMI9JviX\r\nX4pu9A9ZCMvHFFS/nVfWBfzGpefg215+5vJMH2s1qBUw+l4R/PZQtPOsPTvG\r\nRnK5IH1rYrXtrQzPkDQ4F5pDo6bPVkD4bcW/2HR6BuoL+NU4YJf2VWSS44zQ\r\n15iLDiIVVLSnri/PK+hLRBb4MbKlVTDZZWDS4vex0ugUqPUHNSkDsm5mXZbw\r\nqPmtH1IcGhozJc6XcAvOPN/kNomtIwfKvrw=\r\n=dqoy\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\n### Basic Routing\n\n```ts\n// Then use it in any environment\nimport { createServer } from 'http'\nimport { createRouter, Router } from '@whatwg-node/router'\n\nconst router = createRouter()\n// GET collection index\nrouter.get('/todos', () => new Response('Todos Index!'))\n// GET item\nrouter.get('/todos/:id', ({ params }) => new Response(`Todo #${params.id}`))\n// POST to the collection (we'll use async here)\nrouter.post('/todos', async request => {\n  const content = await request.json()\n  return new Response('Creating Todo: ' + JSON.stringify(content))\n})\n\n// Redirect to a URL\nrouter.get('/google', () => Response.redirect('http://www.google.com'))\n\n// 404 for everything else\nrouter.all('*', () => new Response('Not Found.', { status: 404 }))\n\nconst httpServer = createServer(router)\nhttpServer.listen(4000)\n```\n\n## Example\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors. Or you can use the plugins to handle errors like below.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Plugins to handle CORS, cookies and more\n\nThis library also provides a plugin system that allows you hook into the request/response lifecycle.\n\n- `onRequest` - Called before the request is handled by the router\n- - It has `endResponse` method that accepts a `Response` object to short-circuit the request\n- `onResponse` - Called after the request is handled by the router\n- - It allows you to modify the response before it is sent to the client\n\n### Cookie Management\n\nYou can use `useCookies` to parse cookies from the request header and set cookies in the response by\nusing Web Standard [CookieStore](https://developer.mozilla.org/en-US/docs/Web/API/CookieStore).\n\n```ts\nimport { createRouter, Response, useCookies } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [useCookies()]\n})\n\nrouter.get('/me', async req => {\n  const sessionId = await request.cookieStore.get('session_id')\n  if (!sessionId) {\n    return Response.json({ error: 'Unauthorized' }, { status: 401 })\n  }\n  const user = await getUserBySessionId(sessionId)\n  return Response.json(user)\n})\n\nrouter.post('/login', async req => {\n  const { username, password } = await req.json()\n  const sessionId = await createSessionForUser({ username, password })\n  await request.cookieStore.set('session_id', sessionId)\n  return Response.json({ message: 'ok' })\n})\n```\n\n### CORS Management\n\nYou can also setup a CORS middleware to handle preflight CORS requests.\n\n```ts\nimport { createRouter, useCORS } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [\n    useCORS({\n      origin: '*',\n      methods: ['GET', 'POST', 'PUT', 'DELETE'],\n      headers: ['Content-Type', 'Authorization']\n    })\n  ]\n})\n```\n\n### Custom plugins\n\nYou can also create your own plugins to handle errors, logging, etc.\n\n```ts\nimport { createRouter } from '@whatwg-node/router'\n\nconst useRequestId = (): RoutePlugin => {\n  return {\n    onRequest({ request, fetchAPI }) {\n      let requestId = request.headers.get('X-Request-ID')\n      if (!requestId) {\n        requestId = fetchAPI.crypto.randomUUID()\n        request.headers.set('X-Request-ID', requestId)\n      }\n    },\n    onResponse({ response, fetchAPI }) {\n      response.headers.set('X-Request-ID', request.headers.get('X-Request-ID'))\n    }\n  }\n}\n\nconst router = createRouter({\n  plugins: [useRequestId()]\n})\n```\n\n## Type Safety with TypeScript, JSON Schema and OpenAPI\n\nThis library is written in TypeScript and it provides type safety for your request and response with\nthe power of JSON Schema.\n\nTo define type-safe routes, we use `addRoute` method with specific parameters.\n\n#### Typing the request\n\nYou can type individual parts of the `Request` object including JSON body, headers, query\nparameters, and URL parameters.\n\n##### JSON Body\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'post',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        JSONBody: {\n          type: 'object',\n          properties: {\n            title: { type: 'string' },\n            completed: { type: 'boolean' }\n          },\n          additionalProperties: false,\n          required: ['title']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const { title, completed } = await request.json()\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Headers\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'post',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        Headers: {\n          type: 'object',\n          properties: {\n            'x-api-key': { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['x-api-key']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const apiKey = request.headers.get('x-api-key')\n    // Would fail on TypeScript compilation\n    const wrongHeaderName = request.headers.get('x-api-key-wrong')\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Path Parameters\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'get',\n    path: '/todos/:id',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        PathParams: {\n          type: 'object',\n          properties: {\n            id: { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['id']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const { id } = request.params\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Query Parameters\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute({\n  method: 'get',\n  path: '/todos',\n  // Define the request body schema\n  schemas: {\n    Request: {\n      QueryParams: {\n        type: 'object',\n        properties: {\n          limit: { type: 'number' },\n          offset: { type: 'number' }\n        },\n        additionalProperties: false,\n        required: ['limit']\n      },\n    }\n  }\n}, async request => {\n  // This part is fully typed\n  const { limit, offset } = request.query\n  // You can also use `URLSearchParams` API\n  const limit = request.parsedURL.searchParams.get('limit')\n  // ...\n  return Response.json({ message: 'ok' })\n})\n```\n\n#### Typing the response\n\nYou can also type the response body by the status code. We strongly recommend to explicitly define\nthe status codes.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'get',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        Headers: {\n          type: 'object',\n          properties: {\n            'x-api-key': { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['x-api-key']\n        }\n      },\n      Response: {\n        200: {\n          type: 'array',\n          items: {\n            type: 'object',\n            properties: {\n              id: { type: 'string' },\n              title: { type: 'string' },\n              completed: { type: 'boolean' }\n            },\n            additionalProperties: false,\n            required: ['id', 'title', 'completed']\n          }\n        },\n        401: {\n          type: 'object',\n          properties: {\n            message: { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['message']\n        }\n      }\n    }\n  },\n  async request => {\n    const apiKey = request.headers.get('x-api-key')\n    if (!apiKey) {\n      return Response.json(\n        { message: 'API key is required' },\n        {\n          status: 401\n        }\n      )\n    }\n    const todos = await getTodos({\n      apiKey\n    })\n    // This part is fully typed\n    return Response.json(todos, {\n      status: 200\n    })\n  }\n)\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"d51f621f2b585ec9578f837737d09ce666207e9c","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.1","dependencies":{"tslib":"^2.3.1","openapi-types":"12.1.0","json-schema-to-ts":"2.6.2","@whatwg-node/fetch":"0.8.2-alpha-20230224130759-d51f621","@whatwg-node/server":"^0.7.0","@whatwg-node/typed-fetch":"0.0.1-alpha-20230224130759-d51f621"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.4.0-alpha-20230224130759-d51f621_1677244099443_0.4129630098804633","host":"s3://npm-registry-packages"}},"0.4.0-alpha-20230224143204-f98eefc":{"name":"@whatwg-node/router","version":"0.4.0-alpha-20230224143204-f98eefc","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.4.0-alpha-20230224143204-f98eefc","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"dbea591ab2ff473eb2f67fce8e081d471e4bd84b","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.4.0-alpha-20230224143204-f98eefc.tgz","fileCount":10,"integrity":"sha512-ubw3dNaRJm/FB0A1khOdNtOas3clwgtuqH0pMl4iGoGNVce4V5WMC+M6z6IvfPjGskNNMr9AVxGEoR5jy3aW0w==","signatures":[{"sig":"MEYCIQD+b7REFilCpwwXxMVKsNRUIP2dlDXrVKz9WNaSZlhvuQIhAMtO4fcoC2d8KQQ+EaCypwgd/GxB/gmGERAsy89njU2j","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":48235,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj+Mp+ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmqe6RAAhkCQRwsfgYDCeXdQxao2IwyI0jl/UeKCzr7+h2rQBEYWypEd\r\n+RH6JbMwAtyoihwsWdMdW541NpVi+uar6v8DyczJcXq6TXLFl1bCw2XR+06V\r\nxhnFvTIZ+DXssoH6bOxagn8hi5lEESenBDdYPQHX5thdfpsgS5+/U8R3bPwb\r\nkLoMWsYRytJmR11PiSXi/eX64FYPHDRXF1mL85/1kJDcVOLKFrXPr9sZvt/E\r\nh45qLUNAgUsorDHHgppDGc1VyIhsi4f9fWxha/Sx1zSiEB/MORSRMYfp/rYg\r\nYAzIjwTlzLqJZl+dzh/AZU7qoNF1PAKj3sLvI2+udmUVE1Bv5vJqZHSHqKX/\r\npmF4/70NibJYDE5OHQOSvHbok7BC2llA5oGFPAERc3sTjE2xk/lwqHpwZUab\r\ntDMcXbxdgkcE01eOHad1cmLVw/BtZ0VkEcjAqEcF75/PjVM1hQFvoKAC/m3x\r\noY3gpMTVBQc+1Dd8O+TDX4Og/o3BpPWIkkkwHnNVJxQQCQxELsTSRh55eTOe\r\nWTSaEzjZa3KSSDD0eHmwuQ30veGT/FqYzrFBqxTni6/nHY8Iiqw9ePYWY7TW\r\nFXuUBNzjx4hiDm/Ql79FWG5x601hwRBkXxeH/mSD1p0xh+/8NZmOYmU4rzCY\r\nNVlAOsiMwJljbJKxzpw6MT4LM+dVYFN1I3c=\r\n=WMt9\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\n### Basic Routing\n\n```ts\n// Then use it in any environment\nimport { createServer } from 'http'\nimport { createRouter, Router } from '@whatwg-node/router'\n\nconst router = createRouter()\n// GET collection index\nrouter.get('/todos', () => new Response('Todos Index!'))\n// GET item\nrouter.get('/todos/:id', ({ params }) => new Response(`Todo #${params.id}`))\n// POST to the collection (we'll use async here)\nrouter.post('/todos', async request => {\n  const content = await request.json()\n  return new Response('Creating Todo: ' + JSON.stringify(content))\n})\n\n// Redirect to a URL\nrouter.get('/google', () => Response.redirect('http://www.google.com'))\n\n// 404 for everything else\nrouter.all('*', () => new Response('Not Found.', { status: 404 }))\n\nconst httpServer = createServer(router)\nhttpServer.listen(4000)\n```\n\n## Example\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors. Or you can use the plugins to handle errors like below.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Plugins to handle CORS, cookies and more\n\nThis library also provides a plugin system that allows you hook into the request/response lifecycle.\n\n- `onRequest` - Called before the request is handled by the router\n- - It has `endResponse` method that accepts a `Response` object to short-circuit the request\n- `onResponse` - Called after the request is handled by the router\n- - It allows you to modify the response before it is sent to the client\n\n### Cookie Management\n\nYou can use `useCookies` to parse cookies from the request header and set cookies in the response by\nusing Web Standard [CookieStore](https://developer.mozilla.org/en-US/docs/Web/API/CookieStore).\n\n```ts\nimport { createRouter, Response, useCookies } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [useCookies()]\n})\n\nrouter.get('/me', async req => {\n  const sessionId = await request.cookieStore.get('session_id')\n  if (!sessionId) {\n    return Response.json({ error: 'Unauthorized' }, { status: 401 })\n  }\n  const user = await getUserBySessionId(sessionId)\n  return Response.json(user)\n})\n\nrouter.post('/login', async req => {\n  const { username, password } = await req.json()\n  const sessionId = await createSessionForUser({ username, password })\n  await request.cookieStore.set('session_id', sessionId)\n  return Response.json({ message: 'ok' })\n})\n```\n\n### CORS Management\n\nYou can also setup a CORS middleware to handle preflight CORS requests.\n\n```ts\nimport { createRouter, useCORS } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [\n    useCORS({\n      origin: '*',\n      methods: ['GET', 'POST', 'PUT', 'DELETE'],\n      headers: ['Content-Type', 'Authorization']\n    })\n  ]\n})\n```\n\n### Custom plugins\n\nYou can also create your own plugins to handle errors, logging, etc.\n\n```ts\nimport { createRouter } from '@whatwg-node/router'\n\nconst useRequestId = (): RoutePlugin => {\n  return {\n    onRequest({ request, fetchAPI }) {\n      let requestId = request.headers.get('X-Request-ID')\n      if (!requestId) {\n        requestId = fetchAPI.crypto.randomUUID()\n        request.headers.set('X-Request-ID', requestId)\n      }\n    },\n    onResponse({ response, fetchAPI }) {\n      response.headers.set('X-Request-ID', request.headers.get('X-Request-ID'))\n    }\n  }\n}\n\nconst router = createRouter({\n  plugins: [useRequestId()]\n})\n```\n\n## Type Safety with TypeScript, JSON Schema and OpenAPI\n\nThis library is written in TypeScript and it provides type safety for your request and response with\nthe power of JSON Schema.\n\nTo define type-safe routes, we use `addRoute` method with specific parameters.\n\n#### Typing the request\n\nYou can type individual parts of the `Request` object including JSON body, headers, query\nparameters, and URL parameters.\n\n##### JSON Body\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'post',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        JSONBody: {\n          type: 'object',\n          properties: {\n            title: { type: 'string' },\n            completed: { type: 'boolean' }\n          },\n          additionalProperties: false,\n          required: ['title']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const { title, completed } = await request.json()\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Headers\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'post',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        Headers: {\n          type: 'object',\n          properties: {\n            'x-api-key': { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['x-api-key']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const apiKey = request.headers.get('x-api-key')\n    // Would fail on TypeScript compilation\n    const wrongHeaderName = request.headers.get('x-api-key-wrong')\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Path Parameters\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'get',\n    path: '/todos/:id',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        PathParams: {\n          type: 'object',\n          properties: {\n            id: { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['id']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const { id } = request.params\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Query Parameters\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute({\n  method: 'get',\n  path: '/todos',\n  // Define the request body schema\n  schemas: {\n    Request: {\n      QueryParams: {\n        type: 'object',\n        properties: {\n          limit: { type: 'number' },\n          offset: { type: 'number' }\n        },\n        additionalProperties: false,\n        required: ['limit']\n      },\n    }\n  }\n}, async request => {\n  // This part is fully typed\n  const { limit, offset } = request.query\n  // You can also use `URLSearchParams` API\n  const limit = request.parsedURL.searchParams.get('limit')\n  // ...\n  return Response.json({ message: 'ok' })\n})\n```\n\n#### Typing the response\n\nYou can also type the response body by the status code. We strongly recommend to explicitly define\nthe status codes.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'get',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        Headers: {\n          type: 'object',\n          properties: {\n            'x-api-key': { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['x-api-key']\n        }\n      },\n      Response: {\n        200: {\n          type: 'array',\n          items: {\n            type: 'object',\n            properties: {\n              id: { type: 'string' },\n              title: { type: 'string' },\n              completed: { type: 'boolean' }\n            },\n            additionalProperties: false,\n            required: ['id', 'title', 'completed']\n          }\n        },\n        401: {\n          type: 'object',\n          properties: {\n            message: { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['message']\n        }\n      }\n    }\n  },\n  async request => {\n    const apiKey = request.headers.get('x-api-key')\n    if (!apiKey) {\n      return Response.json(\n        { message: 'API key is required' },\n        {\n          status: 401\n        }\n      )\n    }\n    const todos = await getTodos({\n      apiKey\n    })\n    // This part is fully typed\n    return Response.json(todos, {\n      status: 200\n    })\n  }\n)\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"f98eefc3190c38532c0dbd10d7101d2fd3af8c5b","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.1","dependencies":{"tslib":"^2.3.1","openapi-types":"12.1.0","json-schema-to-ts":"2.6.2","@whatwg-node/fetch":"0.8.2-alpha-20230224143204-f98eefc","@whatwg-node/server":"^0.7.0","@whatwg-node/typed-fetch":"0.0.1-alpha-20230224143204-f98eefc"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.4.0-alpha-20230224143204-f98eefc_1677249149794_0.08308921324973806","host":"s3://npm-registry-packages"}},"0.4.0-alpha-20230224183853-237400d":{"name":"@whatwg-node/router","version":"0.4.0-alpha-20230224183853-237400d","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.4.0-alpha-20230224183853-237400d","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"cc08289e48ef22b1a08a6555c25a010548848dfe","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.4.0-alpha-20230224183853-237400d.tgz","fileCount":7,"integrity":"sha512-GJ5gpcf9mBfKG1iBldVcFpgaRqEKOqnwcF0s9j9xMGHWkhDVcxTHNHopPQWhgS0Lhj6XPjoYdNDMD7BwfgmQEg==","signatures":[{"sig":"MEUCIH+fjaCjfrmDkp/ZtK547yPwPyOtH8B//bvwPpPSV4YyAiEA4UrB7l/mpUARY+FTc+N5JCqw5JAdgq6KSmeNo7lJslE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19308,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj+QRRACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpRNQ/+PVjsGTHFt2Z8C9PLI6XiYRLbLNhOs6O2U5Ab0fZhkrZigdkq\r\nbgH8ocMx7+2EXNK5lNYcWOzucYUb0sHK8INpf4DIy7m2IoutPXhsMi1xY66k\r\nCx9nIAXF7lMHRoDyaox2vc7Z31pUrgkKiLbrLcZjhzeEduqpzS6/pJ8rbfzW\r\ndNh5clmMDJGRVPG52CqZzu/gDUjrJS9bhK2taVnHbbKRM2MTkOIVzkTxAoLz\r\n34+qq4nn3jfOgQ62U7dqABujeGsZg3SODDK0KFPuFPIHBP8x17WTvoz3aJCo\r\noPTUMaDB1FMmbFKM+LFl9T8P6FP6q8fBSCDl7YiMiXo31LWNNUimswAu310K\r\ntMiKF9dmOQfdTJ3RxIXsCgFI/t9JEtqW2vqpzKO8yxkBNw8CXA6dVm2vUuNP\r\nyk5mfGaveyuIfJeqDD9Yj8iF/1bMzyTRqtBuDROl56oPqlmzv5gHia93iJY0\r\n3FYud4uO5ovr52n4ekSTA/RW61yTD2Rbyp8CQLlXUeBiFuEpsUOWctFm+4xB\r\nE+Fsj9uE/zFJhsCCSepTK14kXL2LimnRis8iNRgoi7HWn+uWclYWIU3OhCUW\r\nehyFiZMWW3qVuxoRwQCSVme43fl6T30XDa0VIOkfdPb3m+ELIgTD6uIly9Mi\r\nqPdR6jx15rhQMvXAjQl+DtH6W+ZS+e5DAPY=\r\n=NGrZ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"237400da8dcbf5bd0c577090f0317de32722eb2b","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.1","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"^0.8.0","@whatwg-node/server":"^0.7.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.4.0-alpha-20230224183853-237400d_1677263953625_0.06287351388686124","host":"s3://npm-registry-packages"}},"0.4.0-alpha-20230225004247-e22aa7d":{"name":"@whatwg-node/router","version":"0.4.0-alpha-20230225004247-e22aa7d","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.4.0-alpha-20230225004247-e22aa7d","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"8cd679b8a647ddf2edac73a80a7537908bc8bcf2","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.4.0-alpha-20230225004247-e22aa7d.tgz","fileCount":7,"integrity":"sha512-uMwX+hf1hq5f9uRhWHjUFdghKoT78wbC6hH9QueNMrpExNMF7jdAIktl177BzNzwCCnN7raHTACdDIO3bTi0ow==","signatures":[{"sig":"MEUCIHXYntvIBnyDncTYRVqja9ocxJD8zNvRmaabmhSJ6yWqAiEAwwTzHwPrFDnp5NBk4aC9VFFpGP4fZuf9IO2RLRZ5JDA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19308,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj+VmXACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmq54w//fQIv80WX3mgbFMBHsnQH+XKFT5miBe8YBDi0RbjyCqhKCfpc\r\n9MGLhZOgEHdB6wHm2gLqi2cvhcnapYZvOWAjiXuMFHYR2pPnLR0zCPyoRTd/\r\n7bCDAX0fBOY+xbVIMJqJ1g+8uaZ6kTNgGtKLebIAwSFIspAo6eXeCjuOpmJd\r\nW7pQnG1wrOXt0nk24dlmv5vATnpAQBRR1Qd1uyrXotURwXrSx+/VC0j8KTvM\r\nwg8HnTXdEKbEVpoDawJWAiEzPIOwjJAMPvxJKJ3BFn1H+yyAsB1RjzCZL3+7\r\n5IaFSBj66GW1I13/GIlxbMMQucbsifA0aWPXOsW2ashJHGsdDDp90AUoGul8\r\n/V4wy1hmXwSiH6Na4frW2qC5aQLFvpVeb3jEBvcB9gESTyWGC9spAjD1bGZh\r\ncgw4FmCQkS78Rgrq97XlwnfAz9V6P+12NBClEtjMxDy3N4DpnhopdsJRRi3s\r\nlUQCKcDpfs3g740eCJ9sCgsgaFY1poSz/1/0JH4KJ2bVktku2C/+g/FKwu4Y\r\nHTSJZUtdFT+Tlk8JNqYdZqVHj/idF7E+igbVRPny/Iq5QR92HuKy1bN5p/Di\r\nblhVGLqPw2n22Ix0HV3MoxUjfpusw3cHXYmf0KcHOHrbyBXRpEYSzLoe5WyU\r\n5OMSzxj4HNMkW3ykaKrTBTgEEJRg2ZJ6MDE=\r\n=dn+p\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"e22aa7d740f717bb1e12922c55eb20f664aeae4f","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.1","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"^0.8.0","@whatwg-node/server":"^0.7.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.4.0-alpha-20230225004247-e22aa7d_1677285782898_0.263565749338071","host":"s3://npm-registry-packages"}},"0.4.0-rc-20230225042529-7d928b3":{"name":"@whatwg-node/router","version":"0.4.0-rc-20230225042529-7d928b3","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.4.0-rc-20230225042529-7d928b3","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"20fcafd02c7a1d6f5c2283478ae54b1a602d229f","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.4.0-rc-20230225042529-7d928b3.tgz","fileCount":7,"integrity":"sha512-XQCjsc2kdbDnD52/WdGU7Ij6jj+bDd9lk29fmxD+sTrN77vzHlPtIBcG+aUZjSxzio06XZ+8GX3lk/l1yuSCJQ==","signatures":[{"sig":"MEUCIQC6fxse21hoazL5KRQSHhtJ5XAYvJlH3Y8qaj8nwn7uDgIgJv3d90Nn6Quhlp+Amt3u9zJtvokARn26grpHWJ1YQHo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19305,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj+Y3MACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqQtw/+Krx0izQYes3HhR7mL3o7s3Ew8201NhVxty/IkulIEw/XJR+l\r\nTKEQQXJQ+UBdOwARnYI/n1bzcO986BU009Vvcfh+89MO0FD1a6VHSVxv8EYf\r\nrTwoWS3IJrwtChoZ/chqOp++OjugrM3KUSipZu4CcYWJyEqgW1KWw48Y+tuh\r\nNu4KIh8qZ7xQGVkbXwB2qNFSbeZEPgy46JHzUXgtgtcvAUiPs5KvPsWb7ES8\r\nja0QGbJkrtW9+PT5/0/kLpGlFJyKpt8SxVyp4l2c3lUUs2NNnFLfsdMg+G38\r\nJShH9OUfBAf4jue/iBu+ql+3I6Twj1GP7/MsN8qL/iVD3uefjHQH8fPN+wd8\r\nv6lF7VYak8xa6s6d9nt5ISAFgRmrzHh+GZ0BSc+trE039rYKUlxISMvw6j10\r\nqyxxLCAftPi3fhQQ4AxBpw3AIAAsNuJDLHAzw5kvJrPi9p3ZBwHBul6IeWA2\r\nT1VAEYMEKk0TYhoDPGDRbe0bAvA5tGddm/gz8P5XmKFRctTJo1A2nb8qQiTw\r\n88WZ3ik01C8/LaneKehIb8C629PlbuOChZLudK6nzroOgDMO7uVYlPWPibIu\r\nO2oiG6eTwo3GnpxcAC9Q1Qn6308U1L5KqcarkReSI9fPAwJQ4BEIOSGlkrqt\r\nhUebV6EzsGWH57x4mPEafOsgYdaeKlvLqxk=\r\n=/PuB\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"7d928b3d7b2d0d17751a6534a06896e4f33f541b","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.1","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"^0.8.0","@whatwg-node/server":"^0.7.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.4.0-rc-20230225042529-7d928b3_1677299148045_0.6204450858582617","host":"s3://npm-registry-packages"}},"0.4.0-alpha-20230226114644-367e082":{"name":"@whatwg-node/router","version":"0.4.0-alpha-20230226114644-367e082","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.4.0-alpha-20230226114644-367e082","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"41224586c07bb69f2012ec690ea92628da80d7d2","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.4.0-alpha-20230226114644-367e082.tgz","fileCount":7,"integrity":"sha512-M4zt0hF/47/r5pbOhdNsiaDuYJw23Cqafdw2hMAMIN+fSm2DsAqhhLGioerb7ait+6ToCMJap9xsIDW+/x3IGw==","signatures":[{"sig":"MEYCIQDhbdk7bNgbc5d1pqZBvRUifDM9ZMzvKqJmk4dRJghK6QIhAPnrg53aMxBcyQQvFsytQmFGHE1T7P5CzRwCtYR1fn+M","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19308,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj+0azACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqBkRAAg6gakM3cFniHoMeEg36fvnxSFsDWapMVsowiLFkFwMx7ponQ\r\nmnX+Ca1S3w0+uOntub96Hl0dZK80JQiokKue+dwxpAIfDwsSlc4DOdHNa0Y3\r\nbqTtQQgmbYT95uKH0cEHJnVcAUm85JvVOnPaaPkavSVu1X+BTfDHJanbjQj8\r\nodBLap2SPbp3s4W3cdsHXX1r0XN52OqQxQlcXxwFbgxcKKxM2NkYRyqpj+/z\r\n/OPvwrI3NGyGobEKdu83LPdKY9MCMYtsFYyZWnVv93tK5LJZWIefcPPntsBW\r\nQ2y0j2kGZdQarrOtDs27QCQ2IJcuTlzyuroxjAodrQxdxQSywj/tJHKAIXk3\r\n7hqmRJZDVM1nUETUqLUlcne7SThw7YNMHlZzb69KtzYe91Qg+Mm6TEFNRVrt\r\njbQENHCwIXb7jXDnlpsqAcVvNH4X83ee3w/ybZqH17QwKELP7jbqqQzIognk\r\nYcd8pEwHEaUQ0v6AZR8/SsqNebcJsJzCEh/aYClsjsfyRBMoYDzVITyusQnJ\r\nhhpJNwNLLmeSvCVM6P8OABb2D9Z74XS/Ukp88jSJ4p1pZeHhnV05IHHNSeZ9\r\nrXjw75Gsddi/nokX73S1HE45TUrTJrwiL/+TuJYEvsjFVezE66ycqOy1IFfL\r\nFFPabXdFBoo+qrAdP0aBbX4q1mRzwQ7Fw6I=\r\n=Ex/J\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"367e0824eb11f9ad8b70760574f296beeb716c34","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.1","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"^0.8.0","@whatwg-node/server":"^0.7.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.4.0-alpha-20230226114644-367e082_1677412019330_0.9867159499038174","host":"s3://npm-registry-packages"}},"0.4.0-rc-20230226150216-7ac4f5e":{"name":"@whatwg-node/router","version":"0.4.0-rc-20230226150216-7ac4f5e","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.4.0-rc-20230226150216-7ac4f5e","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"7994028c58bb5f278b28a7ef86bfb6bf60aeaaa8","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.4.0-rc-20230226150216-7ac4f5e.tgz","fileCount":7,"integrity":"sha512-Ld0XQ/a0xJuinENN5lazcFtjady9wChJ8OH31Xw7TZ7CuBAk9idrO4sr4dG1iWzUKe9FnKBUf7E81APn0wJczA==","signatures":[{"sig":"MEQCIGrULdYmE7tbkvHjPzgq9te4vQdgJDpkhUoHypyVGNqxAiBLk6h/FbKtQU4AHR7Bs7jj+g62mfOMdhy5V5aS3xLBTA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19305,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj+3SHACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmplTw/+JdOb8XOiQJTHTlDE/jYy83kQ3GHPUGoXcImlsn875SjjDmue\r\nDM1va5W+5x7ZSXGQ6Vq7zb3Ct4QTeo0P8yVWH7g9RCgh8ydKxWKDSta5UVYd\r\nfp9dj7znRq2SNXxGo2o3jGn8Vztpl4RjRyzSPMQTW85X/igH4EOMpHdRHAq5\r\n1SqoglbHKfkeU3e2kiNrBb4OSi7EkH+pNGcdUHV2wniN1wkT6bwf9s3D6syc\r\nps8ZWXVzSSgBh12vbo+SFF+r3MrxpzQg1mejESQGtDf3cPenZI/Lmm1ZuUcP\r\nC8d+3qxjeVRYSbsygqbKg8rfsvkeaLkyVo7HJobbk0Wuf0sMEqKxpqJxYSVA\r\nVDCm+4QC4fToIqTXRQwsSY1MD8TC6fDdekakORrvIQx9HooVM1k582tTOxNW\r\nM0l0fEHmH/WSOb8jcx0hS2BS3EFIYz0Mjr0Z/P2CZRvsoWYPdQ2uicxCwCcc\r\nvBloyObEHMvZQpT8Js84byG45Jji4Ld+dTxo4vo52612Xblld/6Cle455mHw\r\nlwfDOiVldbZRGEsLmL+M5Zn7IAWaAoy6cpDMNruxRE14FTmlzhHV+/vy6TCF\r\ntG1EkJFStp0y+E+ec66E2rPwCPbpN6XbN+389QC9f7yE00rWx2zLIIuPeppf\r\nPnrFhFlayx1xTYheTl1fHIb0bQynbRCPSLk=\r\n=cqs9\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"7ac4f5e8c44f950d81fe828f6ba6acd3bd1f7d72","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.1","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"^0.8.0","@whatwg-node/server":"^0.7.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.4.0-rc-20230226150216-7ac4f5e_1677423751004_0.16577064377812567","host":"s3://npm-registry-packages"}},"0.4.0-alpha-20230226233400-388f8e3":{"name":"@whatwg-node/router","version":"0.4.0-alpha-20230226233400-388f8e3","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.4.0-alpha-20230226233400-388f8e3","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"44d8d918d352edd2c54cca11a5d9c5a182de701e","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.4.0-alpha-20230226233400-388f8e3.tgz","fileCount":7,"integrity":"sha512-mcpfPajxCXKX5v+fWlrppYttVTdVXQeAUxNiKGdlvmfiKsgTbt190TohdyX9nYSY+d91UloF7NIpzIGarhYTgg==","signatures":[{"sig":"MEUCIQDOfc2hfmRcJN9ZI9PNNDSp+snMncpsp/kf/seweaa3dwIgKBqCvhArDPN8sw9K+HXKR/SMDpt6WE0DjrluhAYGF6A=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19308,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj++x2ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqaLw/+Kkar/ekVswJrBgf9288WftPvAkbTtBVcQ6KH+6sN9Dgq+XcX\r\nhQJ2gDLNkzQLJoEWNTRGgOWd3Mm0gl3SXHZzEKdMwiiyBPzKznT5Mm4HvaRT\r\nzVHzo/EMIGeOnk9SoBbukVbeQ1YLHjxKaddkfkcw/bSlQBa3p8usQFMXbHY8\r\no3UmbFZ5UaBXWEbs0qjn6ZKwuOmWOJAcHd/ohykaKzWNOW5begDijlGujIri\r\nNIGnF7RUHs9alhOvZuN+8yhl37UhCsnHe1CprlUmGWbpuYDtlXfINzaitM9F\r\nWhO+aksurYF3WT327WvlkSASwcTyuIo+cc0QMIyKrD/6zAsAnPQ4IuAVF8Iq\r\nlKwEh6SLOqr9ATOpxgmlKQIqX6HovWMtD/FpaLuQ6yZBv9kWb5BsSZt0iJ8A\r\niIL4Cxk7WjTm3VaU8Rpr59sDKRqpaLPRCvtd8lsh3I8To12+KX1Q9Y1AP0z4\r\n/f9fdFWF9KACZp9fWm1nwKl0Tadm+2avXdm0iQUTufmITu00G3O4lYMPKZ6e\r\nIQQ3YUPQOjZImoYCZ53rtpkEJS3ENS9vJRu6j9sGdbFPdIdSb9QpHB3ND/f5\r\ngsy7ZlFUrB3ldNZtBoa875ngh7si7amB2o4KeVwm6d4HpVyoMBKjLEp8bDL9\r\n+2JrRITizj9zpLw453eEn9Y/7TAhU4uZgrE=\r\n=WynZ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"388f8e3774885f60cfb8d118a352740db1823eb2","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.1","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"^0.8.0","@whatwg-node/server":"^0.7.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.4.0-alpha-20230226233400-388f8e3_1677454454739_0.9770602713012104","host":"s3://npm-registry-packages"}},"0.4.0-rc-20230227023116-6f97cb1":{"name":"@whatwg-node/router","version":"0.4.0-rc-20230227023116-6f97cb1","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.4.0-rc-20230227023116-6f97cb1","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"b0d2bee6e70fc2727ee5207802c3cb73a06243a9","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.4.0-rc-20230227023116-6f97cb1.tgz","fileCount":7,"integrity":"sha512-bNytRppwYaS036nRIhP6fs9ULDT8RNBRRvkHXpQkG0OuznBIQp2ldCYvpatLSVkrP0gj0QMW3Qb2xWFzXMYvAw==","signatures":[{"sig":"MEQCIGu0Dta93ajij3I1L6s/w8aE13s9v1jH2l0wf/xDkL66AiAnavHr1w9mTOhjxniJGsHdNpuDtEEJ/pB0wzaXlVlMjw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19305,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj/BYEACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrHFA/+IaFZbO6R232Ez+GsrT3R2owTtGZjql/5sx1QOIHqtK4dBylF\r\njTBmQ2eMa9CMyrr0R8+QEic9vCUULOZmBZWLQsKTLJJb1KbO5rrGuVtsc7eA\r\nRl8KZvUydydfsEXO7aOZ499zcaEkbZJbME4THsJvT4NLsm6YQnVYnIHCw5YW\r\n/g0CUO+7kt3GKHSUF6YaeavD6EFSSMcFfJoLqsWY7I3FaRtVT5Sir9NPqv3r\r\nWwY2j4yBBC5o+df+ZHjkqmCGRgjxGXJFUpUytV7rQXo13ekKU5+RsMo1Dr51\r\npNt7dt+A13uBNbYpfzFZwNW1OFglGntCw4P/lPNYEOKpI6003bmVxGU+0P90\r\nnF4zLHHE+pdRrFkowdHwUcaVFG7IRoyDHJt11m2Ay83vTvOdTCnQ1VA68EBA\r\nBr9Ga4RKQ7sxbLBR+f7wEbBDgtjT0mI89TDFYSZSVFyrDIFAAuCkOAL2AZie\r\nYZa1ReVwYwtnBmJsYaLHTXSSzvgdxscYfPuQbclHy0u+vEhSrYzKRbYBvkw7\r\n4gViMHGMEugGo7sMMV3xUrxVQgPAJwF8rVNxM07h4+cLp3NhgY8HfC7V3JGt\r\ndnfD7H1GCHzzNXZgiM0mGonV8FpiImlumh4jdgBQ+x5WBKdiGOueSZuaW6VN\r\nZ7ZaQ6KAU4rhWYgRE9NFNhgvTyhrVrk1LhI=\r\n=JPIF\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"6f97cb1338113b543670356e4cb68a70f13edaab","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.1","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"^0.8.0","@whatwg-node/server":"^0.7.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.4.0-rc-20230227023116-6f97cb1_1677465092708_0.24552186885737037","host":"s3://npm-registry-packages"}},"0.4.0-alpha-20230227130032-9550f6c":{"name":"@whatwg-node/router","version":"0.4.0-alpha-20230227130032-9550f6c","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.4.0-alpha-20230227130032-9550f6c","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"fc607775df6a6f7dbceda3364a7c3c885e3635d4","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.4.0-alpha-20230227130032-9550f6c.tgz","fileCount":10,"integrity":"sha512-aZJBcyudscfjnhY3Gy4fbZ8GwXmMZkrqkD9zFxmiBN4Z4nSjWv7MB/AEHgI+W8+/qBm5vGwBn8ConFUu0wxgVg==","signatures":[{"sig":"MEYCIQDvxtHbKEIG5ZUPzEcWdQrhR7yuSyyLJqcloIdDXUiQBwIhAMoZ9go87GPqWoUsGaByXBWkep9FPia4JnqpudMd92xz","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":49035,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj/KmFACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmo8VQ/+MloAmNX7gDwtj1hIXRUOCtYbDJOQBUf7kyxBbG7K4z8xtwU1\r\nni6zzV0GtUbFhsHQM/NQ+o6naJ1p158uPqdUOUUrmE3Kh/yHlfZdpDYrGqdw\r\nkMwAAFGMAf9VCZdOFX5PtYtYUqJHs39nqcl7vW0SO/nCgZB2IuOjbDzPDPDx\r\noROooL784tU6lmZkgIDR8mbGw76NdKkBsFC9c1b8NvKKMsW/UjUjt8C4n4Bk\r\nvHswiXZrVjW96lYWFQHnBBuuW5zVw7cEoZX+I/dEdiGTbwUDrhj7IqUIPgsD\r\nrwNNkThD1pw8Vt3NlQPBAg+2D533FjS4gKQsPAtfEqHgWZd1l9gClWVoWlA2\r\nb9k6W7wK8QyipUkf9FOKeuVVwBStxffUYsc9/F0qb/bW1ww1oDwM+LyngF9i\r\nQRm0bVmQrZa62Mfa95NVi+NqX3GZwIxfDJt+61CSF3C94feuweJnRisFcugO\r\nn2cB0FXvQAGzy7kvyKHQOrhx/srotuWMileGXMoT2JXB7hfFatMKcGaNp0z5\r\nALD9nccKCtsLbm0MQG15pxUv1UvSjjtuVzx+k706dDs+AoBlwsrI0zUq+Hzo\r\nvm3loZBauWdXf2u5BWAUe0XdqEqlatYDadgPF48p5E52OKCDP6I2fWEv4GMA\r\nvlNkwqvi5KQpggvO6NLw9CXZ1mWkBqBBnBQ=\r\n=1Bsu\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\n### Basic Routing\n\n```ts\n// Then use it in any environment\nimport { createServer } from 'http'\nimport { createRouter, Router } from '@whatwg-node/router'\n\nconst router = createRouter()\n// GET collection index\nrouter.get('/todos', () => new Response('Todos Index!'))\n// GET item\nrouter.get('/todos/:id', ({ params }) => new Response(`Todo #${params.id}`))\n// POST to the collection (we'll use async here)\nrouter.post('/todos', async request => {\n  const content = await request.json()\n  return new Response('Creating Todo: ' + JSON.stringify(content))\n})\n\n// Redirect to a URL\nrouter.get('/google', () => Response.redirect('http://www.google.com'))\n\n// 404 for everything else\nrouter.all('*', () => new Response('Not Found.', { status: 404 }))\n\nconst httpServer = createServer(router)\nhttpServer.listen(4000)\n```\n\n## Example\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors. Or you can use the plugins to handle errors like below.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Plugins to handle CORS, cookies and more\n\nThis library also provides a plugin system that allows you hook into the request/response lifecycle.\n\n- `onRequest` - Called before the request is handled by the router\n- - It has `endResponse` method that accepts a `Response` object to short-circuit the request\n- `onResponse` - Called after the request is handled by the router\n- - It allows you to modify the response before it is sent to the client\n\n### Cookie Management\n\nYou can use `useCookies` to parse cookies from the request header and set cookies in the response by\nusing Web Standard [CookieStore](https://developer.mozilla.org/en-US/docs/Web/API/CookieStore).\n\n```ts\nimport { createRouter, Response, useCookies } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [useCookies()]\n})\n\nrouter.get('/me', async req => {\n  const sessionId = await request.cookieStore.get('session_id')\n  if (!sessionId) {\n    return Response.json({ error: 'Unauthorized' }, { status: 401 })\n  }\n  const user = await getUserBySessionId(sessionId)\n  return Response.json(user)\n})\n\nrouter.post('/login', async req => {\n  const { username, password } = await req.json()\n  const sessionId = await createSessionForUser({ username, password })\n  await request.cookieStore.set('session_id', sessionId)\n  return Response.json({ message: 'ok' })\n})\n```\n\n### CORS Management\n\nYou can also setup a CORS middleware to handle preflight CORS requests.\n\n```ts\nimport { createRouter, useCORS } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [\n    useCORS({\n      origin: '*',\n      methods: ['GET', 'POST', 'PUT', 'DELETE'],\n      headers: ['Content-Type', 'Authorization']\n    })\n  ]\n})\n```\n\n### Custom plugins\n\nYou can also create your own plugins to handle errors, logging, etc.\n\n```ts\nimport { createRouter } from '@whatwg-node/router'\n\nconst useRequestId = (): RoutePlugin => {\n  return {\n    onRequest({ request, fetchAPI }) {\n      let requestId = request.headers.get('X-Request-ID')\n      if (!requestId) {\n        requestId = fetchAPI.crypto.randomUUID()\n        request.headers.set('X-Request-ID', requestId)\n      }\n    },\n    onResponse({ response, fetchAPI }) {\n      response.headers.set('X-Request-ID', request.headers.get('X-Request-ID'))\n    }\n  }\n}\n\nconst router = createRouter({\n  plugins: [useRequestId()]\n})\n```\n\n## Type Safety with TypeScript, JSON Schema and OpenAPI\n\nThis library is written in TypeScript and it provides type safety for your request and response with\nthe power of JSON Schema.\n\nTo define type-safe routes, we use `addRoute` method with specific parameters.\n\n#### Typing the request\n\nYou can type individual parts of the `Request` object including JSON body, headers, query\nparameters, and URL parameters.\n\n##### JSON Body\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'post',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        JSONBody: {\n          type: 'object',\n          properties: {\n            title: { type: 'string' },\n            completed: { type: 'boolean' }\n          },\n          additionalProperties: false,\n          required: ['title']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const { title, completed } = await request.json()\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Headers\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'post',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        Headers: {\n          type: 'object',\n          properties: {\n            'x-api-key': { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['x-api-key']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const apiKey = request.headers.get('x-api-key')\n    // Would fail on TypeScript compilation\n    const wrongHeaderName = request.headers.get('x-api-key-wrong')\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Path Parameters\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'get',\n    path: '/todos/:id',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        PathParams: {\n          type: 'object',\n          properties: {\n            id: { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['id']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const { id } = request.params\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Query Parameters\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute({\n  method: 'get',\n  path: '/todos',\n  // Define the request body schema\n  schemas: {\n    Request: {\n      QueryParams: {\n        type: 'object',\n        properties: {\n          limit: { type: 'number' },\n          offset: { type: 'number' }\n        },\n        additionalProperties: false,\n        required: ['limit']\n      },\n    }\n  }\n}, async request => {\n  // This part is fully typed\n  const { limit, offset } = request.query\n  // You can also use `URLSearchParams` API\n  const limit = request.parsedURL.searchParams.get('limit')\n  // ...\n  return Response.json({ message: 'ok' })\n})\n```\n\n#### Typing the response\n\nYou can also type the response body by the status code. We strongly recommend to explicitly define\nthe status codes.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'get',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        Headers: {\n          type: 'object',\n          properties: {\n            'x-api-key': { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['x-api-key']\n        }\n      },\n      Response: {\n        200: {\n          type: 'array',\n          items: {\n            type: 'object',\n            properties: {\n              id: { type: 'string' },\n              title: { type: 'string' },\n              completed: { type: 'boolean' }\n            },\n            additionalProperties: false,\n            required: ['id', 'title', 'completed']\n          }\n        },\n        401: {\n          type: 'object',\n          properties: {\n            message: { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['message']\n        }\n      }\n    }\n  },\n  async request => {\n    const apiKey = request.headers.get('x-api-key')\n    if (!apiKey) {\n      return Response.json(\n        { message: 'API key is required' },\n        {\n          status: 401\n        }\n      )\n    }\n    const todos = await getTodos({\n      apiKey\n    })\n    // This part is fully typed\n    return Response.json(todos, {\n      status: 200\n    })\n  }\n)\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"9550f6c107b26b2d101c2c251b706fc0538d7ecf","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.1","dependencies":{"tslib":"^2.3.1","openapi-types":"12.1.0","json-schema-to-ts":"2.6.2","@whatwg-node/fetch":"0.8.2-alpha-20230227130032-9550f6c","@whatwg-node/server":"^0.7.0","@whatwg-node/typed-fetch":"0.0.1-alpha-20230227130032-9550f6c"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.4.0-alpha-20230227130032-9550f6c_1677502853427_0.08164994258042424","host":"s3://npm-registry-packages"}},"0.4.0-alpha-20230227130053-a2fb518":{"name":"@whatwg-node/router","version":"0.4.0-alpha-20230227130053-a2fb518","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.4.0-alpha-20230227130053-a2fb518","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"efd8b72f04b52b146c059024251581c5283de1f8","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.4.0-alpha-20230227130053-a2fb518.tgz","fileCount":10,"integrity":"sha512-811HoJranOe9etuBXhKmOJ98+A7c7vp5svKglqKSwkGHZnUfJRTnveVZJHmDmH9wNY471LjvXl9fsbMJXv71Aw==","signatures":[{"sig":"MEUCIApMuNBML/0Gl/moMDBpvASiHRT/aa1bPjd2ykVkO96OAiEAvPtD+oqGzaVg0DX+SpOjQXZEoXphYnX3q/tztcAV1fM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":49035,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj/KmaACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoU+w/8D9GTVFU9E4jRgDsizngqdkK4UeR0nWfNN0FqrHz5M14cuBEn\r\n/DgoGkGD3M+RDxpu6ZL2o+3A09lb3KhXgyVyQ28DFOGZKgAJXH7JsCyruNwa\r\ntVN+S7uYr4CKx/sGRV+t4Z1wM+JllSCKHHvmA/RmdBFheczg5U/8Uj/E3gAx\r\nTbsysYiVEeECArnGRKG2Bk/Chiw4F2OeXr17vqXeiP9Hu/XOdquXq978WpKf\r\nWVxOVegMaHtz0RhihvNHO1T0Qmrfh4+UzsePOTUMA3llV18nzRKJAXLZyCZe\r\nzDr6VsfwpnV1Pp+Or2X8Wq+jlRuhwpDPFYIT4wSVBDCOpTQSxWXkLUbTJ2GH\r\nuG75LWb7LozQ0LzkJIuNsg8n2cjXC7j58t2h+S3Q+AxB0K+36dw5CqYT7vcl\r\nwntThXy3C1gQClr1I6uguHznjAPpYQaPVTfCTxVNL0nY083p2YExBMYoPHlI\r\nVNYWjr5X5jtjmoDUiYdqjaR4VZsemhAQJU1Fkc944eT+iEFKCpr++WxCxzwX\r\n3lFhO4lbUS9ehac2BTwfiIp0W6k1115FBZWsCoEQjZqCiapeyz75dxLiXN1c\r\n1XDOJ87zrYDCybh5o8K+uL4onMLvNeA0SQ/WCkUVLbpD6bel7dB8+kNKVbWL\r\nO2Uybb8qsaXbhn8oVOdvxXw9xRfRmLn6Frs=\r\n=9Ddn\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\n### Basic Routing\n\n```ts\n// Then use it in any environment\nimport { createServer } from 'http'\nimport { createRouter, Router } from '@whatwg-node/router'\n\nconst router = createRouter()\n// GET collection index\nrouter.get('/todos', () => new Response('Todos Index!'))\n// GET item\nrouter.get('/todos/:id', ({ params }) => new Response(`Todo #${params.id}`))\n// POST to the collection (we'll use async here)\nrouter.post('/todos', async request => {\n  const content = await request.json()\n  return new Response('Creating Todo: ' + JSON.stringify(content))\n})\n\n// Redirect to a URL\nrouter.get('/google', () => Response.redirect('http://www.google.com'))\n\n// 404 for everything else\nrouter.all('*', () => new Response('Not Found.', { status: 404 }))\n\nconst httpServer = createServer(router)\nhttpServer.listen(4000)\n```\n\n## Example\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors. Or you can use the plugins to handle errors like below.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Plugins to handle CORS, cookies and more\n\nThis library also provides a plugin system that allows you hook into the request/response lifecycle.\n\n- `onRequest` - Called before the request is handled by the router\n- - It has `endResponse` method that accepts a `Response` object to short-circuit the request\n- `onResponse` - Called after the request is handled by the router\n- - It allows you to modify the response before it is sent to the client\n\n### Cookie Management\n\nYou can use `useCookies` to parse cookies from the request header and set cookies in the response by\nusing Web Standard [CookieStore](https://developer.mozilla.org/en-US/docs/Web/API/CookieStore).\n\n```ts\nimport { createRouter, Response, useCookies } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [useCookies()]\n})\n\nrouter.get('/me', async req => {\n  const sessionId = await request.cookieStore.get('session_id')\n  if (!sessionId) {\n    return Response.json({ error: 'Unauthorized' }, { status: 401 })\n  }\n  const user = await getUserBySessionId(sessionId)\n  return Response.json(user)\n})\n\nrouter.post('/login', async req => {\n  const { username, password } = await req.json()\n  const sessionId = await createSessionForUser({ username, password })\n  await request.cookieStore.set('session_id', sessionId)\n  return Response.json({ message: 'ok' })\n})\n```\n\n### CORS Management\n\nYou can also setup a CORS middleware to handle preflight CORS requests.\n\n```ts\nimport { createRouter, useCORS } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [\n    useCORS({\n      origin: '*',\n      methods: ['GET', 'POST', 'PUT', 'DELETE'],\n      headers: ['Content-Type', 'Authorization']\n    })\n  ]\n})\n```\n\n### Custom plugins\n\nYou can also create your own plugins to handle errors, logging, etc.\n\n```ts\nimport { createRouter } from '@whatwg-node/router'\n\nconst useRequestId = (): RoutePlugin => {\n  return {\n    onRequest({ request, fetchAPI }) {\n      let requestId = request.headers.get('X-Request-ID')\n      if (!requestId) {\n        requestId = fetchAPI.crypto.randomUUID()\n        request.headers.set('X-Request-ID', requestId)\n      }\n    },\n    onResponse({ response, fetchAPI }) {\n      response.headers.set('X-Request-ID', request.headers.get('X-Request-ID'))\n    }\n  }\n}\n\nconst router = createRouter({\n  plugins: [useRequestId()]\n})\n```\n\n## Type Safety with TypeScript, JSON Schema and OpenAPI\n\nThis library is written in TypeScript and it provides type safety for your request and response with\nthe power of JSON Schema.\n\nTo define type-safe routes, we use `addRoute` method with specific parameters.\n\n#### Typing the request\n\nYou can type individual parts of the `Request` object including JSON body, headers, query\nparameters, and URL parameters.\n\n##### JSON Body\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'post',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        JSONBody: {\n          type: 'object',\n          properties: {\n            title: { type: 'string' },\n            completed: { type: 'boolean' }\n          },\n          additionalProperties: false,\n          required: ['title']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const { title, completed } = await request.json()\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Headers\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'post',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        Headers: {\n          type: 'object',\n          properties: {\n            'x-api-key': { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['x-api-key']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const apiKey = request.headers.get('x-api-key')\n    // Would fail on TypeScript compilation\n    const wrongHeaderName = request.headers.get('x-api-key-wrong')\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Path Parameters\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'get',\n    path: '/todos/:id',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        PathParams: {\n          type: 'object',\n          properties: {\n            id: { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['id']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const { id } = request.params\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Query Parameters\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute({\n  method: 'get',\n  path: '/todos',\n  // Define the request body schema\n  schemas: {\n    Request: {\n      QueryParams: {\n        type: 'object',\n        properties: {\n          limit: { type: 'number' },\n          offset: { type: 'number' }\n        },\n        additionalProperties: false,\n        required: ['limit']\n      },\n    }\n  }\n}, async request => {\n  // This part is fully typed\n  const { limit, offset } = request.query\n  // You can also use `URLSearchParams` API\n  const limit = request.parsedURL.searchParams.get('limit')\n  // ...\n  return Response.json({ message: 'ok' })\n})\n```\n\n#### Typing the response\n\nYou can also type the response body by the status code. We strongly recommend to explicitly define\nthe status codes.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'get',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        Headers: {\n          type: 'object',\n          properties: {\n            'x-api-key': { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['x-api-key']\n        }\n      },\n      Response: {\n        200: {\n          type: 'array',\n          items: {\n            type: 'object',\n            properties: {\n              id: { type: 'string' },\n              title: { type: 'string' },\n              completed: { type: 'boolean' }\n            },\n            additionalProperties: false,\n            required: ['id', 'title', 'completed']\n          }\n        },\n        401: {\n          type: 'object',\n          properties: {\n            message: { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['message']\n        }\n      }\n    }\n  },\n  async request => {\n    const apiKey = request.headers.get('x-api-key')\n    if (!apiKey) {\n      return Response.json(\n        { message: 'API key is required' },\n        {\n          status: 401\n        }\n      )\n    }\n    const todos = await getTodos({\n      apiKey\n    })\n    // This part is fully typed\n    return Response.json(todos, {\n      status: 200\n    })\n  }\n)\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"a2fb5188f78630dfc6789994502da736b65021c2","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.1","dependencies":{"tslib":"^2.3.1","openapi-types":"12.1.0","json-schema-to-ts":"2.6.2","@whatwg-node/fetch":"0.8.2-alpha-20230227130053-a2fb518","@whatwg-node/server":"^0.7.0","@whatwg-node/typed-fetch":"0.0.1-alpha-20230227130053-a2fb518"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.4.0-alpha-20230227130053-a2fb518_1677502874685_0.7942424241976569","host":"s3://npm-registry-packages"}},"0.4.0-alpha-20230227131024-08db2e7":{"name":"@whatwg-node/router","version":"0.4.0-alpha-20230227131024-08db2e7","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.4.0-alpha-20230227131024-08db2e7","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"8e364da76866bafd3cd46291ff02410985625b42","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.4.0-alpha-20230227131024-08db2e7.tgz","fileCount":10,"integrity":"sha512-npiUlZ/wH8Vo27HOsYMOeAPGPHOS3rQ6JDim37ofeRhBdjDofTwspAiVC46D0ypoK/GmZyVuVBjxKb1p7vZTGw==","signatures":[{"sig":"MEUCIQCh5XJdLmQTWSgmz0bJLbVg/EblGZrrTZtmTXOy92CAYgIgWhz8nSG7/G6CzBv0v/Dqk854BCvuPcHgMHPAbzsCf2Q=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":49046,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj/KvXACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoBrw//UGVRa/9AoKitQjAF6o23bqChakq5E2tZ8YqNLQHthZQgtHtt\r\nv3rhnKE2r9juwsyUUArw7UJNXXrya56ucqk83A379I3vTjeMjaADGHO4PBK0\r\nQipfzt9jL8W/oWLbGMXgPr6FZbTS/R+0h8JmMjRYjK0r9dintU9oZUojOXvV\r\n85VKGON622fzE+HqgHgX4GUBD63aWrgRCkBNuArwYiGY7pUJf1cVu6XILlEc\r\nfgwJpL3MGiDKqFVe4zfJsBZAuwkLnGiK1/keLnHMlMngaDMYLXb5bJ9t3e6G\r\nXMyVCj4bErjifZeSR5xCufvddDu2J0ojivq6nFodsuDEduJGm8Y6yR2vMKMy\r\nx2HUWvKCPYD3snOLYOB9Z9N/xNWGLl47HG7hiJz7N4W4roww8LIjqKmDLwxW\r\ntv45Ne9AhQ9NCk6bWO+2WhXMdmCId6ZmT57mp/cdydnh5DY2uajUdTvENiJ/\r\njyov+lzSa3o2K1RUrDfVWdR1qHzkRKxvhv+rK4ixids+/GnOVp5XrciEHL9w\r\nBAwvnk1pc4HhY4JDhiNLtP8rIqtfk9odrCQ46iPx9pJo/nS13Im6vz+xryCF\r\nob9g024o4wkhZlo7rD7C2hbS3Sf4+Xb4EzIapEKNUbAJk3TMJ5xRnc/84r2V\r\nsYKsj4GMk7qcQkr2qeFsqlctwP0AId7nSkY=\r\n=f8lS\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\n### Basic Routing\n\n```ts\n// Then use it in any environment\nimport { createServer } from 'http'\nimport { createRouter, Router } from '@whatwg-node/router'\n\nconst router = createRouter()\n// GET collection index\nrouter.get('/todos', () => new Response('Todos Index!'))\n// GET item\nrouter.get('/todos/:id', ({ params }) => new Response(`Todo #${params.id}`))\n// POST to the collection (we'll use async here)\nrouter.post('/todos', async request => {\n  const content = await request.json()\n  return new Response('Creating Todo: ' + JSON.stringify(content))\n})\n\n// Redirect to a URL\nrouter.get('/google', () => Response.redirect('http://www.google.com'))\n\n// 404 for everything else\nrouter.all('*', () => new Response('Not Found.', { status: 404 }))\n\nconst httpServer = createServer(router)\nhttpServer.listen(4000)\n```\n\n## Example\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors. Or you can use the plugins to handle errors like below.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Plugins to handle CORS, cookies and more\n\nThis library also provides a plugin system that allows you hook into the request/response lifecycle.\n\n- `onRequest` - Called before the request is handled by the router\n- - It has `endResponse` method that accepts a `Response` object to short-circuit the request\n- `onResponse` - Called after the request is handled by the router\n- - It allows you to modify the response before it is sent to the client\n\n### Cookie Management\n\nYou can use `useCookies` to parse cookies from the request header and set cookies in the response by\nusing Web Standard [CookieStore](https://developer.mozilla.org/en-US/docs/Web/API/CookieStore).\n\n```ts\nimport { createRouter, Response, useCookies } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [useCookies()]\n})\n\nrouter.get('/me', async req => {\n  const sessionId = await request.cookieStore.get('session_id')\n  if (!sessionId) {\n    return Response.json({ error: 'Unauthorized' }, { status: 401 })\n  }\n  const user = await getUserBySessionId(sessionId)\n  return Response.json(user)\n})\n\nrouter.post('/login', async req => {\n  const { username, password } = await req.json()\n  const sessionId = await createSessionForUser({ username, password })\n  await request.cookieStore.set('session_id', sessionId)\n  return Response.json({ message: 'ok' })\n})\n```\n\n### CORS Management\n\nYou can also setup a CORS middleware to handle preflight CORS requests.\n\n```ts\nimport { createRouter, useCORS } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [\n    useCORS({\n      origin: '*',\n      methods: ['GET', 'POST', 'PUT', 'DELETE'],\n      headers: ['Content-Type', 'Authorization']\n    })\n  ]\n})\n```\n\n### Custom plugins\n\nYou can also create your own plugins to handle errors, logging, etc.\n\n```ts\nimport { createRouter } from '@whatwg-node/router'\n\nconst useRequestId = (): RoutePlugin => {\n  return {\n    onRequest({ request, fetchAPI }) {\n      let requestId = request.headers.get('X-Request-ID')\n      if (!requestId) {\n        requestId = fetchAPI.crypto.randomUUID()\n        request.headers.set('X-Request-ID', requestId)\n      }\n    },\n    onResponse({ response, fetchAPI }) {\n      response.headers.set('X-Request-ID', request.headers.get('X-Request-ID'))\n    }\n  }\n}\n\nconst router = createRouter({\n  plugins: [useRequestId()]\n})\n```\n\n## Type Safety with TypeScript, JSON Schema and OpenAPI\n\nThis library is written in TypeScript and it provides type safety for your request and response with\nthe power of JSON Schema.\n\nTo define type-safe routes, we use `addRoute` method with specific parameters.\n\n#### Typing the request\n\nYou can type individual parts of the `Request` object including JSON body, headers, query\nparameters, and URL parameters.\n\n##### JSON Body\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'post',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        JSONBody: {\n          type: 'object',\n          properties: {\n            title: { type: 'string' },\n            completed: { type: 'boolean' }\n          },\n          additionalProperties: false,\n          required: ['title']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const { title, completed } = await request.json()\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Headers\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'post',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        Headers: {\n          type: 'object',\n          properties: {\n            'x-api-key': { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['x-api-key']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const apiKey = request.headers.get('x-api-key')\n    // Would fail on TypeScript compilation\n    const wrongHeaderName = request.headers.get('x-api-key-wrong')\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Path Parameters\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'get',\n    path: '/todos/:id',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        PathParams: {\n          type: 'object',\n          properties: {\n            id: { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['id']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const { id } = request.params\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Query Parameters\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute({\n  method: 'get',\n  path: '/todos',\n  // Define the request body schema\n  schemas: {\n    Request: {\n      QueryParams: {\n        type: 'object',\n        properties: {\n          limit: { type: 'number' },\n          offset: { type: 'number' }\n        },\n        additionalProperties: false,\n        required: ['limit']\n      },\n    }\n  }\n}, async request => {\n  // This part is fully typed\n  const { limit, offset } = request.query\n  // You can also use `URLSearchParams` API\n  const limit = request.parsedURL.searchParams.get('limit')\n  // ...\n  return Response.json({ message: 'ok' })\n})\n```\n\n#### Typing the response\n\nYou can also type the response body by the status code. We strongly recommend to explicitly define\nthe status codes.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'get',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        Headers: {\n          type: 'object',\n          properties: {\n            'x-api-key': { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['x-api-key']\n        }\n      },\n      Response: {\n        200: {\n          type: 'array',\n          items: {\n            type: 'object',\n            properties: {\n              id: { type: 'string' },\n              title: { type: 'string' },\n              completed: { type: 'boolean' }\n            },\n            additionalProperties: false,\n            required: ['id', 'title', 'completed']\n          }\n        },\n        401: {\n          type: 'object',\n          properties: {\n            message: { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['message']\n        }\n      }\n    }\n  },\n  async request => {\n    const apiKey = request.headers.get('x-api-key')\n    if (!apiKey) {\n      return Response.json(\n        { message: 'API key is required' },\n        {\n          status: 401\n        }\n      )\n    }\n    const todos = await getTodos({\n      apiKey\n    })\n    // This part is fully typed\n    return Response.json(todos, {\n      status: 200\n    })\n  }\n)\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"08db2e72fb21b43637b9064dd402853bcfac35ec","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.1","dependencies":{"tslib":"^2.3.1","openapi-types":"12.1.0","json-schema-to-ts":"2.6.2","@whatwg-node/fetch":"0.8.2-alpha-20230227131024-08db2e7","@whatwg-node/server":"^0.7.0","@whatwg-node/typed-fetch":"0.0.1-alpha-20230227131024-08db2e7"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.4.0-alpha-20230227131024-08db2e7_1677503446986_0.09213293420267665","host":"s3://npm-registry-packages"}},"0.4.0-alpha-20230227152152-ebc4f40":{"name":"@whatwg-node/router","version":"0.4.0-alpha-20230227152152-ebc4f40","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.4.0-alpha-20230227152152-ebc4f40","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"808102887d7458fe91f3c1dff019bec2714f31fe","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.4.0-alpha-20230227152152-ebc4f40.tgz","fileCount":10,"integrity":"sha512-IX2igWCGArsRlZV7QXcr1vGO6P+VhQYPdCId47yFbpr0sqCSG87ZpkH+A5+YzsJtmvNPhG8L/prLBbGwOmxlUQ==","signatures":[{"sig":"MEUCIQD20+r7ARJGAQOQhGjZSYIThJZL9+Oa2nyLQ4Ki0HfFOAIgYewjvCXjl1c+ITjdglVOPbqkRQR8Y14i6AQW/jim/9o=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":50369,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj/MqiACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmo0PRAAg1qtpq/g7vNUOWjhTdqkK2z8HVrkEr0A1hrghQcPYqgO/9Nq\r\neByzTj8MVkH/l8Yfam9iIIF3a4aaEju3YIEQ4ylV3bMfruglQADFYtvozPUe\r\nzGQLQ5Ng76po6r5w7chAXTWxhhpeVN+4FWe/yzRXEEvPYEegflNB9+Y5Cxni\r\nugXII2ZXZAk0ZbSNgIsMQguJzPIseYWBJPWq11Jk7I15jaGQnHIGd+QTLiX9\r\n4+ib9IyMOM57NgXjJbeJkpxwTZzpu9U3ut77rZUU3bbP8Xydanw5HxYgWjVC\r\n12QCHB+Z/kKcuzcbmw64+ckoNof1NcK1a5aiE+xJ5pEqsEh90M8hZrt0vGRB\r\nzU90VtB/E6PR5LgZCb25g2sUkr3kR2dvU7XvbcwgqbX7c6uqtGF9XfTFl90A\r\nIpgdLIsfN3/8btwlSA9aUcVXTiup50H95SDwODmpcB64sXyEnBhoVEagHONU\r\nRR+2ZLNkncMlBNLPuT9ze/6a8HEEiaOlcLiB10fiEVdau69UoA9fAssyE9ra\r\nUcHT6BmIqZ0XJUKSMIO7TlIa3gd1sHQWTnWC186IsaJGMsnAJYJA6o1qgDPd\r\nDfbP0b/LAflV51H1t6W5+Z49IsDsq0V7ct+X6JRsMXnk9bEEsrzZ16iY7PIM\r\nJgUCqD/zwJaryt55w4BbeHEPxO6JElNHEzQ=\r\n=vBn4\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\n### Basic Routing\n\n```ts\n// Then use it in any environment\nimport { createServer } from 'http'\nimport { createRouter, Router } from '@whatwg-node/router'\n\nconst router = createRouter()\n// GET collection index\nrouter.get('/todos', () => new Response('Todos Index!'))\n// GET item\nrouter.get('/todos/:id', ({ params }) => new Response(`Todo #${params.id}`))\n// POST to the collection (we'll use async here)\nrouter.post('/todos', async request => {\n  const content = await request.json()\n  return new Response('Creating Todo: ' + JSON.stringify(content))\n})\n\n// Redirect to a URL\nrouter.get('/google', () => Response.redirect('http://www.google.com'))\n\n// 404 for everything else\nrouter.all('*', () => new Response('Not Found.', { status: 404 }))\n\nconst httpServer = createServer(router)\nhttpServer.listen(4000)\n```\n\n## Example\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors. Or you can use the plugins to handle errors like below.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Plugins to handle CORS, cookies and more\n\nThis library also provides a plugin system that allows you hook into the request/response lifecycle.\n\n- `onRequest` - Called before the request is handled by the router\n- - It has `endResponse` method that accepts a `Response` object to short-circuit the request\n- `onResponse` - Called after the request is handled by the router\n- - It allows you to modify the response before it is sent to the client\n\n### Cookie Management\n\nYou can use `useCookies` to parse cookies from the request header and set cookies in the response by\nusing Web Standard [CookieStore](https://developer.mozilla.org/en-US/docs/Web/API/CookieStore).\n\n```ts\nimport { createRouter, Response, useCookies } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [useCookies()]\n})\n\nrouter.get('/me', async req => {\n  const sessionId = await request.cookieStore.get('session_id')\n  if (!sessionId) {\n    return Response.json({ error: 'Unauthorized' }, { status: 401 })\n  }\n  const user = await getUserBySessionId(sessionId)\n  return Response.json(user)\n})\n\nrouter.post('/login', async req => {\n  const { username, password } = await req.json()\n  const sessionId = await createSessionForUser({ username, password })\n  await request.cookieStore.set('session_id', sessionId)\n  return Response.json({ message: 'ok' })\n})\n```\n\n### CORS Management\n\nYou can also setup a CORS middleware to handle preflight CORS requests.\n\n```ts\nimport { createRouter, useCORS } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [\n    useCORS({\n      origin: '*',\n      methods: ['GET', 'POST', 'PUT', 'DELETE'],\n      headers: ['Content-Type', 'Authorization']\n    })\n  ]\n})\n```\n\n### Custom plugins\n\nYou can also create your own plugins to handle errors, logging, etc.\n\n```ts\nimport { createRouter } from '@whatwg-node/router'\n\nconst useRequestId = (): RoutePlugin => {\n  return {\n    onRequest({ request, fetchAPI }) {\n      let requestId = request.headers.get('X-Request-ID')\n      if (!requestId) {\n        requestId = fetchAPI.crypto.randomUUID()\n        request.headers.set('X-Request-ID', requestId)\n      }\n    },\n    onResponse({ response, fetchAPI }) {\n      response.headers.set('X-Request-ID', request.headers.get('X-Request-ID'))\n    }\n  }\n}\n\nconst router = createRouter({\n  plugins: [useRequestId()]\n})\n```\n\n## Type Safety with TypeScript, JSON Schema and OpenAPI\n\nThis library is written in TypeScript and it provides type safety for your request and response with\nthe power of JSON Schema.\n\nTo define type-safe routes, we use `addRoute` method with specific parameters.\n\n#### Typing the request\n\nYou can type individual parts of the `Request` object including JSON body, headers, query\nparameters, and URL parameters.\n\n##### JSON Body\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'post',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        JSONBody: {\n          type: 'object',\n          properties: {\n            title: { type: 'string' },\n            completed: { type: 'boolean' }\n          },\n          additionalProperties: false,\n          required: ['title']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const { title, completed } = await request.json()\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Headers\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'post',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        Headers: {\n          type: 'object',\n          properties: {\n            'x-api-key': { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['x-api-key']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const apiKey = request.headers.get('x-api-key')\n    // Would fail on TypeScript compilation\n    const wrongHeaderName = request.headers.get('x-api-key-wrong')\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Path Parameters\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'get',\n    path: '/todos/:id',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        PathParams: {\n          type: 'object',\n          properties: {\n            id: { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['id']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const { id } = request.params\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Query Parameters\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute({\n  method: 'get',\n  path: '/todos',\n  // Define the request body schema\n  schemas: {\n    Request: {\n      QueryParams: {\n        type: 'object',\n        properties: {\n          limit: { type: 'number' },\n          offset: { type: 'number' }\n        },\n        additionalProperties: false,\n        required: ['limit']\n      },\n    }\n  }\n}, async request => {\n  // This part is fully typed\n  const { limit, offset } = request.query\n  // You can also use `URLSearchParams` API\n  const limit = request.parsedURL.searchParams.get('limit')\n  // ...\n  return Response.json({ message: 'ok' })\n})\n```\n\n#### Typing the response\n\nYou can also type the response body by the status code. We strongly recommend to explicitly define\nthe status codes.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'get',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        Headers: {\n          type: 'object',\n          properties: {\n            'x-api-key': { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['x-api-key']\n        }\n      },\n      Response: {\n        200: {\n          type: 'array',\n          items: {\n            type: 'object',\n            properties: {\n              id: { type: 'string' },\n              title: { type: 'string' },\n              completed: { type: 'boolean' }\n            },\n            additionalProperties: false,\n            required: ['id', 'title', 'completed']\n          }\n        },\n        401: {\n          type: 'object',\n          properties: {\n            message: { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['message']\n        }\n      }\n    }\n  },\n  async request => {\n    const apiKey = request.headers.get('x-api-key')\n    if (!apiKey) {\n      return Response.json(\n        { message: 'API key is required' },\n        {\n          status: 401\n        }\n      )\n    }\n    const todos = await getTodos({\n      apiKey\n    })\n    // This part is fully typed\n    return Response.json(todos, {\n      status: 200\n    })\n  }\n)\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"ebc4f40f728423088557e1e12dbfff6bb7222a31","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.1","dependencies":{"tslib":"^2.3.1","openapi-types":"12.1.0","json-schema-to-ts":"2.6.2","@whatwg-node/fetch":"0.8.2-alpha-20230227152152-ebc4f40","@whatwg-node/server":"^0.7.0","@whatwg-node/typed-fetch":"0.0.1-alpha-20230227152152-ebc4f40"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.4.0-alpha-20230227152152-ebc4f40_1677511330507_0.9828403827231624","host":"s3://npm-registry-packages"}},"0.4.0-alpha-20230227154338-576087f":{"name":"@whatwg-node/router","version":"0.4.0-alpha-20230227154338-576087f","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.4.0-alpha-20230227154338-576087f","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"5e36c57aa39e7987c96996ba904ad4cf4d6f31a3","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.4.0-alpha-20230227154338-576087f.tgz","fileCount":10,"integrity":"sha512-8w+89WcPbTjobNHLQCVmqKG+RNb8qfKyf28PKI/KzwpEmHHPWyZSxTk8+ld3/OlcRJkSOpYGmi9VQknUgPkKsA==","signatures":[{"sig":"MEUCIFEjElgZJOktjGV48HRc0ePldkl6BUB4VWcGyGtLuPY0AiEA6kmmFhY4wL9NLVkVpV4RAGzWURDKAYX3+8eaIXwBCdI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":50399,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj/M+/ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoNdA/+PzWS9ZUM1OXj3XuZi1GzryjX+pRj/2yV9KDgXMdQx5u7w7s7\r\nbu0o/u1fFLrkMsCSA7Q9Q45pL+Cw1wOcQ+fZVF/UTdZaiqFKlQi75wVjKPFz\r\nlWGiClvU5GM/jWthD5X+NsswUzC/L2PqI/CrmrhFeCiESJ1u9LxINZp8lPTd\r\nebFrywDa7OzpksgKIzg9p3rcz3zcDCVipQCfh0uxw5qLS/dPDkUr6HuhfGww\r\n7STA1mZK//5eF5eCQdPX91HjKoJzLfk0Hz6o/AaTbQX+lU/qyZy7+Qr2CmqX\r\nQSfu3cUrvytmlMOftUECSwUDSnX5pAOHH71qA7rgNnKNfc+GMleh4R3UEQQn\r\nXzy3ac8AzzeTLZmYwCHOueqgAvLSx4yQbWhgBl1EXA7/9qkPatIT5tyByezp\r\n0lDwI+Oybi7uLQgLNwFhXYsgpzA0TQ2LEsw2LG2qRkaVhtCehIneeUvKg+mq\r\nzYa7HzXNlYyv1HusM1wnFYgpb+7RDY/GetbzYE4HMHwa2EDTRw2hLiFhtNDd\r\n4sOYzYE1H2N3L2j4aCmO2HAW4fGeQerWJO5mlOI3VPWKzTF02aMU/gqL0dnJ\r\ncHi1el8rg7IBh7pXXrdH/9l+nP3bI4iXrKtn5MttiICZ95I8OoY+msHHvDEG\r\neL3jC/wo9OxbrEzcD294VDYjgztCyJ3pUlc=\r\n=2RN0\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\n### Basic Routing\n\n```ts\n// Then use it in any environment\nimport { createServer } from 'http'\nimport { createRouter, Router } from '@whatwg-node/router'\n\nconst router = createRouter()\n// GET collection index\nrouter.get('/todos', () => new Response('Todos Index!'))\n// GET item\nrouter.get('/todos/:id', ({ params }) => new Response(`Todo #${params.id}`))\n// POST to the collection (we'll use async here)\nrouter.post('/todos', async request => {\n  const content = await request.json()\n  return new Response('Creating Todo: ' + JSON.stringify(content))\n})\n\n// Redirect to a URL\nrouter.get('/google', () => Response.redirect('http://www.google.com'))\n\n// 404 for everything else\nrouter.all('*', () => new Response('Not Found.', { status: 404 }))\n\nconst httpServer = createServer(router)\nhttpServer.listen(4000)\n```\n\n## Example\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors. Or you can use the plugins to handle errors like below.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Plugins to handle CORS, cookies and more\n\nThis library also provides a plugin system that allows you hook into the request/response lifecycle.\n\n- `onRequest` - Called before the request is handled by the router\n- - It has `endResponse` method that accepts a `Response` object to short-circuit the request\n- `onResponse` - Called after the request is handled by the router\n- - It allows you to modify the response before it is sent to the client\n\n### Cookie Management\n\nYou can use `useCookies` to parse cookies from the request header and set cookies in the response by\nusing Web Standard [CookieStore](https://developer.mozilla.org/en-US/docs/Web/API/CookieStore).\n\n```ts\nimport { createRouter, Response, useCookies } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [useCookies()]\n})\n\nrouter.get('/me', async req => {\n  const sessionId = await request.cookieStore.get('session_id')\n  if (!sessionId) {\n    return Response.json({ error: 'Unauthorized' }, { status: 401 })\n  }\n  const user = await getUserBySessionId(sessionId)\n  return Response.json(user)\n})\n\nrouter.post('/login', async req => {\n  const { username, password } = await req.json()\n  const sessionId = await createSessionForUser({ username, password })\n  await request.cookieStore.set('session_id', sessionId)\n  return Response.json({ message: 'ok' })\n})\n```\n\n### CORS Management\n\nYou can also setup a CORS middleware to handle preflight CORS requests.\n\n```ts\nimport { createRouter, useCORS } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [\n    useCORS({\n      origin: '*',\n      methods: ['GET', 'POST', 'PUT', 'DELETE'],\n      headers: ['Content-Type', 'Authorization']\n    })\n  ]\n})\n```\n\n### Custom plugins\n\nYou can also create your own plugins to handle errors, logging, etc.\n\n```ts\nimport { createRouter } from '@whatwg-node/router'\n\nconst useRequestId = (): RoutePlugin => {\n  return {\n    onRequest({ request, fetchAPI }) {\n      let requestId = request.headers.get('X-Request-ID')\n      if (!requestId) {\n        requestId = fetchAPI.crypto.randomUUID()\n        request.headers.set('X-Request-ID', requestId)\n      }\n    },\n    onResponse({ response, fetchAPI }) {\n      response.headers.set('X-Request-ID', request.headers.get('X-Request-ID'))\n    }\n  }\n}\n\nconst router = createRouter({\n  plugins: [useRequestId()]\n})\n```\n\n## Type Safety with TypeScript, JSON Schema and OpenAPI\n\nThis library is written in TypeScript and it provides type safety for your request and response with\nthe power of JSON Schema.\n\nTo define type-safe routes, we use `addRoute` method with specific parameters.\n\n#### Typing the request\n\nYou can type individual parts of the `Request` object including JSON body, headers, query\nparameters, and URL parameters.\n\n##### JSON Body\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'post',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        JSONBody: {\n          type: 'object',\n          properties: {\n            title: { type: 'string' },\n            completed: { type: 'boolean' }\n          },\n          additionalProperties: false,\n          required: ['title']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const { title, completed } = await request.json()\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Headers\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'post',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        Headers: {\n          type: 'object',\n          properties: {\n            'x-api-key': { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['x-api-key']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const apiKey = request.headers.get('x-api-key')\n    // Would fail on TypeScript compilation\n    const wrongHeaderName = request.headers.get('x-api-key-wrong')\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Path Parameters\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'get',\n    path: '/todos/:id',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        PathParams: {\n          type: 'object',\n          properties: {\n            id: { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['id']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const { id } = request.params\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Query Parameters\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute({\n  method: 'get',\n  path: '/todos',\n  // Define the request body schema\n  schemas: {\n    Request: {\n      QueryParams: {\n        type: 'object',\n        properties: {\n          limit: { type: 'number' },\n          offset: { type: 'number' }\n        },\n        additionalProperties: false,\n        required: ['limit']\n      },\n    }\n  }\n}, async request => {\n  // This part is fully typed\n  const { limit, offset } = request.query\n  // You can also use `URLSearchParams` API\n  const limit = request.parsedURL.searchParams.get('limit')\n  // ...\n  return Response.json({ message: 'ok' })\n})\n```\n\n#### Typing the response\n\nYou can also type the response body by the status code. We strongly recommend to explicitly define\nthe status codes.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'get',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        Headers: {\n          type: 'object',\n          properties: {\n            'x-api-key': { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['x-api-key']\n        }\n      },\n      Response: {\n        200: {\n          type: 'array',\n          items: {\n            type: 'object',\n            properties: {\n              id: { type: 'string' },\n              title: { type: 'string' },\n              completed: { type: 'boolean' }\n            },\n            additionalProperties: false,\n            required: ['id', 'title', 'completed']\n          }\n        },\n        401: {\n          type: 'object',\n          properties: {\n            message: { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['message']\n        }\n      }\n    }\n  },\n  async request => {\n    const apiKey = request.headers.get('x-api-key')\n    if (!apiKey) {\n      return Response.json(\n        { message: 'API key is required' },\n        {\n          status: 401\n        }\n      )\n    }\n    const todos = await getTodos({\n      apiKey\n    })\n    // This part is fully typed\n    return Response.json(todos, {\n      status: 200\n    })\n  }\n)\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"576087f299dc0a5d4c152b3a0c42493e4ea2ab3a","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.1","dependencies":{"tslib":"^2.3.1","openapi-types":"12.1.0","json-schema-to-ts":"2.6.2","@whatwg-node/fetch":"0.8.2-alpha-20230227154338-576087f","@whatwg-node/server":"^0.7.0","@whatwg-node/typed-fetch":"0.0.1-alpha-20230227154338-576087f"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.4.0-alpha-20230227154338-576087f_1677512638714_0.7626948699424787","host":"s3://npm-registry-packages"}},"0.4.0-alpha-20230227195238-be99321":{"name":"@whatwg-node/router","version":"0.4.0-alpha-20230227195238-be99321","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.4.0-alpha-20230227195238-be99321","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"63be60261f9ec221fd22c37456e17df4707b8cbd","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.4.0-alpha-20230227195238-be99321.tgz","fileCount":7,"integrity":"sha512-twV2iuGsV8GiSl5SK1gPfsvpNM4KALz9wdXBwO4LFR8UjxLO8FfUKfWH0h0BCImh7ckuQbNaz5FXObKxCrEV0w==","signatures":[{"sig":"MEYCIQDr7lCzg+rVzh4zYF3izEwFkua16eMZub5gRxjLCpQjrQIhAKk5hnz1mokIqtSJM1Ca31NLXY/kCdCtr4dYiiTAcG3X","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19308,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj/QoVACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmp0HhAAmyNMyChoYFrvYttErDLTSu6p041wJNH/Yo6ewbVgS8fRoaj1\r\nppksrkMVssJlV9aBdI3U6PaMf+LZbGnjC4o3XGlVIautd3iXHJ7gaBV2ZQV/\r\nYDKQUPAC5o6OcWMT6QxTWE8cB1QUQVMrllMwf//Xls2U2+tb0rKc8QfKam6D\r\npltP0LB/6OcPOk45SHLLVw91U05qrZI+SQvToAWDMDb4rT8ksZzTd48ix+4c\r\n6qStEb60Xe4829reNSE3RZabnn6uQMniIQ99pGC4nep1hY2rDnD2ku7/j9Do\r\nyJDESr+zW7ki2g53y81sfvAhdUnm6WoNK/P6sJnQXvMLm8AmKtLT2d52zvev\r\naBLctP06UVvjbnjFRBmIMZsp9zKYA/WWJYjQaRA2OIC6AbjfBlCuw0CylXhr\r\nXo9QZGDSOz+kpQAud7PztGAAF87DLUAtXifOHFHUzLUKJCbDpTSM/1/9j8o5\r\nRnVNdtEop9ZNr+WgeI9q0iyGe+wxz+btRMaq/zoKNORT95v7asu3e7iHO7Ar\r\nN32ehgP3HfPfuKNqsxwyiwA3GCp2MrkDjidjHzTRD665AAx6YwIALnUwg0aj\r\n7pP3g0OZa9Q37OCpwKINtHoa+VTRLQJAONzjkiPo5XG6jmGVp7w8+obhhZDM\r\nqSrHVWhXyv0aGs/TMMKjfJ/0NBmBfLiy1A8=\r\n=75Xm\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"be99321664d40c02315e8d6f3a3232701b37ccb4","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.1","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"^0.8.0","@whatwg-node/server":"^0.7.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.4.0-alpha-20230227195238-be99321_1677527573155_0.6094422790823291","host":"s3://npm-registry-packages"}},"0.4.0-alpha-20230227223133-11ddf9d":{"name":"@whatwg-node/router","version":"0.4.0-alpha-20230227223133-11ddf9d","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.4.0-alpha-20230227223133-11ddf9d","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"e298895dabf4619e18bf26879f7e7d5ffa1f871b","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.4.0-alpha-20230227223133-11ddf9d.tgz","fileCount":7,"integrity":"sha512-JJMDIHRtRTq2oRSqDJIeZIPcWeq3Z26JIl1bYQT68iteY4gFUKE1sr4snoSHFZo+Z/8IMkR8/xg85CTnXwD2bw==","signatures":[{"sig":"MEUCIDUZ4RatQ4A/XTZsHm+DyPd02J1yXoEeqwibjJg/yKBxAiEAucSLear/8ntnrk6IKH/0E62c7N1uRUT77M86SnTNkOM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19308,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj/S9TACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmodlw/+Na1Uc9eZ4PqGTRY9SFjagQA7fLxh/NY1k3eOMM3L0Qak6sTM\r\n5tpmK3XZiuYssMQ8LqxXPLdxEjBxWiCTrWu71xI63rASOLPk6XmTaRPsHjpq\r\nEQVtiH/SAlxOJnoKb02tbK94vsSdPe9XHTgs+xyj2t9QLPtl1vAmGtlqXEv5\r\ncMehqpKLeLwD5FGOlNtYc5fzOVzQBKmc0nuqojjvOqmvoSTL7hXMHzCvRhpp\r\nAnjoNGsGbJ3dxiQ8X2wkDO9dHDriZQsw1YuZBMQmkUCMDQT7VtbtHxgBup2/\r\n4kJ5Y8/nElOZ3n5XmDlqvDih0BfCT5+7V1cxdSASFUxh4UWwyz/a/lJmjfLU\r\npKTjKfxEvTdMkKqioA8ZcvyFTM7Mag5jhzS1Td9vhyhSa94MiLi76p/MiMCr\r\ndKtNUDje5RfEqFr20cYPmBi3CXyWOM/bkYm++EJBC4VhzovwUOGBwXG2nqUx\r\nL7UkXNSifgn4YhxtgHgC5eQ426O9T6ATqGZRABvcWiqeBT03tb05goRS/Vvw\r\n/9tInqKZmXU1XxHWLRNsfV8AuzvIeDUKdC/Te1JJ03sLPMPSLiqOwmpAXsT8\r\n3mMTHnrwE9NQ6IG+OdMYGq3H3Xqtf7EQ6weBOLZlLJebGbX/wz8HSVJamTga\r\nKjcLAzzCXZnHUiSjDw/H4JsWjXmVKIhZlqM=\r\n=9010\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"11ddf9dc0d6f9ae3832b4e1106a45309c3177e35","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.1","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"^0.8.0","@whatwg-node/server":"^0.7.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.4.0-alpha-20230227223133-11ddf9d_1677537107448_0.5450032486874028","host":"s3://npm-registry-packages"}},"0.4.0-rc-20230227223359-a88acf2":{"name":"@whatwg-node/router","version":"0.4.0-rc-20230227223359-a88acf2","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.4.0-rc-20230227223359-a88acf2","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"6373767ec7c6165537240a059822741f70e46d7c","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.4.0-rc-20230227223359-a88acf2.tgz","fileCount":7,"integrity":"sha512-sCnQBPhTvMBROpjpoJvTvEsBlZjXZO1UiVXrToLc997XOecjrT1y8rTKt0YQzVTGkH3fQo1rlWGw5EYv+KikzQ==","signatures":[{"sig":"MEUCIAduW81YRtmblf5SQeuxEVRY4ugcXuaHz6+S0/BGbs9yAiEA1M9Fl61JxpOzIWdYAOihb+m9tOrRKPHmIg5YICqimDA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19305,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj/S/pACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpeBhAAi/5Vriim4ZZxkl1KfgschKK2xV68OjSZ3haC9Mu6bPmBeROi\r\nLyqfD0iJJ+kmIo5JiDUx887vGNd+3Tlg0GVvDXuEuBsJsSVjoCbjLYWXs00O\r\nb2e37uSWxDK5uiczggx3BlDPQ0Sz79+2ZWEgXkYqYO+4DVpbSygyqglnK+QE\r\n+3dPeodePE6xdkJkO89ZCRkbi45gvXbxjYgNZLydh9oSFez3VnomBnYqufF+\r\ncrtgUyPG0Aw/4GrdpuSSqF9xZ1aQo5vUPfD1iUtxe17xzLmLfu0iG/ZKyhjf\r\nGMrRYAhWS1pcQIzQDoaQdtV/D9LH2U0VkiTlG5JFJrbii6nBQXWRNEqtOXCh\r\nHZ9VUotJEfbrTrJK08ho5SF5v8F+VQfs2QZMdEOIf3askBf7dQcpSVlcmjFd\r\nKdV44K384Rl9I2ayiumEYpgNnR7LlNeWHqfr3T9TEa9P7b0CsrQ/9rQXAG81\r\npWVrxDhlNCCULyEnNHw/O2fm8nGRdVZZO4DdIfR1OzWFmRM5tIDEqYjpa03O\r\nJsfUUDT4ASiT+B7pdx6vmEFIT2gfBnxiiJaqFHvZ+yP4XWFZoRpG0+Yh49fP\r\nAsfNHgUV6mx15qkkqGeKAHHiJS6SuEsOKjgM6KDuVZK1UwOSDZbZ6mHk9050\r\nWoxTSA3uxDa0VxdMItjIVP3RlBl6zHjYTtM=\r\n=kzIZ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"a88acf2fe6176a3436672d7d11c93b4291fbe450","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.1","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"^0.8.0","@whatwg-node/server":"^0.7.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.4.0-rc-20230227223359-a88acf2_1677537257021_0.8417154258277018","host":"s3://npm-registry-packages"}},"0.4.0-alpha-20230228084440-36a394c":{"name":"@whatwg-node/router","version":"0.4.0-alpha-20230228084440-36a394c","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.4.0-alpha-20230228084440-36a394c","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"104baf7535b2ae33cabeca9aee2c64acb2a60720","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.4.0-alpha-20230228084440-36a394c.tgz","fileCount":10,"integrity":"sha512-q8ktqbHStkxKwm96g3xANaLCzX8PKvUMgV9DBjic1ZDIaPMTqN5pcyn1kz3ZJOGXO46rEh50+lSdtYnKlo+bwg==","signatures":[{"sig":"MEQCICxB70xLPLAXgKumeKVSDaei300RYX8iNrMO0xodVhD8AiBh8Zzl69+nto2wgWG8bikd2Q8zB+1z1MVNVYeH8m8egQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":50341,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj/b8OACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmoduw//ZG6oLhDD/gD3JRzbujlglWj844EapzSDEEToTeyuVxOSY8iJ\r\nPsBolB1LF9twraUS9AzooUBcJZXgV5CPmnYmMCMkVIhdxK7uarq5B/IDTR2s\r\nay52tDGyT8d/cQ4FvqO6DnPTLf9Zlz0BgRBWew5ZwYjaj19791VED38phOEd\r\nKtKC55ujCG8eEfb7JlsE52KnArFjeq1I6MgntteCxy04oXz/b61Ej79SwygE\r\nmYUJnhX+Z3A5u6nP797Pdhj7rITofGYp65Unegx8pHx4iwLoV0mkO249ZoMK\r\n6ZC5VAf7K4txtGjPMlmqT07HLdz5zt7hcaD26zhRso2OhY3nfyljy1fd+848\r\nrydvnZHMxk+nb/axE5OTO+s63u7IrmUQ9dI66av4QbdAKfQoK4Knf2qNXG6l\r\nfPkIMTB6gw4a0xKlk4NVUJlo/mEpZxRwIsuKy3p/I28gbL4CqfoJtmysCExo\r\n0Z4h6O8fLPofVvtq7m1zlDR/hWEgOleuHl41Q9wGQ+7LzLcaFGQLNZKGxigg\r\nesCN7o/mtdaIiNPVjM+xoferidEO1EgC8daDLCas2xMOB57Yv3+xVE35sVYz\r\nOpUrNJq5vyd5u1GdRMw3ry9VHSFrTjt9VIzHVTjcW+ux0e0zJiKzPHxxbLmg\r\nSCgncyfk5SpR1ygjZWpdtZdyB0P1Z326rNA=\r\n=PNb2\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\n### Basic Routing\n\n```ts\n// Then use it in any environment\nimport { createServer } from 'http'\nimport { createRouter, Router } from '@whatwg-node/router'\n\nconst router = createRouter()\n// GET collection index\nrouter.get('/todos', () => new Response('Todos Index!'))\n// GET item\nrouter.get('/todos/:id', ({ params }) => new Response(`Todo #${params.id}`))\n// POST to the collection (we'll use async here)\nrouter.post('/todos', async request => {\n  const content = await request.json()\n  return new Response('Creating Todo: ' + JSON.stringify(content))\n})\n\n// Redirect to a URL\nrouter.get('/google', () => Response.redirect('http://www.google.com'))\n\n// 404 for everything else\nrouter.all('*', () => new Response('Not Found.', { status: 404 }))\n\nconst httpServer = createServer(router)\nhttpServer.listen(4000)\n```\n\n## Example\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors. Or you can use the plugins to handle errors like below.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Plugins to handle CORS, cookies and more\n\nThis library also provides a plugin system that allows you hook into the request/response lifecycle.\n\n- `onRequest` - Called before the request is handled by the router\n- - It has `endResponse` method that accepts a `Response` object to short-circuit the request\n- `onResponse` - Called after the request is handled by the router\n- - It allows you to modify the response before it is sent to the client\n\n### Cookie Management\n\nYou can use `useCookies` to parse cookies from the request header and set cookies in the response by\nusing Web Standard [CookieStore](https://developer.mozilla.org/en-US/docs/Web/API/CookieStore).\n\n```ts\nimport { createRouter, Response, useCookies } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [useCookies()]\n})\n\nrouter.get('/me', async req => {\n  const sessionId = await request.cookieStore.get('session_id')\n  if (!sessionId) {\n    return Response.json({ error: 'Unauthorized' }, { status: 401 })\n  }\n  const user = await getUserBySessionId(sessionId)\n  return Response.json(user)\n})\n\nrouter.post('/login', async req => {\n  const { username, password } = await req.json()\n  const sessionId = await createSessionForUser({ username, password })\n  await request.cookieStore.set('session_id', sessionId)\n  return Response.json({ message: 'ok' })\n})\n```\n\n### CORS Management\n\nYou can also setup a CORS middleware to handle preflight CORS requests.\n\n```ts\nimport { createRouter, useCORS } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [\n    useCORS({\n      origin: '*',\n      methods: ['GET', 'POST', 'PUT', 'DELETE'],\n      headers: ['Content-Type', 'Authorization']\n    })\n  ]\n})\n```\n\n### Custom plugins\n\nYou can also create your own plugins to handle errors, logging, etc.\n\n```ts\nimport { createRouter } from '@whatwg-node/router'\n\nconst useRequestId = (): RoutePlugin => {\n  return {\n    onRequest({ request, fetchAPI }) {\n      let requestId = request.headers.get('X-Request-ID')\n      if (!requestId) {\n        requestId = fetchAPI.crypto.randomUUID()\n        request.headers.set('X-Request-ID', requestId)\n      }\n    },\n    onResponse({ response, fetchAPI }) {\n      response.headers.set('X-Request-ID', request.headers.get('X-Request-ID'))\n    }\n  }\n}\n\nconst router = createRouter({\n  plugins: [useRequestId()]\n})\n```\n\n## Type Safety with TypeScript, JSON Schema and OpenAPI\n\nThis library is written in TypeScript and it provides type safety for your request and response with\nthe power of JSON Schema.\n\nTo define type-safe routes, we use `addRoute` method with specific parameters.\n\n#### Typing the request\n\nYou can type individual parts of the `Request` object including JSON body, headers, query\nparameters, and URL parameters.\n\n##### JSON Body\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'post',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        JSONBody: {\n          type: 'object',\n          properties: {\n            title: { type: 'string' },\n            completed: { type: 'boolean' }\n          },\n          additionalProperties: false,\n          required: ['title']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const { title, completed } = await request.json()\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Headers\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'post',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        Headers: {\n          type: 'object',\n          properties: {\n            'x-api-key': { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['x-api-key']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const apiKey = request.headers.get('x-api-key')\n    // Would fail on TypeScript compilation\n    const wrongHeaderName = request.headers.get('x-api-key-wrong')\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Path Parameters\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'get',\n    path: '/todos/:id',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        PathParams: {\n          type: 'object',\n          properties: {\n            id: { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['id']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const { id } = request.params\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Query Parameters\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute({\n  method: 'get',\n  path: '/todos',\n  // Define the request body schema\n  schemas: {\n    Request: {\n      QueryParams: {\n        type: 'object',\n        properties: {\n          limit: { type: 'number' },\n          offset: { type: 'number' }\n        },\n        additionalProperties: false,\n        required: ['limit']\n      },\n    }\n  }\n}, async request => {\n  // This part is fully typed\n  const { limit, offset } = request.query\n  // You can also use `URLSearchParams` API\n  const limit = request.parsedURL.searchParams.get('limit')\n  // ...\n  return Response.json({ message: 'ok' })\n})\n```\n\n#### Typing the response\n\nYou can also type the response body by the status code. We strongly recommend to explicitly define\nthe status codes.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'get',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        Headers: {\n          type: 'object',\n          properties: {\n            'x-api-key': { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['x-api-key']\n        }\n      },\n      Response: {\n        200: {\n          type: 'array',\n          items: {\n            type: 'object',\n            properties: {\n              id: { type: 'string' },\n              title: { type: 'string' },\n              completed: { type: 'boolean' }\n            },\n            additionalProperties: false,\n            required: ['id', 'title', 'completed']\n          }\n        },\n        401: {\n          type: 'object',\n          properties: {\n            message: { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['message']\n        }\n      }\n    }\n  },\n  async request => {\n    const apiKey = request.headers.get('x-api-key')\n    if (!apiKey) {\n      return Response.json(\n        { message: 'API key is required' },\n        {\n          status: 401\n        }\n      )\n    }\n    const todos = await getTodos({\n      apiKey\n    })\n    // This part is fully typed\n    return Response.json(todos, {\n      status: 200\n    })\n  }\n)\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"36a394cb8d5a14c1fc34e258f2d135c6a170f8c8","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.1","dependencies":{"tslib":"^2.3.1","openapi-types":"12.1.0","json-schema-to-ts":"2.6.2","@whatwg-node/fetch":"0.8.2-alpha-20230228084440-36a394c","@whatwg-node/server":"^0.7.0","@whatwg-node/typed-fetch":"0.0.1-alpha-20230228084440-36a394c"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.4.0-alpha-20230228084440-36a394c_1677573902050_0.2286293447010821","host":"s3://npm-registry-packages"}},"0.4.0-alpha-20230228090751-8c97448":{"name":"@whatwg-node/router","version":"0.4.0-alpha-20230228090751-8c97448","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.4.0-alpha-20230228090751-8c97448","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"4c0bc5e3bfab42f37c800bec7076b07e766b2a0c","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.4.0-alpha-20230228090751-8c97448.tgz","fileCount":10,"integrity":"sha512-hgOncpHPNjXlo8Vb6y+x/Du6TyjxxwQw6fdcxPkAeaTJBot+ZJGPK5wAHx/Yjpjjs6i0OSBDteBhWqp7b/Vnng==","signatures":[{"sig":"MEYCIQC4a8CpGnS/0ahJXqFIMKgRetXWndGESxvQW7ptEvubpwIhALRWxUAauYrWc9w3SFwqourzv0Ct1ZaUVNziQn0jwf8p","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":50385,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj/cR8ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrpIQ//c3UQAAobaTncNDTWohHp21jQxoqjfEMX2v7gkPLZwhY/oVkM\r\nDeHB+oz3YtRTLUY7q8ZyyDCFzBA5JPQoL2qfs8XCxp3zFx/V0aHMk1rvWrwa\r\n2GKIvtXlW5V2WxF3Mfla9aXyQbhG46TOhIXyAcp0fZgcYxfaKZSzjTZvQ5Es\r\nUwjCt2B8BsFqFx9dYc+QE25y9WIwwApIYSuOXcBqzJfrap4m7CL5cSP1RuOA\r\nNGlkGI6f0ulgn95WSufM4xIz2PjVbJYOsoZU26EoDy1r+t6GMOrjjmuBTW8V\r\nNTvc2+pNAhD393SQGORh+UG8PemDt38punKC5HGNuXgI9PLCZYeluz7V6/qT\r\nYLbhn1IJ2diPm2CnM5yYobhxI2FD0dULHtfHTlPmyuz6aQXdgCPHMxn1Sn5T\r\n5CM3MW3K4KgP3nsBcXdymrOzwPohkXtLUyNN1jQAqIYbowJKW9BHrq/bP/48\r\nmtYxQj/aoRJ5+yUqOcWUZymm0G0NO7q2gBxtKRZNORnA5qzvyPWw+1cWhZUv\r\niERX4pP9VYl3Yc11vevjJcyBHQhykBsTIYjZoSpI4f6s4lGvrjKd7EbwHKLL\r\n2TmXWZpFn/yTymkoPXWcF9j+MG4fMfNryc/eBa2HGiPTcBWqPH4S8a9QXZpQ\r\ndP8Mukd5ep2km52o56R8SnLDk968roA/VAo=\r\n=9yUY\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\n### Basic Routing\n\n```ts\n// Then use it in any environment\nimport { createServer } from 'http'\nimport { createRouter, Router } from '@whatwg-node/router'\n\nconst router = createRouter()\n// GET collection index\nrouter.get('/todos', () => new Response('Todos Index!'))\n// GET item\nrouter.get('/todos/:id', ({ params }) => new Response(`Todo #${params.id}`))\n// POST to the collection (we'll use async here)\nrouter.post('/todos', async request => {\n  const content = await request.json()\n  return new Response('Creating Todo: ' + JSON.stringify(content))\n})\n\n// Redirect to a URL\nrouter.get('/google', () => Response.redirect('http://www.google.com'))\n\n// 404 for everything else\nrouter.all('*', () => new Response('Not Found.', { status: 404 }))\n\nconst httpServer = createServer(router)\nhttpServer.listen(4000)\n```\n\n## Example\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors. Or you can use the plugins to handle errors like below.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Plugins to handle CORS, cookies and more\n\nThis library also provides a plugin system that allows you hook into the request/response lifecycle.\n\n- `onRequest` - Called before the request is handled by the router\n- - It has `endResponse` method that accepts a `Response` object to short-circuit the request\n- `onResponse` - Called after the request is handled by the router\n- - It allows you to modify the response before it is sent to the client\n\n### Cookie Management\n\nYou can use `useCookies` to parse cookies from the request header and set cookies in the response by\nusing Web Standard [CookieStore](https://developer.mozilla.org/en-US/docs/Web/API/CookieStore).\n\n```ts\nimport { createRouter, Response, useCookies } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [useCookies()]\n})\n\nrouter.get('/me', async req => {\n  const sessionId = await request.cookieStore.get('session_id')\n  if (!sessionId) {\n    return Response.json({ error: 'Unauthorized' }, { status: 401 })\n  }\n  const user = await getUserBySessionId(sessionId)\n  return Response.json(user)\n})\n\nrouter.post('/login', async req => {\n  const { username, password } = await req.json()\n  const sessionId = await createSessionForUser({ username, password })\n  await request.cookieStore.set('session_id', sessionId)\n  return Response.json({ message: 'ok' })\n})\n```\n\n### CORS Management\n\nYou can also setup a CORS middleware to handle preflight CORS requests.\n\n```ts\nimport { createRouter, useCORS } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [\n    useCORS({\n      origin: '*',\n      methods: ['GET', 'POST', 'PUT', 'DELETE'],\n      headers: ['Content-Type', 'Authorization']\n    })\n  ]\n})\n```\n\n### Custom plugins\n\nYou can also create your own plugins to handle errors, logging, etc.\n\n```ts\nimport { createRouter } from '@whatwg-node/router'\n\nconst useRequestId = (): RoutePlugin => {\n  return {\n    onRequest({ request, fetchAPI }) {\n      let requestId = request.headers.get('X-Request-ID')\n      if (!requestId) {\n        requestId = fetchAPI.crypto.randomUUID()\n        request.headers.set('X-Request-ID', requestId)\n      }\n    },\n    onResponse({ response, fetchAPI }) {\n      response.headers.set('X-Request-ID', request.headers.get('X-Request-ID'))\n    }\n  }\n}\n\nconst router = createRouter({\n  plugins: [useRequestId()]\n})\n```\n\n## Type Safety with TypeScript, JSON Schema and OpenAPI\n\nThis library is written in TypeScript and it provides type safety for your request and response with\nthe power of JSON Schema.\n\nTo define type-safe routes, we use `addRoute` method with specific parameters.\n\n#### Typing the request\n\nYou can type individual parts of the `Request` object including JSON body, headers, query\nparameters, and URL parameters.\n\n##### JSON Body\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'post',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        JSONBody: {\n          type: 'object',\n          properties: {\n            title: { type: 'string' },\n            completed: { type: 'boolean' }\n          },\n          additionalProperties: false,\n          required: ['title']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const { title, completed } = await request.json()\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Headers\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'post',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        Headers: {\n          type: 'object',\n          properties: {\n            'x-api-key': { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['x-api-key']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const apiKey = request.headers.get('x-api-key')\n    // Would fail on TypeScript compilation\n    const wrongHeaderName = request.headers.get('x-api-key-wrong')\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Path Parameters\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'get',\n    path: '/todos/:id',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        PathParams: {\n          type: 'object',\n          properties: {\n            id: { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['id']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const { id } = request.params\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Query Parameters\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute({\n  method: 'get',\n  path: '/todos',\n  // Define the request body schema\n  schemas: {\n    Request: {\n      QueryParams: {\n        type: 'object',\n        properties: {\n          limit: { type: 'number' },\n          offset: { type: 'number' }\n        },\n        additionalProperties: false,\n        required: ['limit']\n      },\n    }\n  }\n}, async request => {\n  // This part is fully typed\n  const { limit, offset } = request.query\n  // You can also use `URLSearchParams` API\n  const limit = request.parsedURL.searchParams.get('limit')\n  // ...\n  return Response.json({ message: 'ok' })\n})\n```\n\n#### Typing the response\n\nYou can also type the response body by the status code. We strongly recommend to explicitly define\nthe status codes.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'get',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        Headers: {\n          type: 'object',\n          properties: {\n            'x-api-key': { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['x-api-key']\n        }\n      },\n      Response: {\n        200: {\n          type: 'array',\n          items: {\n            type: 'object',\n            properties: {\n              id: { type: 'string' },\n              title: { type: 'string' },\n              completed: { type: 'boolean' }\n            },\n            additionalProperties: false,\n            required: ['id', 'title', 'completed']\n          }\n        },\n        401: {\n          type: 'object',\n          properties: {\n            message: { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['message']\n        }\n      }\n    }\n  },\n  async request => {\n    const apiKey = request.headers.get('x-api-key')\n    if (!apiKey) {\n      return Response.json(\n        { message: 'API key is required' },\n        {\n          status: 401\n        }\n      )\n    }\n    const todos = await getTodos({\n      apiKey\n    })\n    // This part is fully typed\n    return Response.json(todos, {\n      status: 200\n    })\n  }\n)\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"8c974489c0d6547b5bbfedca957925b32fde4e15","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.1","dependencies":{"tslib":"^2.3.1","openapi-types":"12.1.0","json-schema-to-ts":"2.6.2","@whatwg-node/fetch":"0.8.2-alpha-20230228090751-8c97448","@whatwg-node/server":"^0.7.0","@whatwg-node/typed-fetch":"0.0.1-alpha-20230228090751-8c97448"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.4.0-alpha-20230228090751-8c97448_1677575291894_0.6441326434074564","host":"s3://npm-registry-packages"}},"0.4.0-rc-20230228100653-a986914":{"name":"@whatwg-node/router","version":"0.4.0-rc-20230228100653-a986914","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.4.0-rc-20230228100653-a986914","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"76d7093a9bc5d40a73d032a004b335bcbd1099a2","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.4.0-rc-20230228100653-a986914.tgz","fileCount":7,"integrity":"sha512-RWb9pb2SLIXyBXLEJzfKTxUsID+w99DW+rWavolgj9fiiAiDQdGHMl343hnwqlH9HtdbEeOtZp8jCzw3+kxD3g==","signatures":[{"sig":"MEUCIQD0nPHkCwUIp0zAf3NrKhCoTNjTIRR51Vn5EMsS0+FyjwIgCBMVO4da1hzYcPqSSLfSqeqm1AFijU6nOfUNfCxfedg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19305,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj/dJNACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmocDBAAlaKD6PGkOeDprHck6wWqg0B/fxJKI7Ilx+mS+wNnjtpe/6E2\r\nW5ZlnnHiIy9jbo3Lmvyz9pFJq+AAfJXLh4g0pSX2akOPNYWi9WVDIWdYeZag\r\nGWhorIwdMseRrxTDdj8Rk+7u7+u11NzH8QYrmDLDBNo/n7CJZm7A/ILX5VmD\r\nYPtjWTOWZSdFY241leMncHymBE6G3Br5avfnHT7eTckWJ1AG2BMdxmN2oF2p\r\nT/k0t+qMOPbVgBcxoJSMnAvBujqxfhnJC/9M9Oh9GP25guBbTjcXKFL1PZbE\r\nyM332nApRZiaozyGDl1nihwiompLhuP8I5fnNw5NVsaMjLZJj8UQeK7EF4NY\r\nkALNWw8x2DwZp493n4UJVbhRCfILmD0BEc+eS3GsG8/djqqX5ct40ALcT6LI\r\nO+KlrSRbNjmiIm1comPTlsoCnovHKwR45PNjp92S0oYLXqm4M8GtuZmAgsLx\r\n1a2U58khC5h4el7p13xu1CY6vobjswoMmnD0lnFaR9baIAlAIn89V+2QdrkQ\r\nIqY08r8yg/Bp7fD7Fj0/Vr5u4PvhXglhFk3Kg71o0lTQ2y84d7iTybYpbKV0\r\njyJoVoVIs3s4bRKn2t02mRiTK7WFoptpjQ6nr9ZwfiNQTHrCw4rczzCx5aQE\r\nQIexcWLiKX4/lw13x9HED5ly7yvxrZ9A1yc=\r\n=DOyn\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"a986914268f62d9ffe171fd555ace54836fba79f","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.1","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"^0.8.0","@whatwg-node/server":"^0.7.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.4.0-rc-20230228100653-a986914_1677578829057_0.7399780623665322","host":"s3://npm-registry-packages"}},"0.4.0-alpha-20230228121813-6a22ee6":{"name":"@whatwg-node/router","version":"0.4.0-alpha-20230228121813-6a22ee6","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.4.0-alpha-20230228121813-6a22ee6","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"ed6461b0d64f38dfba0d1bbfc033a6808d725171","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.4.0-alpha-20230228121813-6a22ee6.tgz","fileCount":10,"integrity":"sha512-NXt7/dqbN+81uAJCVTJ+mPjEpi8ANhDSuybBdKPmk+WoHjREFlNGvQVD6QNOVcUkCstrgWF0SWSh9I98NTH9Rg==","signatures":[{"sig":"MEUCIQDQMnmkwR69+f5gFZmjph8hzzPhqY0K77bVApdIeIoXCQIgKnUSl3WeOaR7RYiYMOgxTHOqFDvViDKwwFAX7dUV7hk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":50964,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj/fEYACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpGdA//RDrlQNHMhiSM8a6PAFwfGiom4hjwQoS8BNeJNVqJn+nj+tSD\r\n4SLn6X1JnqCaEeeq+GIL03v2epcjv5h5rqKAxD8Se9y1vm88Gg3aSqFx+CvZ\r\nXFsOVT3VSfSWF0wGb8Oh7nAVj7kkEUWx9YA6/5a+3wyjcPCeYjylQYigwKif\r\nJERWjAYTnW3IUPwBbO0DCuhufoDlxoU6Vj/ENy76PDjCiJsT1BLokFEy3Ubx\r\nMUtt0H9Due5ym+9U4Pt5NQCADt1lI8wsl3o04moctkuCj27kDgBSW93h2cC+\r\ntspXdEsdBO77tyPF22JTQIaALE9TReI4lfsvw27AYu5CwLMzf28KGjrMRzg0\r\nKgpujH/E8ZSxn0EbrGJ9Wr8wfG8VkXN1QnLFnF420iljsI9U2keTMPse8Fp4\r\n4ly3tqYrsAcicsVJv/39qCWXxVwbYV7cIaBJiwQJotB1jLdgtO3FG59oNDfO\r\nad7XgWSVCinjBgJSEp16X731x8hWDH51wzAp/5UmoRXQpDxSlW2cb2KRTvjj\r\nV6hR62UoNbWafth6ItTxEXTUYRo2wlG/6zpoF3iOgmKSg9zfxHDvxxd/lKhK\r\nYfK7RV/PAe9mCfv7g9szSYAId+kkNuGh4QZC4exbYgDr+W7UmANHLAzfdt3l\r\nCsjUPs0xrM1VSFJErokBAoFCGED9rmrvBKw=\r\n=oWiV\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\n### Basic Routing\n\n```ts\n// Then use it in any environment\nimport { createServer } from 'http'\nimport { createRouter, Router } from '@whatwg-node/router'\n\nconst router = createRouter()\n// GET collection index\nrouter.get('/todos', () => new Response('Todos Index!'))\n// GET item\nrouter.get('/todos/:id', ({ params }) => new Response(`Todo #${params.id}`))\n// POST to the collection (we'll use async here)\nrouter.post('/todos', async request => {\n  const content = await request.json()\n  return new Response('Creating Todo: ' + JSON.stringify(content))\n})\n\n// Redirect to a URL\nrouter.get('/google', () => Response.redirect('http://www.google.com'))\n\n// 404 for everything else\nrouter.all('*', () => new Response('Not Found.', { status: 404 }))\n\nconst httpServer = createServer(router)\nhttpServer.listen(4000)\n```\n\n## Example\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors. Or you can use the plugins to handle errors like below.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Plugins to handle CORS, cookies and more\n\nThis library also provides a plugin system that allows you hook into the request/response lifecycle.\n\n- `onRequest` - Called before the request is handled by the router\n- - It has `endResponse` method that accepts a `Response` object to short-circuit the request\n- `onResponse` - Called after the request is handled by the router\n- - It allows you to modify the response before it is sent to the client\n\n### Cookie Management\n\nYou can use `useCookies` to parse cookies from the request header and set cookies in the response by\nusing Web Standard [CookieStore](https://developer.mozilla.org/en-US/docs/Web/API/CookieStore).\n\n```ts\nimport { createRouter, Response, useCookies } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [useCookies()]\n})\n\nrouter.get('/me', async req => {\n  const sessionId = await request.cookieStore.get('session_id')\n  if (!sessionId) {\n    return Response.json({ error: 'Unauthorized' }, { status: 401 })\n  }\n  const user = await getUserBySessionId(sessionId)\n  return Response.json(user)\n})\n\nrouter.post('/login', async req => {\n  const { username, password } = await req.json()\n  const sessionId = await createSessionForUser({ username, password })\n  await request.cookieStore.set('session_id', sessionId)\n  return Response.json({ message: 'ok' })\n})\n```\n\n### CORS Management\n\nYou can also setup a CORS middleware to handle preflight CORS requests.\n\n```ts\nimport { createRouter, useCORS } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [\n    useCORS({\n      origin: '*',\n      methods: ['GET', 'POST', 'PUT', 'DELETE'],\n      headers: ['Content-Type', 'Authorization']\n    })\n  ]\n})\n```\n\n### Custom plugins\n\nYou can also create your own plugins to handle errors, logging, etc.\n\n```ts\nimport { createRouter } from '@whatwg-node/router'\n\nconst useRequestId = (): RoutePlugin => {\n  return {\n    onRequest({ request, fetchAPI }) {\n      let requestId = request.headers.get('X-Request-ID')\n      if (!requestId) {\n        requestId = fetchAPI.crypto.randomUUID()\n        request.headers.set('X-Request-ID', requestId)\n      }\n    },\n    onResponse({ response, fetchAPI }) {\n      response.headers.set('X-Request-ID', request.headers.get('X-Request-ID'))\n    }\n  }\n}\n\nconst router = createRouter({\n  plugins: [useRequestId()]\n})\n```\n\n## Type Safety with TypeScript, JSON Schema and OpenAPI\n\nThis library is written in TypeScript and it provides type safety for your request and response with\nthe power of JSON Schema.\n\nTo define type-safe routes, we use `addRoute` method with specific parameters.\n\n#### Typing the request\n\nYou can type individual parts of the `Request` object including JSON body, headers, query\nparameters, and URL parameters.\n\n##### JSON Body\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'post',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        JSONBody: {\n          type: 'object',\n          properties: {\n            title: { type: 'string' },\n            completed: { type: 'boolean' }\n          },\n          additionalProperties: false,\n          required: ['title']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const { title, completed } = await request.json()\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Headers\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'post',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        Headers: {\n          type: 'object',\n          properties: {\n            'x-api-key': { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['x-api-key']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const apiKey = request.headers.get('x-api-key')\n    // Would fail on TypeScript compilation\n    const wrongHeaderName = request.headers.get('x-api-key-wrong')\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Path Parameters\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'get',\n    path: '/todos/:id',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        PathParams: {\n          type: 'object',\n          properties: {\n            id: { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['id']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const { id } = request.params\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Query Parameters\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute({\n  method: 'get',\n  path: '/todos',\n  // Define the request body schema\n  schemas: {\n    Request: {\n      QueryParams: {\n        type: 'object',\n        properties: {\n          limit: { type: 'number' },\n          offset: { type: 'number' }\n        },\n        additionalProperties: false,\n        required: ['limit']\n      },\n    }\n  }\n}, async request => {\n  // This part is fully typed\n  const { limit, offset } = request.query\n  // You can also use `URLSearchParams` API\n  const limit = request.parsedURL.searchParams.get('limit')\n  // ...\n  return Response.json({ message: 'ok' })\n})\n```\n\n#### Typing the response\n\nYou can also type the response body by the status code. We strongly recommend to explicitly define\nthe status codes.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'get',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        Headers: {\n          type: 'object',\n          properties: {\n            'x-api-key': { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['x-api-key']\n        }\n      },\n      Response: {\n        200: {\n          type: 'array',\n          items: {\n            type: 'object',\n            properties: {\n              id: { type: 'string' },\n              title: { type: 'string' },\n              completed: { type: 'boolean' }\n            },\n            additionalProperties: false,\n            required: ['id', 'title', 'completed']\n          }\n        },\n        401: {\n          type: 'object',\n          properties: {\n            message: { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['message']\n        }\n      }\n    }\n  },\n  async request => {\n    const apiKey = request.headers.get('x-api-key')\n    if (!apiKey) {\n      return Response.json(\n        { message: 'API key is required' },\n        {\n          status: 401\n        }\n      )\n    }\n    const todos = await getTodos({\n      apiKey\n    })\n    // This part is fully typed\n    return Response.json(todos, {\n      status: 200\n    })\n  }\n)\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"6a22ee696f3f33050bfdd964f6326d49f73d4446","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.1","dependencies":{"tslib":"^2.3.1","openapi-types":"12.1.0","json-schema-to-ts":"2.6.2","@whatwg-node/fetch":"0.8.2-alpha-20230228121813-6a22ee6","@whatwg-node/server":"^0.7.0","@whatwg-node/typed-fetch":"0.0.1-alpha-20230228121813-6a22ee6"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.4.0-alpha-20230228121813-6a22ee6_1677586712678_0.14127106926491861","host":"s3://npm-registry-packages"}},"0.4.0-alpha-20230228123813-b78e09d":{"name":"@whatwg-node/router","version":"0.4.0-alpha-20230228123813-b78e09d","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.4.0-alpha-20230228123813-b78e09d","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"e9ea1fb699844d8a73c8a766cd4972fcb0be94dc","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.4.0-alpha-20230228123813-b78e09d.tgz","fileCount":10,"integrity":"sha512-cN6XbBaMEnPTfYQ5czKMDaAJQL2IwKkkZhryFJAMyD9fBqcx/2wPKnjB31bgJezKV8POw1Da7CGJDlr1Rh1sOw==","signatures":[{"sig":"MEQCIDP6+YSyvR8tkpMsC9dyaFlNdvSy/xHtzOom3ENJPYEKAiAXR70uXJDPXVb1GTPzKkLpoXUaNpZah6kVckdjyC1aVw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":50950,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj/fXNACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmoo6Q//eM8edaqeZxwuX4MRvMjvCpERL5sgDzrld8vg1bCDbXgYJkRE\r\nBdbBXlRu1V5iH40CPJVZ1UpJuj7dyeJVeHwI46gzjbawtpEn8MNniL78qVfJ\r\na6Ozw1Tjq3deM7iFe+uss4/+ZY5m/KaCbWH/Ygd+4yX89bOBYpbt67C1zhNN\r\n7av7VU0gGGvIPBWnjYJKVyASOvU9P4X622V/LZsLrGpVEhNd07gj/YbwKp6X\r\nlr9SJd6/GWUTfB1VBoAccsrgwEmyHd4vkGsu++vo2v/prKQq/aoh9uRbHj0l\r\nvOudYFpQNBqqBkWvc0LoWz8Jg+WWU7GUJNKYCX6S6n6BgvdvrhQd2zgAYakm\r\nouGuY2mBINg/8XTD/w4aze2MnPL8Ckr9z4RrF28V7R+KM46NURa0zZTmGbTg\r\nhqKgaBcj8PoRCV4zdUSP43usCCiXU8JT02/l3sz3eLGSvPoSkeFyaupH3FzG\r\nefNQVbWavWYMg07HZrQDuYnxW/J+gmjQrSTQ5byPBh6bzM9jipOrrD3MjvRj\r\nAPb59oTjBA9oiILj4ZXdMRNCb0X2KY/2a+fYxTOFLJGMBZ+ah2+SEdrpQqjc\r\n7UdA1T5OpoZ6fspDht9lRGFSXVINwnkIIOtWIgTeTogNZH1nWvXHNLmTWbZu\r\nti1TqZQv9HPjTJE7Vjz7OSFL7OO12CRzapo=\r\n=rMJR\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\n### Basic Routing\n\n```ts\n// Then use it in any environment\nimport { createServer } from 'http'\nimport { createRouter, Router } from '@whatwg-node/router'\n\nconst router = createRouter()\n// GET collection index\nrouter.get('/todos', () => new Response('Todos Index!'))\n// GET item\nrouter.get('/todos/:id', ({ params }) => new Response(`Todo #${params.id}`))\n// POST to the collection (we'll use async here)\nrouter.post('/todos', async request => {\n  const content = await request.json()\n  return new Response('Creating Todo: ' + JSON.stringify(content))\n})\n\n// Redirect to a URL\nrouter.get('/google', () => Response.redirect('http://www.google.com'))\n\n// 404 for everything else\nrouter.all('*', () => new Response('Not Found.', { status: 404 }))\n\nconst httpServer = createServer(router)\nhttpServer.listen(4000)\n```\n\n## Example\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors. Or you can use the plugins to handle errors like below.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Plugins to handle CORS, cookies and more\n\nThis library also provides a plugin system that allows you hook into the request/response lifecycle.\n\n- `onRequest` - Called before the request is handled by the router\n- - It has `endResponse` method that accepts a `Response` object to short-circuit the request\n- `onResponse` - Called after the request is handled by the router\n- - It allows you to modify the response before it is sent to the client\n\n### Cookie Management\n\nYou can use `useCookies` to parse cookies from the request header and set cookies in the response by\nusing Web Standard [CookieStore](https://developer.mozilla.org/en-US/docs/Web/API/CookieStore).\n\n```ts\nimport { createRouter, Response, useCookies } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [useCookies()]\n})\n\nrouter.get('/me', async req => {\n  const sessionId = await request.cookieStore.get('session_id')\n  if (!sessionId) {\n    return Response.json({ error: 'Unauthorized' }, { status: 401 })\n  }\n  const user = await getUserBySessionId(sessionId)\n  return Response.json(user)\n})\n\nrouter.post('/login', async req => {\n  const { username, password } = await req.json()\n  const sessionId = await createSessionForUser({ username, password })\n  await request.cookieStore.set('session_id', sessionId)\n  return Response.json({ message: 'ok' })\n})\n```\n\n### CORS Management\n\nYou can also setup a CORS middleware to handle preflight CORS requests.\n\n```ts\nimport { createRouter, useCORS } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [\n    useCORS({\n      origin: '*',\n      methods: ['GET', 'POST', 'PUT', 'DELETE'],\n      headers: ['Content-Type', 'Authorization']\n    })\n  ]\n})\n```\n\n### Custom plugins\n\nYou can also create your own plugins to handle errors, logging, etc.\n\n```ts\nimport { createRouter } from '@whatwg-node/router'\n\nconst useRequestId = (): RoutePlugin => {\n  return {\n    onRequest({ request, fetchAPI }) {\n      let requestId = request.headers.get('X-Request-ID')\n      if (!requestId) {\n        requestId = fetchAPI.crypto.randomUUID()\n        request.headers.set('X-Request-ID', requestId)\n      }\n    },\n    onResponse({ response, fetchAPI }) {\n      response.headers.set('X-Request-ID', request.headers.get('X-Request-ID'))\n    }\n  }\n}\n\nconst router = createRouter({\n  plugins: [useRequestId()]\n})\n```\n\n## Type Safety with TypeScript, JSON Schema and OpenAPI\n\nThis library is written in TypeScript and it provides type safety for your request and response with\nthe power of JSON Schema.\n\nTo define type-safe routes, we use `addRoute` method with specific parameters.\n\n#### Typing the request\n\nYou can type individual parts of the `Request` object including JSON body, headers, query\nparameters, and URL parameters.\n\n##### JSON Body\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'post',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        JSONBody: {\n          type: 'object',\n          properties: {\n            title: { type: 'string' },\n            completed: { type: 'boolean' }\n          },\n          additionalProperties: false,\n          required: ['title']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const { title, completed } = await request.json()\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Headers\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'post',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        Headers: {\n          type: 'object',\n          properties: {\n            'x-api-key': { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['x-api-key']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const apiKey = request.headers.get('x-api-key')\n    // Would fail on TypeScript compilation\n    const wrongHeaderName = request.headers.get('x-api-key-wrong')\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Path Parameters\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'get',\n    path: '/todos/:id',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        PathParams: {\n          type: 'object',\n          properties: {\n            id: { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['id']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const { id } = request.params\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Query Parameters\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute({\n  method: 'get',\n  path: '/todos',\n  // Define the request body schema\n  schemas: {\n    Request: {\n      QueryParams: {\n        type: 'object',\n        properties: {\n          limit: { type: 'number' },\n          offset: { type: 'number' }\n        },\n        additionalProperties: false,\n        required: ['limit']\n      },\n    }\n  }\n}, async request => {\n  // This part is fully typed\n  const { limit, offset } = request.query\n  // You can also use `URLSearchParams` API\n  const limit = request.parsedURL.searchParams.get('limit')\n  // ...\n  return Response.json({ message: 'ok' })\n})\n```\n\n#### Typing the response\n\nYou can also type the response body by the status code. We strongly recommend to explicitly define\nthe status codes.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'get',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        Headers: {\n          type: 'object',\n          properties: {\n            'x-api-key': { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['x-api-key']\n        }\n      },\n      Response: {\n        200: {\n          type: 'array',\n          items: {\n            type: 'object',\n            properties: {\n              id: { type: 'string' },\n              title: { type: 'string' },\n              completed: { type: 'boolean' }\n            },\n            additionalProperties: false,\n            required: ['id', 'title', 'completed']\n          }\n        },\n        401: {\n          type: 'object',\n          properties: {\n            message: { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['message']\n        }\n      }\n    }\n  },\n  async request => {\n    const apiKey = request.headers.get('x-api-key')\n    if (!apiKey) {\n      return Response.json(\n        { message: 'API key is required' },\n        {\n          status: 401\n        }\n      )\n    }\n    const todos = await getTodos({\n      apiKey\n    })\n    // This part is fully typed\n    return Response.json(todos, {\n      status: 200\n    })\n  }\n)\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"b78e09d19469823e7175c1c8caeb2a92e5feb18a","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.1","dependencies":{"tslib":"^2.3.1","openapi-types":"12.1.0","json-schema-to-ts":"2.6.2","@whatwg-node/fetch":"0.8.2-alpha-20230228123813-b78e09d","@whatwg-node/server":"^0.7.0","@whatwg-node/typed-fetch":"0.0.1-alpha-20230228123813-b78e09d"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.4.0-alpha-20230228123813-b78e09d_1677587917075_0.7010952720633099","host":"s3://npm-registry-packages"}},"0.4.0-alpha-20230228124206-1e319de":{"name":"@whatwg-node/router","version":"0.4.0-alpha-20230228124206-1e319de","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.4.0-alpha-20230228124206-1e319de","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"b0307e409f96127c6ff85b5a93bc871ab4da1365","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.4.0-alpha-20230228124206-1e319de.tgz","fileCount":10,"integrity":"sha512-3Sibuj+NapToyZMt3J/cNYznaSocbAhUPxh8miYsREwYzE2BF+5LdVSyC4KMaVygSIOW+OG/wc5cGU5DUK40Pg==","signatures":[{"sig":"MEUCIGiwSEU7pVBIVNPVZACOFk7KoQR0XB+dcc3HpEUsGZoiAiEAq38MNbfDyXgx2jYsz5sGRjYcW8X9RHL/dN8uoNLeKrI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":50950,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj/fa0ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqfWg//VNlcPOO0KcXadlBezn6DngQcSdzQ84ALyhQyq+6I1l52c8pG\r\nbGG1+gnsvKWxG+fEju3/GPV8/4CS1NyVF4HSLGwvy/tMStDiFnWiU3v4kAF1\r\nn8qhfuTEP78zHYWfEhx4DSB+CUDVhD5KsElEU1Yv4sKfsmEiLIL225DLMZMA\r\n2STAaIIzXvJKXnz9gqjypYrdb1Mx7j69JyvhoeECDgr4rdGrI4xrQ4G1h1uD\r\nSBScxGLbsAHFxL9HMNdTGxBWgqBo+CLqbQjrtWIjX2ILBo8ZmVUz8GkRsaqk\r\n5rovnVULaVsnHuHvUpYMqKXPuLAF5iBSKqQwfhuKK9awmjYrYyeRlYuQ1KcB\r\nDDgDOituX3zYV36so1Wph3a19CjoNN/qNyFO9bl1L51LryQZ2uIrY22LJ6Fb\r\noPVBnidrGWFb0NrArSaamIDbh/beR11XUjt1fNfWWs6R8E6KdEhR2xW8/02n\r\nw+iD2+ENNc20psM6e20pYeP18kEj2Cg7GqFxfITvsmjBL4X09d+U8Qgjv5oj\r\nXf0nD3uCxJorR3ACSOkooPVxtZ9ntCltmyXRhixlSe0w7ZdBsnnjX0cYf3og\r\nwjI8gMlaa8JYaZHEeP3dGOV05TNDeIrZF/4NzTM79isKEyR6/R3rK1+Zld7T\r\nZpOly5UBK4sQYtb+gDvGm2cANYYuNmGNL3A=\r\n=VOu2\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\n### Basic Routing\n\n```ts\n// Then use it in any environment\nimport { createServer } from 'http'\nimport { createRouter, Router } from '@whatwg-node/router'\n\nconst router = createRouter()\n// GET collection index\nrouter.get('/todos', () => new Response('Todos Index!'))\n// GET item\nrouter.get('/todos/:id', ({ params }) => new Response(`Todo #${params.id}`))\n// POST to the collection (we'll use async here)\nrouter.post('/todos', async request => {\n  const content = await request.json()\n  return new Response('Creating Todo: ' + JSON.stringify(content))\n})\n\n// Redirect to a URL\nrouter.get('/google', () => Response.redirect('http://www.google.com'))\n\n// 404 for everything else\nrouter.all('*', () => new Response('Not Found.', { status: 404 }))\n\nconst httpServer = createServer(router)\nhttpServer.listen(4000)\n```\n\n## Example\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors. Or you can use the plugins to handle errors like below.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Plugins to handle CORS, cookies and more\n\nThis library also provides a plugin system that allows you hook into the request/response lifecycle.\n\n- `onRequest` - Called before the request is handled by the router\n- - It has `endResponse` method that accepts a `Response` object to short-circuit the request\n- `onResponse` - Called after the request is handled by the router\n- - It allows you to modify the response before it is sent to the client\n\n### Cookie Management\n\nYou can use `useCookies` to parse cookies from the request header and set cookies in the response by\nusing Web Standard [CookieStore](https://developer.mozilla.org/en-US/docs/Web/API/CookieStore).\n\n```ts\nimport { createRouter, Response, useCookies } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [useCookies()]\n})\n\nrouter.get('/me', async req => {\n  const sessionId = await request.cookieStore.get('session_id')\n  if (!sessionId) {\n    return Response.json({ error: 'Unauthorized' }, { status: 401 })\n  }\n  const user = await getUserBySessionId(sessionId)\n  return Response.json(user)\n})\n\nrouter.post('/login', async req => {\n  const { username, password } = await req.json()\n  const sessionId = await createSessionForUser({ username, password })\n  await request.cookieStore.set('session_id', sessionId)\n  return Response.json({ message: 'ok' })\n})\n```\n\n### CORS Management\n\nYou can also setup a CORS middleware to handle preflight CORS requests.\n\n```ts\nimport { createRouter, useCORS } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [\n    useCORS({\n      origin: '*',\n      methods: ['GET', 'POST', 'PUT', 'DELETE'],\n      headers: ['Content-Type', 'Authorization']\n    })\n  ]\n})\n```\n\n### Custom plugins\n\nYou can also create your own plugins to handle errors, logging, etc.\n\n```ts\nimport { createRouter } from '@whatwg-node/router'\n\nconst useRequestId = (): RoutePlugin => {\n  return {\n    onRequest({ request, fetchAPI }) {\n      let requestId = request.headers.get('X-Request-ID')\n      if (!requestId) {\n        requestId = fetchAPI.crypto.randomUUID()\n        request.headers.set('X-Request-ID', requestId)\n      }\n    },\n    onResponse({ response, fetchAPI }) {\n      response.headers.set('X-Request-ID', request.headers.get('X-Request-ID'))\n    }\n  }\n}\n\nconst router = createRouter({\n  plugins: [useRequestId()]\n})\n```\n\n## Type Safety with TypeScript, JSON Schema and OpenAPI\n\nThis library is written in TypeScript and it provides type safety for your request and response with\nthe power of JSON Schema.\n\nTo define type-safe routes, we use `addRoute` method with specific parameters.\n\n#### Typing the request\n\nYou can type individual parts of the `Request` object including JSON body, headers, query\nparameters, and URL parameters.\n\n##### JSON Body\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'post',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        JSONBody: {\n          type: 'object',\n          properties: {\n            title: { type: 'string' },\n            completed: { type: 'boolean' }\n          },\n          additionalProperties: false,\n          required: ['title']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const { title, completed } = await request.json()\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Headers\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'post',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        Headers: {\n          type: 'object',\n          properties: {\n            'x-api-key': { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['x-api-key']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const apiKey = request.headers.get('x-api-key')\n    // Would fail on TypeScript compilation\n    const wrongHeaderName = request.headers.get('x-api-key-wrong')\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Path Parameters\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'get',\n    path: '/todos/:id',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        PathParams: {\n          type: 'object',\n          properties: {\n            id: { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['id']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const { id } = request.params\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Query Parameters\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute({\n  method: 'get',\n  path: '/todos',\n  // Define the request body schema\n  schemas: {\n    Request: {\n      QueryParams: {\n        type: 'object',\n        properties: {\n          limit: { type: 'number' },\n          offset: { type: 'number' }\n        },\n        additionalProperties: false,\n        required: ['limit']\n      },\n    }\n  }\n}, async request => {\n  // This part is fully typed\n  const { limit, offset } = request.query\n  // You can also use `URLSearchParams` API\n  const limit = request.parsedURL.searchParams.get('limit')\n  // ...\n  return Response.json({ message: 'ok' })\n})\n```\n\n#### Typing the response\n\nYou can also type the response body by the status code. We strongly recommend to explicitly define\nthe status codes.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'get',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        Headers: {\n          type: 'object',\n          properties: {\n            'x-api-key': { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['x-api-key']\n        }\n      },\n      Response: {\n        200: {\n          type: 'array',\n          items: {\n            type: 'object',\n            properties: {\n              id: { type: 'string' },\n              title: { type: 'string' },\n              completed: { type: 'boolean' }\n            },\n            additionalProperties: false,\n            required: ['id', 'title', 'completed']\n          }\n        },\n        401: {\n          type: 'object',\n          properties: {\n            message: { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['message']\n        }\n      }\n    }\n  },\n  async request => {\n    const apiKey = request.headers.get('x-api-key')\n    if (!apiKey) {\n      return Response.json(\n        { message: 'API key is required' },\n        {\n          status: 401\n        }\n      )\n    }\n    const todos = await getTodos({\n      apiKey\n    })\n    // This part is fully typed\n    return Response.json(todos, {\n      status: 200\n    })\n  }\n)\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"1e319de43f6647044424b7458984cbbe70fcd33a","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.1","dependencies":{"tslib":"^2.3.1","openapi-types":"12.1.0","json-schema-to-ts":"2.6.2","@whatwg-node/fetch":"0.8.2-alpha-20230228124206-1e319de","@whatwg-node/server":"^0.7.0","@whatwg-node/typed-fetch":"0.0.1-alpha-20230228124206-1e319de"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.4.0-alpha-20230228124206-1e319de_1677588148120_0.31442297204234126","host":"s3://npm-registry-packages"}},"0.4.0-alpha-20230228151748-5c26743":{"name":"@whatwg-node/router","version":"0.4.0-alpha-20230228151748-5c26743","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.4.0-alpha-20230228151748-5c26743","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"42b5fba837b3b1d298912321949a3788a89ff798","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.4.0-alpha-20230228151748-5c26743.tgz","fileCount":10,"integrity":"sha512-2wul8XssF2qfpM5gD/REQWCRCwfk3r0hDAavMIzGis/O+AOIy/XhuQGyun2jVQb04Dh4QskkxxIBXTzrUhdzUw==","signatures":[{"sig":"MEUCIQC9MwuN6xVgz4+M2es2dVK8DWwEBz8cMk0m26A/pef/bwIgM/ggQ0MkD19RnQnhtqxd3vRUr+WKcYFmmJe6/ng1+Hk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":52047,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj/hsyACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmq4sA//Xj2qXHc2ZFKtk41sa1qEjxtBPWr0a323niXjuwdZGrvJPMKk\r\n29aSFgryP0+QBZfKX4jBe1fVMKHnLYXFyMVaTf9N/4nEAyRrE3Jf+G1JyhWi\r\n7qfMXTvnJCTO8Ukl7S03w9GGm0hrTYDyJLJYBloLA2jOjEznq8ACrIsBxjrv\r\nBaj/ak4WGAFRcZD7RHCiA1ZhpFDyTrUKrbqvDM3L0fSDjOZkJEVBpYT1dOxU\r\n9XuuEizTjx90K3jfix4J6n0KIIA2QmBfSYdVb3VFgq3cGBenAc9Fq8YUQbR7\r\nOZRtyGTzRJY08+mnzjNitxD68tYVS8VZ8oAg47KeSskZZ/vJR4pl+qse89PL\r\nTYyoiEz4SqynEck/PJuF8XJ/hbBVFC29ZF3WV/i00PZEw+eRbiij8PkMc6W+\r\nepROKDskU5IC6CmcFmCKdN8JnSa4pMSnQEIGEj1X4IGyhUUpkFjGYixZNmA4\r\nVK6PMNlHadl5jN/xlq1PQ9y18dLFtcprIVw4evy6IqLcY1NCRBPcB3hbfrc2\r\nrJ9X3vPJ6MM+seV0Z1FsYZ7g6kv35HZp2NbbvNbZD69NGsPzLAE7/uVP14nL\r\nCswqgnnKTQYiuPGE0LG8otDXsaUGLGQ9X2FamoTL+l1aiO6CFH1wAslE6CgE\r\ntQ7CVEpyAtnK2sheX+20I1WQVkPTB+VCTJY=\r\n=SUUK\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\n### Basic Routing\n\n```ts\n// Then use it in any environment\nimport { createServer } from 'http'\nimport { createRouter, Router } from '@whatwg-node/router'\n\nconst router = createRouter()\n// GET collection index\nrouter.get('/todos', () => new Response('Todos Index!'))\n// GET item\nrouter.get('/todos/:id', ({ params }) => new Response(`Todo #${params.id}`))\n// POST to the collection (we'll use async here)\nrouter.post('/todos', async request => {\n  const content = await request.json()\n  return new Response('Creating Todo: ' + JSON.stringify(content))\n})\n\n// Redirect to a URL\nrouter.get('/google', () => Response.redirect('http://www.google.com'))\n\n// 404 for everything else\nrouter.all('*', () => new Response('Not Found.', { status: 404 }))\n\nconst httpServer = createServer(router)\nhttpServer.listen(4000)\n```\n\n## Example\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors. Or you can use the plugins to handle errors like below.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Plugins to handle CORS, cookies and more\n\nThis library also provides a plugin system that allows you hook into the request/response lifecycle.\n\n- `onRequest` - Called before the request is handled by the router\n- - It has `endResponse` method that accepts a `Response` object to short-circuit the request\n- `onResponse` - Called after the request is handled by the router\n- - It allows you to modify the response before it is sent to the client\n\n### Cookie Management\n\nYou can use `useCookies` to parse cookies from the request header and set cookies in the response by\nusing Web Standard [CookieStore](https://developer.mozilla.org/en-US/docs/Web/API/CookieStore).\n\n```ts\nimport { createRouter, Response, useCookies } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [useCookies()]\n})\n\nrouter.get('/me', async req => {\n  const sessionId = await request.cookieStore.get('session_id')\n  if (!sessionId) {\n    return Response.json({ error: 'Unauthorized' }, { status: 401 })\n  }\n  const user = await getUserBySessionId(sessionId)\n  return Response.json(user)\n})\n\nrouter.post('/login', async req => {\n  const { username, password } = await req.json()\n  const sessionId = await createSessionForUser({ username, password })\n  await request.cookieStore.set('session_id', sessionId)\n  return Response.json({ message: 'ok' })\n})\n```\n\n### CORS Management\n\nYou can also setup a CORS middleware to handle preflight CORS requests.\n\n```ts\nimport { createRouter, useCORS } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [\n    useCORS({\n      origin: '*',\n      methods: ['GET', 'POST', 'PUT', 'DELETE'],\n      headers: ['Content-Type', 'Authorization']\n    })\n  ]\n})\n```\n\n### Custom plugins\n\nYou can also create your own plugins to handle errors, logging, etc.\n\n```ts\nimport { createRouter } from '@whatwg-node/router'\n\nconst useRequestId = (): RoutePlugin => {\n  return {\n    onRequest({ request, fetchAPI }) {\n      let requestId = request.headers.get('X-Request-ID')\n      if (!requestId) {\n        requestId = fetchAPI.crypto.randomUUID()\n        request.headers.set('X-Request-ID', requestId)\n      }\n    },\n    onResponse({ response, fetchAPI }) {\n      response.headers.set('X-Request-ID', request.headers.get('X-Request-ID'))\n    }\n  }\n}\n\nconst router = createRouter({\n  plugins: [useRequestId()]\n})\n```\n\n## Type Safety with TypeScript, JSON Schema and OpenAPI\n\nThis library is written in TypeScript and it provides type safety for your request and response with\nthe power of JSON Schema.\n\nTo define type-safe routes, we use `addRoute` method with specific parameters.\n\n#### Typing the request\n\nYou can type individual parts of the `Request` object including JSON body, headers, query\nparameters, and URL parameters.\n\n##### JSON Body\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'post',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        JSONBody: {\n          type: 'object',\n          properties: {\n            title: { type: 'string' },\n            completed: { type: 'boolean' }\n          },\n          additionalProperties: false,\n          required: ['title']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const { title, completed } = await request.json()\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Headers\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'post',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        Headers: {\n          type: 'object',\n          properties: {\n            'x-api-key': { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['x-api-key']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const apiKey = request.headers.get('x-api-key')\n    // Would fail on TypeScript compilation\n    const wrongHeaderName = request.headers.get('x-api-key-wrong')\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Path Parameters\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'get',\n    path: '/todos/:id',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        PathParams: {\n          type: 'object',\n          properties: {\n            id: { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['id']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const { id } = request.params\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Query Parameters\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute({\n  method: 'get',\n  path: '/todos',\n  // Define the request body schema\n  schemas: {\n    Request: {\n      QueryParams: {\n        type: 'object',\n        properties: {\n          limit: { type: 'number' },\n          offset: { type: 'number' }\n        },\n        additionalProperties: false,\n        required: ['limit']\n      },\n    }\n  }\n}, async request => {\n  // This part is fully typed\n  const { limit, offset } = request.query\n  // You can also use `URLSearchParams` API\n  const limit = request.parsedURL.searchParams.get('limit')\n  // ...\n  return Response.json({ message: 'ok' })\n})\n```\n\n#### Typing the response\n\nYou can also type the response body by the status code. We strongly recommend to explicitly define\nthe status codes.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'get',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        Headers: {\n          type: 'object',\n          properties: {\n            'x-api-key': { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['x-api-key']\n        }\n      },\n      Response: {\n        200: {\n          type: 'array',\n          items: {\n            type: 'object',\n            properties: {\n              id: { type: 'string' },\n              title: { type: 'string' },\n              completed: { type: 'boolean' }\n            },\n            additionalProperties: false,\n            required: ['id', 'title', 'completed']\n          }\n        },\n        401: {\n          type: 'object',\n          properties: {\n            message: { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['message']\n        }\n      }\n    }\n  },\n  async request => {\n    const apiKey = request.headers.get('x-api-key')\n    if (!apiKey) {\n      return Response.json(\n        { message: 'API key is required' },\n        {\n          status: 401\n        }\n      )\n    }\n    const todos = await getTodos({\n      apiKey\n    })\n    // This part is fully typed\n    return Response.json(todos, {\n      status: 200\n    })\n  }\n)\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"5c26743a74f69ef1f9b6ad1367d8d2acb714c5ff","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.1","dependencies":{"tslib":"^2.3.1","openapi-types":"12.1.0","json-schema-to-ts":"2.6.2","@whatwg-node/fetch":"0.8.2-alpha-20230228151748-5c26743","@whatwg-node/server":"^0.7.0","@whatwg-node/typed-fetch":"0.0.1-alpha-20230228151748-5c26743"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.4.0-alpha-20230228151748-5c26743_1677597490416_0.09077479838342306","host":"s3://npm-registry-packages"}},"0.4.0-alpha-20230228152145-fde8c53":{"name":"@whatwg-node/router","version":"0.4.0-alpha-20230228152145-fde8c53","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.4.0-alpha-20230228152145-fde8c53","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"b6d22e28d955650010076ad9c9c4129407949631","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.4.0-alpha-20230228152145-fde8c53.tgz","fileCount":10,"integrity":"sha512-t2dKmXJUZL3+UEBwC3eLSskd2XVD2oqE3TSXqNXHWxzFrJ+NJAJyQqxYFBkeV0yybNq9oeN8uZucyJ62JIQX/Q==","signatures":[{"sig":"MEQCIG+subvxOLOf7vX+irqb6yKwUrfw4UTFrRfzGvb2tdlIAiB+wrll5F3fBWtfvOJmf2cHdqcxtbiekwD9l+d17NekWw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":52047,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj/hwiACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqMQxAAmnakRiG3JzcUgPg7hV2s+C0LuERgYH8TBDhX177WrrA2w0YP\r\ncY4n+hwcF9C+79bEafv+zqMCU1IhpBFxvYAPBAG66lwwSMidtUEslrE6P4rK\r\n5FInbXbxl7Rdi0oRAPsLyrEZphBXy+ZfrryJ40H9Pf73sGszrylOraJO7zgh\r\n1Ue9LL7R2949cgQf8fZTjyI0UQi2qhdql8LbieD40jzHT7DgVEENZA98MR9K\r\nq76Z0VFmZ8pV7xme89jihz2pArJYfrx4bGkua0njKRIZ0lryN8MNDzW33xZn\r\nT13hG2M+JcrVj1vFjAdD/msqE13nugMndr6VR16ZHY7VA/t9X6pn1t+jIogN\r\ndhM1VWqkUOmQAhrrvQxhpfhpBgSYZuHWYqMQdQlNouccUDKpiGv1HVmomCKu\r\n8WchmzaPtB2dWn1AI5njJjgnitfoR04eJNgO/17UDbKEPu6SIryLh+FqauV4\r\nxbAFyw+mkL1ukUvKL8o77Uc/5DLvLOOI8k/IhzkpRTn2ytkdF/IcG9Qa8UTn\r\nm88JiusP2QRCZgj56NXvEk6Cu9GVNN4m7ClcCT0flEOBqPSaNLW2Mlk0zSDU\r\nGx3SgENeym3WGM5IBG41b24TKzj1udaWbmlum6Biebb+9RdYEXJv3e8JNHbn\r\nKcbZjEr7Fmuwdmi96RWHrz5o59IkEfrwATA=\r\n=Y1WU\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\n### Basic Routing\n\n```ts\n// Then use it in any environment\nimport { createServer } from 'http'\nimport { createRouter, Router } from '@whatwg-node/router'\n\nconst router = createRouter()\n// GET collection index\nrouter.get('/todos', () => new Response('Todos Index!'))\n// GET item\nrouter.get('/todos/:id', ({ params }) => new Response(`Todo #${params.id}`))\n// POST to the collection (we'll use async here)\nrouter.post('/todos', async request => {\n  const content = await request.json()\n  return new Response('Creating Todo: ' + JSON.stringify(content))\n})\n\n// Redirect to a URL\nrouter.get('/google', () => Response.redirect('http://www.google.com'))\n\n// 404 for everything else\nrouter.all('*', () => new Response('Not Found.', { status: 404 }))\n\nconst httpServer = createServer(router)\nhttpServer.listen(4000)\n```\n\n## Example\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors. Or you can use the plugins to handle errors like below.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Plugins to handle CORS, cookies and more\n\nThis library also provides a plugin system that allows you hook into the request/response lifecycle.\n\n- `onRequest` - Called before the request is handled by the router\n- - It has `endResponse` method that accepts a `Response` object to short-circuit the request\n- `onResponse` - Called after the request is handled by the router\n- - It allows you to modify the response before it is sent to the client\n\n### Cookie Management\n\nYou can use `useCookies` to parse cookies from the request header and set cookies in the response by\nusing Web Standard [CookieStore](https://developer.mozilla.org/en-US/docs/Web/API/CookieStore).\n\n```ts\nimport { createRouter, Response, useCookies } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [useCookies()]\n})\n\nrouter.get('/me', async req => {\n  const sessionId = await request.cookieStore.get('session_id')\n  if (!sessionId) {\n    return Response.json({ error: 'Unauthorized' }, { status: 401 })\n  }\n  const user = await getUserBySessionId(sessionId)\n  return Response.json(user)\n})\n\nrouter.post('/login', async req => {\n  const { username, password } = await req.json()\n  const sessionId = await createSessionForUser({ username, password })\n  await request.cookieStore.set('session_id', sessionId)\n  return Response.json({ message: 'ok' })\n})\n```\n\n### CORS Management\n\nYou can also setup a CORS middleware to handle preflight CORS requests.\n\n```ts\nimport { createRouter, useCORS } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [\n    useCORS({\n      origin: '*',\n      methods: ['GET', 'POST', 'PUT', 'DELETE'],\n      headers: ['Content-Type', 'Authorization']\n    })\n  ]\n})\n```\n\n### Custom plugins\n\nYou can also create your own plugins to handle errors, logging, etc.\n\n```ts\nimport { createRouter } from '@whatwg-node/router'\n\nconst useRequestId = (): RoutePlugin => {\n  return {\n    onRequest({ request, fetchAPI }) {\n      let requestId = request.headers.get('X-Request-ID')\n      if (!requestId) {\n        requestId = fetchAPI.crypto.randomUUID()\n        request.headers.set('X-Request-ID', requestId)\n      }\n    },\n    onResponse({ response, fetchAPI }) {\n      response.headers.set('X-Request-ID', request.headers.get('X-Request-ID'))\n    }\n  }\n}\n\nconst router = createRouter({\n  plugins: [useRequestId()]\n})\n```\n\n## Type Safety with TypeScript, JSON Schema and OpenAPI\n\nThis library is written in TypeScript and it provides type safety for your request and response with\nthe power of JSON Schema.\n\nTo define type-safe routes, we use `addRoute` method with specific parameters.\n\n#### Typing the request\n\nYou can type individual parts of the `Request` object including JSON body, headers, query\nparameters, and URL parameters.\n\n##### JSON Body\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'post',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        JSONBody: {\n          type: 'object',\n          properties: {\n            title: { type: 'string' },\n            completed: { type: 'boolean' }\n          },\n          additionalProperties: false,\n          required: ['title']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const { title, completed } = await request.json()\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Headers\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'post',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        Headers: {\n          type: 'object',\n          properties: {\n            'x-api-key': { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['x-api-key']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const apiKey = request.headers.get('x-api-key')\n    // Would fail on TypeScript compilation\n    const wrongHeaderName = request.headers.get('x-api-key-wrong')\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Path Parameters\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'get',\n    path: '/todos/:id',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        PathParams: {\n          type: 'object',\n          properties: {\n            id: { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['id']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const { id } = request.params\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Query Parameters\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute({\n  method: 'get',\n  path: '/todos',\n  // Define the request body schema\n  schemas: {\n    Request: {\n      QueryParams: {\n        type: 'object',\n        properties: {\n          limit: { type: 'number' },\n          offset: { type: 'number' }\n        },\n        additionalProperties: false,\n        required: ['limit']\n      },\n    }\n  }\n}, async request => {\n  // This part is fully typed\n  const { limit, offset } = request.query\n  // You can also use `URLSearchParams` API\n  const limit = request.parsedURL.searchParams.get('limit')\n  // ...\n  return Response.json({ message: 'ok' })\n})\n```\n\n#### Typing the response\n\nYou can also type the response body by the status code. We strongly recommend to explicitly define\nthe status codes.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'get',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        Headers: {\n          type: 'object',\n          properties: {\n            'x-api-key': { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['x-api-key']\n        }\n      },\n      Response: {\n        200: {\n          type: 'array',\n          items: {\n            type: 'object',\n            properties: {\n              id: { type: 'string' },\n              title: { type: 'string' },\n              completed: { type: 'boolean' }\n            },\n            additionalProperties: false,\n            required: ['id', 'title', 'completed']\n          }\n        },\n        401: {\n          type: 'object',\n          properties: {\n            message: { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['message']\n        }\n      }\n    }\n  },\n  async request => {\n    const apiKey = request.headers.get('x-api-key')\n    if (!apiKey) {\n      return Response.json(\n        { message: 'API key is required' },\n        {\n          status: 401\n        }\n      )\n    }\n    const todos = await getTodos({\n      apiKey\n    })\n    // This part is fully typed\n    return Response.json(todos, {\n      status: 200\n    })\n  }\n)\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"fde8c53bd5ac403fe7383abd47791b201bf6808b","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.1","dependencies":{"tslib":"^2.3.1","openapi-types":"12.1.0","json-schema-to-ts":"2.6.2","@whatwg-node/fetch":"0.8.2-alpha-20230228152145-fde8c53","@whatwg-node/server":"^0.7.0","@whatwg-node/typed-fetch":"0.0.1-alpha-20230228152145-fde8c53"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.4.0-alpha-20230228152145-fde8c53_1677597729793_0.23500102797243527","host":"s3://npm-registry-packages"}},"0.4.0-alpha-20230228153302-5b1cd55":{"name":"@whatwg-node/router","version":"0.4.0-alpha-20230228153302-5b1cd55","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.4.0-alpha-20230228153302-5b1cd55","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"ee9e0e1b99b256dfc857b30148e3e04236f9771e","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.4.0-alpha-20230228153302-5b1cd55.tgz","fileCount":10,"integrity":"sha512-0C3vjQmuhwjVqpEvblyv/Csx+LBf6KpdOCxs+x9qwhpLXLBEOM7d3JLND9Cc0gKYKP6KDe3u5EbQHrAkryDiAw==","signatures":[{"sig":"MEUCIFFi84bLG/a9gcRAglRL51hg9YmMG6ilfHTm2Kd/6PJ3AiEAw8zgsUy9N3/cXPeOU6lbHj+6B4Ic7xBZT00nfoiMXY4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":52843,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj/h7CACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmr2wRAAlZBj/QIfzAZFd6ZePQkYLbSARFPPPyeeouG8qJM+GQb64j8W\r\nFkXFU1vJId3JlfRdLjfdB6ECd9VYdJsWgvUmGRNl3vDUPHb0qqQ1aXFpNli7\r\nEspgu+X6F1/6I16BET1dJWZOS+PpYbjcfsFgNYdCfwfLWY3/hrkuWr3jtDoQ\r\nqvLQzHs9quzyvp7+cS+dnRHNJrQLd/I7V5sPskFmpJ8ZwpPcDh1dsygf1SDF\r\nV2ldGMmoYPLsTXYyrB4R8CApIAwmpFAFzjgXWeGaQ5i5oD+EVNJMTEw4B8Xl\r\nV7DN24YUeJtILY+I145iLF61HlwFjg+YgfWh7b4VcJE0ovG+B9m1i8esiPnT\r\nhkHxBIXNZ6Uj+9WziOVDgEZkkp/aajLeAkz3jUz2YGrgiu1gqqoI8aN5fcx2\r\nbcXHZ3REne7gN/Te/F1ANeX7zz/cXoIrHpiBMxS7zCJTV9o1wm6Ng1EULdoX\r\nCN+ONZS6b06pqpMLIWrVwMRDzOBi/Q2aqawggljyk5zMblGlAkS+x7U3AXLE\r\nBr/PL8YDiusTgFvnrs0ogASdBMJsFj4tYdPbYgvZIVieNJpeI75OjPEk3fQh\r\nRq4b9uxIphjGNcAFb0FUFo2Zt5X6YPJLeRuLk8ORxTAb0IRndhl/+HX/ORTw\r\n1AvcOY3HrPSVDc+Y61zHuczZm5WY9hs9Jfs=\r\n=jk0R\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\n### Basic Routing\n\n```ts\n// Then use it in any environment\nimport { createServer } from 'http'\nimport { createRouter, Router } from '@whatwg-node/router'\n\nconst router = createRouter()\n// GET collection index\nrouter.get('/todos', () => new Response('Todos Index!'))\n// GET item\nrouter.get('/todos/:id', ({ params }) => new Response(`Todo #${params.id}`))\n// POST to the collection (we'll use async here)\nrouter.post('/todos', async request => {\n  const content = await request.json()\n  return new Response('Creating Todo: ' + JSON.stringify(content))\n})\n\n// Redirect to a URL\nrouter.get('/google', () => Response.redirect('http://www.google.com'))\n\n// 404 for everything else\nrouter.all('*', () => new Response('Not Found.', { status: 404 }))\n\nconst httpServer = createServer(router)\nhttpServer.listen(4000)\n```\n\n## Example\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors. Or you can use the plugins to handle errors like below.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Plugins to handle CORS, cookies and more\n\nThis library also provides a plugin system that allows you hook into the request/response lifecycle.\n\n- `onRequest` - Called before the request is handled by the router\n- - It has `endResponse` method that accepts a `Response` object to short-circuit the request\n- `onResponse` - Called after the request is handled by the router\n- - It allows you to modify the response before it is sent to the client\n\n### Cookie Management\n\nYou can use `useCookies` to parse cookies from the request header and set cookies in the response by\nusing Web Standard [CookieStore](https://developer.mozilla.org/en-US/docs/Web/API/CookieStore).\n\n```ts\nimport { createRouter, Response, useCookies } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [useCookies()]\n})\n\nrouter.get('/me', async req => {\n  const sessionId = await request.cookieStore.get('session_id')\n  if (!sessionId) {\n    return Response.json({ error: 'Unauthorized' }, { status: 401 })\n  }\n  const user = await getUserBySessionId(sessionId)\n  return Response.json(user)\n})\n\nrouter.post('/login', async req => {\n  const { username, password } = await req.json()\n  const sessionId = await createSessionForUser({ username, password })\n  await request.cookieStore.set('session_id', sessionId)\n  return Response.json({ message: 'ok' })\n})\n```\n\n### CORS Management\n\nYou can also setup a CORS middleware to handle preflight CORS requests.\n\n```ts\nimport { createRouter, useCORS } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [\n    useCORS({\n      origin: '*',\n      methods: ['GET', 'POST', 'PUT', 'DELETE'],\n      headers: ['Content-Type', 'Authorization']\n    })\n  ]\n})\n```\n\n### Custom plugins\n\nYou can also create your own plugins to handle errors, logging, etc.\n\n```ts\nimport { createRouter } from '@whatwg-node/router'\n\nconst useRequestId = (): RoutePlugin => {\n  return {\n    onRequest({ request, fetchAPI }) {\n      let requestId = request.headers.get('X-Request-ID')\n      if (!requestId) {\n        requestId = fetchAPI.crypto.randomUUID()\n        request.headers.set('X-Request-ID', requestId)\n      }\n    },\n    onResponse({ response, fetchAPI }) {\n      response.headers.set('X-Request-ID', request.headers.get('X-Request-ID'))\n    }\n  }\n}\n\nconst router = createRouter({\n  plugins: [useRequestId()]\n})\n```\n\n## Type Safety with TypeScript, JSON Schema and OpenAPI\n\nThis library is written in TypeScript and it provides type safety for your request and response with\nthe power of JSON Schema.\n\nTo define type-safe routes, we use `addRoute` method with specific parameters.\n\n#### Typing the request\n\nYou can type individual parts of the `Request` object including JSON body, headers, query\nparameters, and URL parameters.\n\n##### JSON Body\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'post',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        JSONBody: {\n          type: 'object',\n          properties: {\n            title: { type: 'string' },\n            completed: { type: 'boolean' }\n          },\n          additionalProperties: false,\n          required: ['title']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const { title, completed } = await request.json()\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Headers\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'post',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        Headers: {\n          type: 'object',\n          properties: {\n            'x-api-key': { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['x-api-key']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const apiKey = request.headers.get('x-api-key')\n    // Would fail on TypeScript compilation\n    const wrongHeaderName = request.headers.get('x-api-key-wrong')\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Path Parameters\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'get',\n    path: '/todos/:id',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        PathParams: {\n          type: 'object',\n          properties: {\n            id: { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['id']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const { id } = request.params\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Query Parameters\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute({\n  method: 'get',\n  path: '/todos',\n  // Define the request body schema\n  schemas: {\n    Request: {\n      QueryParams: {\n        type: 'object',\n        properties: {\n          limit: { type: 'number' },\n          offset: { type: 'number' }\n        },\n        additionalProperties: false,\n        required: ['limit']\n      },\n    }\n  }\n}, async request => {\n  // This part is fully typed\n  const { limit, offset } = request.query\n  // You can also use `URLSearchParams` API\n  const limit = request.parsedURL.searchParams.get('limit')\n  // ...\n  return Response.json({ message: 'ok' })\n})\n```\n\n#### Typing the response\n\nYou can also type the response body by the status code. We strongly recommend to explicitly define\nthe status codes.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'get',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        Headers: {\n          type: 'object',\n          properties: {\n            'x-api-key': { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['x-api-key']\n        }\n      },\n      Response: {\n        200: {\n          type: 'array',\n          items: {\n            type: 'object',\n            properties: {\n              id: { type: 'string' },\n              title: { type: 'string' },\n              completed: { type: 'boolean' }\n            },\n            additionalProperties: false,\n            required: ['id', 'title', 'completed']\n          }\n        },\n        401: {\n          type: 'object',\n          properties: {\n            message: { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['message']\n        }\n      }\n    }\n  },\n  async request => {\n    const apiKey = request.headers.get('x-api-key')\n    if (!apiKey) {\n      return Response.json(\n        { message: 'API key is required' },\n        {\n          status: 401\n        }\n      )\n    }\n    const todos = await getTodos({\n      apiKey\n    })\n    // This part is fully typed\n    return Response.json(todos, {\n      status: 200\n    })\n  }\n)\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"5b1cd55f1740a3d9b910b8c9c4615a8318fdcc6e","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.1","dependencies":{"tslib":"^2.3.1","openapi-types":"12.1.0","json-schema-to-ts":"2.6.2","@whatwg-node/fetch":"0.8.2-alpha-20230228153302-5b1cd55","@whatwg-node/server":"^0.7.0","@whatwg-node/typed-fetch":"0.0.1-alpha-20230228153302-5b1cd55"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.4.0-alpha-20230228153302-5b1cd55_1677598402259_0.8156231813060204","host":"s3://npm-registry-packages"}},"0.4.0-alpha-20230228160609-08baffb":{"name":"@whatwg-node/router","version":"0.4.0-alpha-20230228160609-08baffb","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.4.0-alpha-20230228160609-08baffb","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"0bd814e2b6a1e9b4a0cadb3e9437eea564a1d89d","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.4.0-alpha-20230228160609-08baffb.tgz","fileCount":10,"integrity":"sha512-8pBjbZ/YVSKa8YS4tD5V6JGaIA+7jKNr5v3vke4W4G922gvKEztHxoq7CssPoea6KCfQepjaD6o+t2pknks/Pg==","signatures":[{"sig":"MEQCICFUroOeHnb5k2s3lkphngwJPsZ6o8Pig0QXiY575HbmAiBK0gqewJJHGoOa37XzT3RAUpoxWkW9Uz+O66CnF8wmyA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":53809,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj/iaFACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoGsQ//WdBm9xanTCMj9A/uhArFv3nzh8G5J0NSWEQb8NVm+/oztd0V\r\n+0mFUf3k/I9ZlcPnCgn2LgJ0rfAc0bnAEYqHAes4dQUyW4MjfLIHS9KUiGGw\r\nmENg/6Dq3Tm6E7YJP20HhQ5FPNYPo2DZQ6gZPIMe87gTHkWycoLCp/6sy4RG\r\nnYyeIQaJd5hMG0CCjq8QcjJxmhMl6MXwDxAp4FhRdV04NoUt6oIIe8/Teo/5\r\nPpBcGF9EchR6CuS4IOdpnofXQSvgkLm9Fu5h5JXSILP2C0cgTULd2HjO4AoW\r\nnHU5DyUwN3GXhr735hbOuQasSAm2uTj4HAMhazYTZMQeDn+ax/D+lrdX7mQq\r\n4a/upBzgmso0BcrTGvChSUZQHK5EZb1dYC8+qBa2DDc+cl3qn/dZTerOL6OJ\r\n6PM9AZuckgzt+poXS6+Ya3XJmMvobqFZI059C+JfWX/yQIUC+Qx/i3SHgB+l\r\n2SPYQWm4SpYTBR30ng8qiVFttt59lUhqPHKZYsmcbqX2hZuz1BshYgmFtWLv\r\nu+dPV0VQ4UkKnOCBZNGCzqLwbTML1wFDXdX9dbC0T0VB5DvAGcpYUQ6ybBnE\r\njp5IB9rfO57CZziXjmbVhW2Q0wrBqoxMD7a1CfJJDbaDulB7Ut+9PhdrSULF\r\n/t6No1yGMXutKqjxz6dL9teXs4ym+gKZ4Zs=\r\n=80h8\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\n### Basic Routing\n\n```ts\n// Then use it in any environment\nimport { createServer } from 'http'\nimport { createRouter, Router } from '@whatwg-node/router'\n\nconst router = createRouter()\n// GET collection index\nrouter.get('/todos', () => new Response('Todos Index!'))\n// GET item\nrouter.get('/todos/:id', ({ params }) => new Response(`Todo #${params.id}`))\n// POST to the collection (we'll use async here)\nrouter.post('/todos', async request => {\n  const content = await request.json()\n  return new Response('Creating Todo: ' + JSON.stringify(content))\n})\n\n// Redirect to a URL\nrouter.get('/google', () => Response.redirect('http://www.google.com'))\n\n// 404 for everything else\nrouter.all('*', () => new Response('Not Found.', { status: 404 }))\n\nconst httpServer = createServer(router)\nhttpServer.listen(4000)\n```\n\n## Example\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors. Or you can use the plugins to handle errors like below.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Plugins to handle CORS, cookies and more\n\nThis library also provides a plugin system that allows you hook into the request/response lifecycle.\n\n- `onRequest` - Called before the request is handled by the router\n- - It has `endResponse` method that accepts a `Response` object to short-circuit the request\n- `onResponse` - Called after the request is handled by the router\n- - It allows you to modify the response before it is sent to the client\n\n### Cookie Management\n\nYou can use `useCookies` to parse cookies from the request header and set cookies in the response by\nusing Web Standard [CookieStore](https://developer.mozilla.org/en-US/docs/Web/API/CookieStore).\n\n```ts\nimport { createRouter, Response, useCookies } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [useCookies()]\n})\n\nrouter.get('/me', async req => {\n  const sessionId = await request.cookieStore.get('session_id')\n  if (!sessionId) {\n    return Response.json({ error: 'Unauthorized' }, { status: 401 })\n  }\n  const user = await getUserBySessionId(sessionId)\n  return Response.json(user)\n})\n\nrouter.post('/login', async req => {\n  const { username, password } = await req.json()\n  const sessionId = await createSessionForUser({ username, password })\n  await request.cookieStore.set('session_id', sessionId)\n  return Response.json({ message: 'ok' })\n})\n```\n\n### CORS Management\n\nYou can also setup a CORS middleware to handle preflight CORS requests.\n\n```ts\nimport { createRouter, useCORS } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [\n    useCORS({\n      origin: '*',\n      methods: ['GET', 'POST', 'PUT', 'DELETE'],\n      headers: ['Content-Type', 'Authorization']\n    })\n  ]\n})\n```\n\n### Custom plugins\n\nYou can also create your own plugins to handle errors, logging, etc.\n\n```ts\nimport { createRouter } from '@whatwg-node/router'\n\nconst useRequestId = (): RoutePlugin => {\n  return {\n    onRequest({ request, fetchAPI }) {\n      let requestId = request.headers.get('X-Request-ID')\n      if (!requestId) {\n        requestId = fetchAPI.crypto.randomUUID()\n        request.headers.set('X-Request-ID', requestId)\n      }\n    },\n    onResponse({ response, fetchAPI }) {\n      response.headers.set('X-Request-ID', request.headers.get('X-Request-ID'))\n    }\n  }\n}\n\nconst router = createRouter({\n  plugins: [useRequestId()]\n})\n```\n\n## Type Safety with TypeScript, JSON Schema and OpenAPI\n\nThis library is written in TypeScript and it provides type safety for your request and response with\nthe power of JSON Schema.\n\nTo define type-safe routes, we use `addRoute` method with specific parameters.\n\n#### Typing the request\n\nYou can type individual parts of the `Request` object including JSON body, headers, query\nparameters, and URL parameters.\n\n##### JSON Body\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'post',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        JSONBody: {\n          type: 'object',\n          properties: {\n            title: { type: 'string' },\n            completed: { type: 'boolean' }\n          },\n          additionalProperties: false,\n          required: ['title']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const { title, completed } = await request.json()\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Headers\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'post',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        Headers: {\n          type: 'object',\n          properties: {\n            'x-api-key': { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['x-api-key']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const apiKey = request.headers.get('x-api-key')\n    // Would fail on TypeScript compilation\n    const wrongHeaderName = request.headers.get('x-api-key-wrong')\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Path Parameters\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'get',\n    path: '/todos/:id',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        PathParams: {\n          type: 'object',\n          properties: {\n            id: { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['id']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const { id } = request.params\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Query Parameters\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute({\n  method: 'get',\n  path: '/todos',\n  // Define the request body schema\n  schemas: {\n    Request: {\n      QueryParams: {\n        type: 'object',\n        properties: {\n          limit: { type: 'number' },\n          offset: { type: 'number' }\n        },\n        additionalProperties: false,\n        required: ['limit']\n      },\n    }\n  }\n}, async request => {\n  // This part is fully typed\n  const { limit, offset } = request.query\n  // You can also use `URLSearchParams` API\n  const limit = request.parsedURL.searchParams.get('limit')\n  // ...\n  return Response.json({ message: 'ok' })\n})\n```\n\n#### Typing the response\n\nYou can also type the response body by the status code. We strongly recommend to explicitly define\nthe status codes.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'get',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        Headers: {\n          type: 'object',\n          properties: {\n            'x-api-key': { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['x-api-key']\n        }\n      },\n      Response: {\n        200: {\n          type: 'array',\n          items: {\n            type: 'object',\n            properties: {\n              id: { type: 'string' },\n              title: { type: 'string' },\n              completed: { type: 'boolean' }\n            },\n            additionalProperties: false,\n            required: ['id', 'title', 'completed']\n          }\n        },\n        401: {\n          type: 'object',\n          properties: {\n            message: { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['message']\n        }\n      }\n    }\n  },\n  async request => {\n    const apiKey = request.headers.get('x-api-key')\n    if (!apiKey) {\n      return Response.json(\n        { message: 'API key is required' },\n        {\n          status: 401\n        }\n      )\n    }\n    const todos = await getTodos({\n      apiKey\n    })\n    // This part is fully typed\n    return Response.json(todos, {\n      status: 200\n    })\n  }\n)\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"08baffb81f16a9878af0e4a04f4839abb10e5e07","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.1","dependencies":{"tslib":"^2.3.1","openapi-types":"12.1.0","json-schema-to-ts":"2.6.2","@whatwg-node/fetch":"0.8.2-alpha-20230228160609-08baffb","@whatwg-node/server":"^0.7.0","@whatwg-node/typed-fetch":"0.0.1-alpha-20230228160609-08baffb"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.4.0-alpha-20230228160609-08baffb_1677600389227_0.13475221870978626","host":"s3://npm-registry-packages"}},"0.4.0-alpha-20230228164431-66d6bec":{"name":"@whatwg-node/router","version":"0.4.0-alpha-20230228164431-66d6bec","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.4.0-alpha-20230228164431-66d6bec","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"71a77184a32c8144570ca2cf94d9d4e399432858","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.4.0-alpha-20230228164431-66d6bec.tgz","fileCount":10,"integrity":"sha512-jaQ2jAx5PR9BnSd9YDKNZlm9CFv2xCaCFYHs42G1a2qRwvGthFxEPhHCCL5e2qkVSEYPXsljfGohy/lV7hVjcA==","signatures":[{"sig":"MEUCICH8YX4DQ6JKqW0ZMcv1q+m2A2DBVOBcBmc7iJmjqQTIAiEA3LKHfvBHXHF9mSXv6ICw5XSDR/Hwe/AfHJ2eYnS6dKw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":53837,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj/i+FACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmq2jhAAgnya0dlu1SoVBI43rBadz5nCs1XSP9yjcOSf8ZCdGAEvgMks\r\nQuxmGGlKbWzCTpNiBzaX+25AhzE9zbB4+/UBn+dmjcOADh9dfpDHbH0pItdw\r\ntprlgkMRsHSXsL3yokyiS4XGv8IynFDmbNs8aecEM99HQ0SUpax8/N/I/jZo\r\noey8gBiXTVRx4seMAUqqCAFzjB0r4uw3w/05w+Es5AsVUl1LKZchb1IwrbtO\r\nGnZIR9C+ZI2lf0jIoHbj7cqg0XXiTxx5tZLMc6FMiuGkmIBuvhzyDHzYtrfA\r\nbv/uQ/PhpDPAs0N3ka4dp4uge7aEtrrY9dbw9vQOIBnw7NvFC8VUa2EhpQTO\r\nKwGqLdQldNFkz23fbf73Ra9FRzZE15fHxKlVlql15h7w9+xl23cd17sabazR\r\n1lm2u19zwE0ohiCHiboJf6UZHRxvo4PatrFXBgQS9m7c8zC4p0Vv2i+SCaoB\r\nhMilviHHQFMRJnvJMoKP7xaA4Cq6BenXHE7ZUPnOqqAqBKnbo05LN3jGYXOM\r\nYEm2dxus6R4GMcZxlNAFpvEcXDEHZKFQFE9iOWTVJGbQG9kYDFCt+LCW3t0l\r\nPBnRdduXO0zoDljUsZ/2ICpzT1pgzBn2i6dxGI9J3YKs7iOLa3wzTQt8BZR3\r\nkQ5d9UfIwxHa1wLwnN6BYzv9UCsv7Rqfu6c=\r\n=ezNa\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\n### Basic Routing\n\n```ts\n// Then use it in any environment\nimport { createServer } from 'http'\nimport { createRouter, Router } from '@whatwg-node/router'\n\nconst router = createRouter()\n// GET collection index\nrouter.get('/todos', () => new Response('Todos Index!'))\n// GET item\nrouter.get('/todos/:id', ({ params }) => new Response(`Todo #${params.id}`))\n// POST to the collection (we'll use async here)\nrouter.post('/todos', async request => {\n  const content = await request.json()\n  return new Response('Creating Todo: ' + JSON.stringify(content))\n})\n\n// Redirect to a URL\nrouter.get('/google', () => Response.redirect('http://www.google.com'))\n\n// 404 for everything else\nrouter.all('*', () => new Response('Not Found.', { status: 404 }))\n\nconst httpServer = createServer(router)\nhttpServer.listen(4000)\n```\n\n## Example\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors. Or you can use the plugins to handle errors like below.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Plugins to handle CORS, cookies and more\n\nThis library also provides a plugin system that allows you hook into the request/response lifecycle.\n\n- `onRequest` - Called before the request is handled by the router\n- - It has `endResponse` method that accepts a `Response` object to short-circuit the request\n- `onResponse` - Called after the request is handled by the router\n- - It allows you to modify the response before it is sent to the client\n\n### Cookie Management\n\nYou can use `useCookies` to parse cookies from the request header and set cookies in the response by\nusing Web Standard [CookieStore](https://developer.mozilla.org/en-US/docs/Web/API/CookieStore).\n\n```ts\nimport { createRouter, Response, useCookies } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [useCookies()]\n})\n\nrouter.get('/me', async req => {\n  const sessionId = await request.cookieStore.get('session_id')\n  if (!sessionId) {\n    return Response.json({ error: 'Unauthorized' }, { status: 401 })\n  }\n  const user = await getUserBySessionId(sessionId)\n  return Response.json(user)\n})\n\nrouter.post('/login', async req => {\n  const { username, password } = await req.json()\n  const sessionId = await createSessionForUser({ username, password })\n  await request.cookieStore.set('session_id', sessionId)\n  return Response.json({ message: 'ok' })\n})\n```\n\n### CORS Management\n\nYou can also setup a CORS middleware to handle preflight CORS requests.\n\n```ts\nimport { createRouter, useCORS } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [\n    useCORS({\n      origin: '*',\n      methods: ['GET', 'POST', 'PUT', 'DELETE'],\n      headers: ['Content-Type', 'Authorization']\n    })\n  ]\n})\n```\n\n### Custom plugins\n\nYou can also create your own plugins to handle errors, logging, etc.\n\n```ts\nimport { createRouter } from '@whatwg-node/router'\n\nconst useRequestId = (): RoutePlugin => {\n  return {\n    onRequest({ request, fetchAPI }) {\n      let requestId = request.headers.get('X-Request-ID')\n      if (!requestId) {\n        requestId = fetchAPI.crypto.randomUUID()\n        request.headers.set('X-Request-ID', requestId)\n      }\n    },\n    onResponse({ response, fetchAPI }) {\n      response.headers.set('X-Request-ID', request.headers.get('X-Request-ID'))\n    }\n  }\n}\n\nconst router = createRouter({\n  plugins: [useRequestId()]\n})\n```\n\n## Type Safety with TypeScript, JSON Schema and OpenAPI\n\nThis library is written in TypeScript and it provides type safety for your request and response with\nthe power of JSON Schema.\n\nTo define type-safe routes, we use `addRoute` method with specific parameters.\n\n#### Typing the request\n\nYou can type individual parts of the `Request` object including JSON body, headers, query\nparameters, and URL parameters.\n\n##### JSON Body\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'post',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        JSONBody: {\n          type: 'object',\n          properties: {\n            title: { type: 'string' },\n            completed: { type: 'boolean' }\n          },\n          additionalProperties: false,\n          required: ['title']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const { title, completed } = await request.json()\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Headers\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'post',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        Headers: {\n          type: 'object',\n          properties: {\n            'x-api-key': { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['x-api-key']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const apiKey = request.headers.get('x-api-key')\n    // Would fail on TypeScript compilation\n    const wrongHeaderName = request.headers.get('x-api-key-wrong')\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Path Parameters\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'get',\n    path: '/todos/:id',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        PathParams: {\n          type: 'object',\n          properties: {\n            id: { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['id']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const { id } = request.params\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n##### Query Parameters\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute({\n  method: 'get',\n  path: '/todos',\n  // Define the request body schema\n  schemas: {\n    Request: {\n      QueryParams: {\n        type: 'object',\n        properties: {\n          limit: { type: 'number' },\n          offset: { type: 'number' }\n        },\n        additionalProperties: false,\n        required: ['limit']\n      },\n    }\n  }\n}, async request => {\n  // This part is fully typed\n  const { limit, offset } = request.query\n  // You can also use `URLSearchParams` API\n  const limit = request.parsedURL.searchParams.get('limit')\n  // ...\n  return Response.json({ message: 'ok' })\n})\n```\n\n#### Typing the response\n\nYou can also type the response body by the status code. We strongly recommend to explicitly define\nthe status codes.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'get',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      Request: {\n        Headers: {\n          type: 'object',\n          properties: {\n            'x-api-key': { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['x-api-key']\n        }\n      },\n      Response: {\n        200: {\n          type: 'array',\n          items: {\n            type: 'object',\n            properties: {\n              id: { type: 'string' },\n              title: { type: 'string' },\n              completed: { type: 'boolean' }\n            },\n            additionalProperties: false,\n            required: ['id', 'title', 'completed']\n          }\n        },\n        401: {\n          type: 'object',\n          properties: {\n            message: { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['message']\n        }\n      }\n    }\n  },\n  async request => {\n    const apiKey = request.headers.get('x-api-key')\n    if (!apiKey) {\n      return Response.json(\n        { message: 'API key is required' },\n        {\n          status: 401\n        }\n      )\n    }\n    const todos = await getTodos({\n      apiKey\n    })\n    // This part is fully typed\n    return Response.json(todos, {\n      status: 200\n    })\n  }\n)\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"66d6bec4e5b00cfe237e072efcce3c90cf0c6b2d","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.1","dependencies":{"tslib":"^2.3.1","openapi-types":"12.1.0","json-schema-to-ts":"2.6.2","@whatwg-node/fetch":"0.8.2-alpha-20230228164431-66d6bec","@whatwg-node/server":"0.7.2-alpha-20230228164431-66d6bec","@whatwg-node/typed-fetch":"0.0.1-alpha-20230228164431-66d6bec"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.4.0-alpha-20230228164431-66d6bec_1677602693719_0.7611309404013944","host":"s3://npm-registry-packages"}},"0.4.0-alpha-20230301045639-3f96977":{"name":"@whatwg-node/router","version":"0.4.0-alpha-20230301045639-3f96977","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.4.0-alpha-20230301045639-3f96977","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"e67db665542e920ec44d3d62f3e80d10a55d4b19","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.4.0-alpha-20230301045639-3f96977.tgz","fileCount":7,"integrity":"sha512-L7QH7PWOgTzZ87pvs/Fejjde8OuAayTs2tlU7Jyx3jlRY/VEP6erqg9IRfiNgDARBcbV1LRZ/Il634xgkTX6vA==","signatures":[{"sig":"MEYCIQD2Fjl0CujDf+eAbH3Il0a1CVL2ZeBxAY6AVFwuj1a0sgIhAJoIXV1CMUpYJyR6B1//apeGMx2imX9v+ob5SKIbL9pB","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19308,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj/tsXACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmo8jBAAlU9onxJbVGfUErhJZv247PNbTwHeH6jD7YH4C8fRB0BqE8FP\r\nyl2vRbVT8ZOf8Cf7daai+220PAWqatP4CM8uQh1SV6L9t3ow1KSv4hcoMLdV\r\nQPS2HB/q/Igzln130XjSTylEoM/24xGpoDiI2qfsDGnG70yubkj2cZWjT0yg\r\n9LQKp/0KGw/ctLB5RId28iRotFnKUjR+pxHIGFN8Ts+EWisiDh13WS0oD0tx\r\nkdzMde07UBxalt//SSc90Q012n7KlxcTpqeSzE0Kt+PdCSeb3hdRHekcPb5/\r\nHzLumSWxu/gtyW6E7D9XI4E85bqdIxBTAJRbfUf8ZF3L31P8ArVow9Pv5vNX\r\nl6jqBsDpQE7Se5DGgorMTa3ATUiVirza06eA9HBIQvvxKrF4ncw/GYbUOUgi\r\neMYeM0An5ev9KJVV0A1EOJ9MGiNAiPFtoT4ii6jJTZPA8H9+49iahs3DzC4H\r\nzwA7fUt1DJr5wlz+0T/d07WeOCPJPDMiu2bqAgPAcwxfsz3z47ddtt+oTTg/\r\ntnTwopGPvjky9rW1OLWie3ehyGaSIdY+hDh9yp46Y4LQmXkK1XNGrIgNVCKe\r\n2gTAJW9FlapYtsDQqRYluqRv3iykU6diY35bsA6mxoanXOrY0acVyds4TCsa\r\ns78kaxINqwBxG5c+jFg6oR+lqmNyq2Uf390=\r\n=+uFf\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"3f969775bf42955cf96e41eddfc80042d90f87ce","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.1","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"^0.8.0","@whatwg-node/server":"^0.7.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.4.0-alpha-20230301045639-3f96977_1677646614949_0.09073586739429085","host":"s3://npm-registry-packages"}},"0.4.0-rc-20230301090452-7e2e4ed":{"name":"@whatwg-node/router","version":"0.4.0-rc-20230301090452-7e2e4ed","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.4.0-rc-20230301090452-7e2e4ed","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"abdf495055eb7567fc63329f999a6c8ebeb768b4","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.4.0-rc-20230301090452-7e2e4ed.tgz","fileCount":7,"integrity":"sha512-MxQp95ZbgIfjIbE0621cTryuOQp+Ov6MdX8E0GVI5SEuv/OLxzYlyXUlQIgGqRxbVvJeNj2QjVQVGf5mDvxpYA==","signatures":[{"sig":"MEUCIE6WjJn5saUmaYMvc1pc6d9qLVejJoSfhbfmKsWsO7BDAiEAsB6Sh9TMgd4H7+cVEOheeE32tkbabK2Uln0m5P+KPss=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19305,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj/xVDACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqTCw/8DgnPSyoWV1ZM80RZDeC5F1bAEXaWY9NHWvcR9AmF0XCYmjHL\r\naJ5Sh1NmnCRdbbJdBuYaicVD0upyRbNyX3a1C8XalOxWxeUWCVeVw2W7fHCp\r\nJ2ajz7ks8EIgOQ7h735CIGBfIotuPm2wFScu59Kx+XVP0UVoxsrrpHaN3LcW\r\neqJAzP2OX3zme/dU934NXwhGE4PLw2/cuRNL73O3kKP5Ry9xDYXmtBf1GUs2\r\ns9x8y8/VUeDPISWMN7sygOzoLwnF4tIBi9MwiVkrS9kaN+0Jvb/H6dI4nviA\r\na8bOnVee4g4fAUknUN9f9Yucl53vDh/odnhgsUBmcnKvQP6QJdBWEIrYwuTu\r\nl7ZzfDaM6X9q2M5/np8pr9gZLRKZkbna0knrFSIc9TPjRaGMAs2QBXp4hF1H\r\nZh3HLVsNQZ0GuZPxgBy2kEBw2kjI2bz06rBIUQT5/9AypH0DwQsDdKMiLvhV\r\nOJebRzMotTxjvKY5ieudvpTwuf2rfb+TuQF/I5drsDtois9Tqmv7zlX7MOOw\r\n5HkjxtBrxs/8Fvni1ozcx6s4nJf/6Wk6f7HeyPNhWu7ntp2z3kny/1tF+B61\r\nbOVT4spPmStpS4wibfeBVqHH7eS+O1g2TYQ6BAwZicldUnjpKFZmYS1XkfTY\r\nEbXIvn2ZSTAW40G/kswdNxjvDQEyobkQKgE=\r\n=Sxkt\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"7e2e4ed5ef0530cd159a07bf36d4064d07855d05","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.1","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"^0.8.0","@whatwg-node/server":"^0.7.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.4.0-rc-20230301090452-7e2e4ed_1677661507037_0.057996447830876985","host":"s3://npm-registry-packages"}},"0.4.0-alpha-20230301133541-9e26be0":{"name":"@whatwg-node/router","version":"0.4.0-alpha-20230301133541-9e26be0","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.4.0-alpha-20230301133541-9e26be0","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"e05412acff72f994a97e2581ef97d41c3aa9a15d","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.4.0-alpha-20230301133541-9e26be0.tgz","fileCount":7,"integrity":"sha512-KZFiYAEBjyG27wp0ryU+7lw8WsdCDWD2g4C7kb/7bnbHpOfyjW0D9z/0zOUPlxy3T5/wnz9qyOGq9ZE2j7udEw==","signatures":[{"sig":"MEUCIQDPfI5KtbzyFqOIfdCkIszyM/WFFViym3XKXrvhXFG3ZgIgFOqGkGJPF/2n+e7gLxC+ZtMrglCv+4NY8uJXLcHNNsw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19308,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj/1S8ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmpocw/+JgcJVVL020G51p/kU92fjc/N2K8n7ufomgvKfA7hAdwfxvpr\r\nUP3YCrXsL+fp7x7TIPsHkZufsBAd39PhDNUx/xDeNovGJsL0e8+PhgiVl+nF\r\nFD5TBqdSQHjUDge9RLC4K5Xqnz+ZPA+r+meiomFdeD6dpmMM5SFGXRfz7wMl\r\nFEUd+xsSPmJHTb3//mPYqjeGSM6Nsb6tAXwSMgDVmL126GmIxjjvKYY44jYm\r\nOJCW//mWFIbU0f58ZUPhQ70Al+2g0bjFEOIvD1K8ET6KgRwMVCEvtfZU2PRW\r\nJTC1Me4GDIkvIRbxirXHNgVjYAxkhrbuFGVDf6iesRDgVG5ZDN7uSLs80LPb\r\nqAQW1nFEU+1PjnV+x9wUsILUYaZqTBRfUZqjnSBV9cvpiEGNk5i3jvZFPAn3\r\nu6gnOot+/rHnIUx4Ntm8b+9/5Sau5AYynWacbqbkOpw8v5w+f59saL1S+z87\r\ne+WzbDOMEQyD7YF4JAjoSLLeCV+uFkErqHz6VRImJl7zLTti37SPLZ6nSv8u\r\nNU7z50rpR2G4IuJVUE4NgLPsjpbsMw4DqXto94pe06DceNa0i7zipCZgeOe7\r\n202h6KeGdxoRfia0edQdfiwDYUmsiYPxFsjl2oMlLw4vsZN9pV1tM6MW3Lvh\r\nTlZPyFJJIZyFvTuQHGNptk71AhsS8wsI5lM=\r\n=Avj4\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"9e26be0c35fd2931ea0ea9bcf3ccbf8eaeb29942","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.5.0","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.2","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"^0.8.0","@whatwg-node/server":"^0.7.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.4.0-alpha-20230301133541-9e26be0_1677677756374_0.22148146763330412","host":"s3://npm-registry-packages"}},"0.4.0-alpha-20230301144304-75f91ef":{"name":"@whatwg-node/router","version":"0.4.0-alpha-20230301144304-75f91ef","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.4.0-alpha-20230301144304-75f91ef","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"54fc7c128e1fd7cb016d75292f25b586e4e66be9","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.4.0-alpha-20230301144304-75f91ef.tgz","fileCount":10,"integrity":"sha512-vyRl5D1uh11u7Z6Q4bx2+tRwVbzHoIkA/b2MocRZqd0wBlMgj3ixP9zd4nWIYO5HcFwDAvpfBR24drngg0wwlQ==","signatures":[{"sig":"MEUCIQCFs5bYgTLqBBf7PTcHKZ62oGHeoBQn2zzOQLiyclxo4wIgW52kMmxyeXkO31yJPoXw1Gw3D4VSeUBSq4VC8kEIX9k=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":57670,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj/2SQACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrZnw//eBE6GOHOPkTnqSenhQt4LepG9DvrdzYgQxpOBqf+wdi5zrf1\r\nJdhF06OCMpa1TeYWPqE8vZvblGcfmWIDxZ1MEBCX+bmkiXcbLcp0bvzoQ1nN\r\nkmt4PKWIOzffBYmHapizhDyyReyE+EhOrI4/zfo/cNG2eDmw+Bpfo8qvb5hH\r\nOlRq0eo7ZaAKqH1OX/ktVvgHCoB5j/dAbk6KSL3bS8h2qLG5QfuqFjFQYD+9\r\ndGFUTdrgosO0q+N4L1iope6KLBaQu3nPafb2eSbIKjExr7qULqzg4SQ66ttM\r\nxw4ajv1VzllPHDSmfT5hZpt9y9H7k7OkYklqI6Z4F9H5KwqhqbWHM89pX+Xb\r\n+osOd00lrRdLdhpMxpq2in/bw6myo9e9tVVppxLmz0Fj+mMpZLNr1CE5bboa\r\nhB1zhln+G6RWSYGFowqaQNsyhjIX1jPtZQ72OpSFd4gkjUHyI+NHbVoWGkNw\r\n4NlpwVHF183KrZDdPpASQ5ON0unhqUm3dCbS0F7dwSMlqVu8kVbfHx2RVl5y\r\nPPC0/3hhaDq1iq2D0A19ba32Z81wwhJVvY1CCqIhNK5uFBTgs0le8QEdyilo\r\nmPiD8rGWEFtxaij3xD23Oweg3GzL4L1LyF90omAMRQDtp2sH0B9OesjHVjDF\r\nFS5HIX5BCM0HC4V4F7dNGCl3jf3ywxRR0D8=\r\n=q0Hu\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic fully type-safe JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\nIt also allows you to create end-to-end type-safe and validated HTTP APIs with JSON Schema without\n**ANY CODE GENERATION**.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Why should I use this package instead of tRPC?\n\ntRPC doesn't need a code generation like this library, but this library allows you export an OpenAPI\ndocument based on the JSON Schema definitions if you don't want to share TypeScript definitions\nbetween the client and the server. And this library uses [JSON Schema](https://json-schema.org/)\ninstead of a programmatic schema solution like zod which is more portable and has bigger ecosystem.\nSo even if you don't want to write JSON Schemas manually, you can use `@sinclair/typebox` to\ngenerate them by using an API like `zod` has.\n\n## Usage\n\nIt uses `.route()` method to add routes to the router with the following parameters;\n\n- `method`: The HTTP method of the request. This is optional and it handles all methods if it's not\n  given.\n- `path`: The URL pattern that the request should match. The url pattern is a string that follows\n  the [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can\n  learn more about URL patterns\n  [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n- `schemas`: An object that contains the schemas for the request and response. This brings a\n  type-safety and validation to your requests and responses. You can learn more about schemas\n  [here](#end-to-end-type-safety-and-validation-with-json-schema).\n- `handler`: The function that will be called when the request matches the given method and path.\n  This function can be either synchronous or asynchronous. If it's asynchronous, it should return a\n  `Promise` that resolves to a `Response` object.\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nYou can learn more about the original `Request` object\n[here](https://developer.mozilla.org/en-US/docs/Web/API/Request).\n\n### Basic Routing\n\n```ts\n// Then use it in any environment\nimport { createServer } from 'http'\nimport { createRouter, Response, Router } from '@whatwg-node/router'\n\nconst router = createRouter()\n  // GET collection index\n  .route({\n    method: 'GET',\n    path: '/todos',\n    handler: () => new Response('Todos Index!')\n  })\n  // GET item\n  .route({\n    method: 'GET',\n    path: '/todos/:id',\n    handler: ({ params }) => new Response(`Todo #${params.id}`)\n  })\n  // POST to the collection (we'll use async here)\n  .route({\n    method: 'POST',\n    path: '/todos',\n    handler: async request => {\n      const content = await request.json()\n      return new Response('Creating Todo: ' + JSON.stringify(content))\n    }\n  })\n\n  // Redirect to a URL\n  .route({\n    method: 'GET',\n    path: '/google',\n    handler: () => Response.redirect('http://www.google.com')\n  })\n\n  // 404 for everything else\n  .route({\n    path: '*',\n    handler: () => new Response('Not Found.', { status: 404 })\n  })\n\nconst httpServer = createServer(router)\nhttpServer.listen(4000)\n```\n\n## Example\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nconst router = createRouter()\n  .route({\n    method: 'GET',\n    path: '/users',\n    handler: () => Response.json(users)\n  })\n  // Parameters are given in the `request.params` object\n  .route({\n    method: 'GET',\n    path: '/users/:id',\n    handler: request => {\n      const user = users.find(user => user.id === request.params.id)\n\n      if (!user) {\n        return new Response(null, {\n          status: 404\n        })\n      }\n\n      return Response.json(user)\n    }\n  })\n  .route({\n    method: 'DELETE',\n    path: '/users/:id',\n    handler: request => {\n      const user = users.find(user => user.id === request.params.id)\n\n      if (!user) {\n        return new Response(null, {\n          status: 404\n        })\n      }\n\n      users.splice(users.indexOf(user), 1)\n\n      return new Response(null, {\n        status: 204\n      })\n    }\n  })\n  // Handle JSON bodies\n  .route({\n    method: 'PUT',\n    path: '/users',\n    handler: async request => {\n      const body = await request.json()\n\n      const user = {\n        id: String(users.length + 1),\n        name: body.name\n      }\n\n      users.push(user)\n\n      return Response.json(user)\n    }\n  })\n  // Handle both parameters and JSON body\n  .route({\n    method: 'PATCH',\n    path: '/users/:id',\n    handler: async request => {\n      const user = users.find(user => user.id === request.params.id)\n\n      if (!user) {\n        return new Response(null, {\n          status: 404\n        })\n      }\n\n      const body = await request.json()\n\n      user.name = body.name\n\n      return Response.json(user)\n    }\n  })\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nconst router = createRouter()\n  .route({\n    path: '*',\n    handler: request => {\n      if (!request.headers.get('Authorization')) {\n        return new Response(null, {\n          status: 401\n        })\n      }\n    }\n  })\n  .route({\n    path: '/users',\n    method: 'GET',\n    handler: request => {\n    // It doesn't reach here if the request doesn't have an `Authorization` header.\n  });\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nconst router = createRouter().route({\n  path: '/users',\n  method: 'GET',\n  handler: [\n    withAuth,\n    request => {\n      // It doesn't reach here if the request doesn't have an `Authorization` header.\n    }\n  ]\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors. Or you can use the plugins to handle errors like below.\n\n```ts\nconst router = createRouter().route({\n  path: '/users',\n  method: 'GET',\n  handler: request => {\n    try {\n      // Do something\n    } catch (error) {\n      return new Response('I handled the error gracefully', {\n        status: 500\n      })\n    }\n  }\n})\n```\n\n## Plugins to handle CORS, cookies and more\n\nThis library also provides a plugin system that allows you hook into the request/response lifecycle.\n\n- `onRequest` - Called before the request is handled by the router\n- - It has `endResponse` method that accepts a `Response` object to short-circuit the request\n- `onResponse` - Called after the request is handled by the router\n- - It allows you to modify the response before it is sent to the client\n\n### Cookie Management\n\nYou can use `useCookies` to parse cookies from the request header and set cookies in the response by\nusing Web Standard [CookieStore](https://developer.mozilla.org/en-US/docs/Web/API/CookieStore).\n\n```ts\nimport { createRouter, Response, useCookies } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [useCookies()]\n})\n.route({\n  path: '/users',\n  method: 'GET',\n  handler: request => {\n    const sessionId = await request.cookieStore.get('session_id')\n    if (!sessionId) {\n      return Response.json({ error: 'Unauthorized' }, { status: 401 })\n    }\n    const user = await getUserBySessionId(sessionId)\n    return Response.json(user)\n  }\n})\n.route({\n  path: '/login',\n  method: 'POST',\n  handler: async request => {\n    const { username, password } = await request.json()\n    const sessionId = await createSessionForUser({ username, password })\n    await request.cookieStore.set('session_id', sessionId)\n    return Response.json({ message: 'ok' })\n  }\n})\n```\n\n### CORS Management\n\nYou can also setup a CORS middleware to handle preflight CORS requests.\n\n```ts\nimport { createRouter, useCORS } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [\n    useCORS({\n      origin: '*',\n      methods: ['GET', 'POST', 'PUT', 'DELETE'],\n      headers: ['Content-Type', 'Authorization']\n    })\n  ]\n})\n```\n\n### Custom plugins\n\nYou can also create your own plugins to handle errors, logging, etc.\n\n```ts\nimport { createRouter } from '@whatwg-node/router'\n\nconst useRequestId = (): RoutePlugin => {\n  return {\n    onRequest({ request, fetchAPI }) {\n      let requestId = request.headers.get('X-Request-ID')\n      if (!requestId) {\n        requestId = fetchAPI.crypto.randomUUID()\n        request.headers.set('X-Request-ID', requestId)\n      }\n    },\n    onResponse({ response, fetchAPI }) {\n      response.headers.set('X-Request-ID', request.headers.get('X-Request-ID'))\n    }\n  }\n}\n\nconst router = createRouter({\n  plugins: [useRequestId()]\n})\n```\n\n## End-to-End Type Safety and Validation with JSON Schema\n\nEven if the library provides you some type safety with TypeScript's type inference, you can still\nuse JSON Schemas to have a better type safety on both request and response.\n\nTo define type-safe routes, we use `schemas` parameters\n\n### Typing the request\n\nYou can type individual parts of the `Request` object including JSON body, headers, query\nparameters, and URL parameters.\n\n#### JSON Body\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().route(\n  {\n    method: 'post',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      request: {\n        json: {\n          type: 'object',\n          properties: {\n            title: { type: 'string' },\n            completed: { type: 'boolean' }\n          },\n          additionalProperties: false,\n          required: ['title']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const { title, completed } = await request.json()\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n#### Headers\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().route(\n  {\n    method: 'post',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      request: {\n        headers: {\n          type: 'object',\n          properties: {\n            'x-api-key': { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['x-api-key']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const apiKey = request.headers.get('x-api-key')\n    // Would fail on TypeScript compilation\n    const wrongHeaderName = request.headers.get('x-api-key-wrong')\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n#### Path Parameters\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().route(\n  {\n    method: 'get',\n    path: '/todos/:id',\n    // Define the request body schema\n    schemas: {\n      request: {\n        params: {\n          type: 'object',\n          properties: {\n            id: { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['id']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const { id } = request.params\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n#### Query Parameters\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute({\n  method: 'get',\n  path: '/todos',\n  // Define the request body schema\n  schemas: {\n    request: {\n      query: {\n        type: 'object',\n        properties: {\n          limit: { type: 'number' },\n          offset: { type: 'number' }\n        },\n        additionalProperties: false,\n        required: ['limit']\n      },\n    }\n  }\n}, async request => {\n  // This part is fully typed\n  const { limit, offset } = request.query\n  // You can also use `URLSearchParams` API\n  const limit = request.parsedURL.searchParams.get('limit')\n  // ...\n  return Response.json({ message: 'ok' })\n})\n```\n\n### Typing the response\n\nYou can also type the response body by the status code. We strongly recommend to explicitly define\nthe status codes.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'get',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      request: {\n        headers: {\n          type: 'object',\n          properties: {\n            'x-api-key': { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['x-api-key']\n        }\n      },\n      response: {\n        200: {\n          type: 'array',\n          items: {\n            type: 'object',\n            properties: {\n              id: { type: 'string' },\n              title: { type: 'string' },\n              completed: { type: 'boolean' }\n            },\n            additionalProperties: false,\n            required: ['id', 'title', 'completed']\n          }\n        },\n        401: {\n          type: 'object',\n          properties: {\n            message: { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['message']\n        }\n      }\n    }\n  },\n  async request => {\n    const apiKey = request.headers.get('x-api-key')\n    if (!apiKey) {\n      return Response.json(\n        { message: 'API key is required' },\n        {\n          status: 401\n        }\n      )\n    }\n    const todos = await getTodos({\n      apiKey\n    })\n    // This part is fully typed\n    return Response.json(todos, {\n      status: 200\n    })\n  }\n)\n```\n\n### Runtime validation with Ajv\n\nThe library itself doesn't include a runtime validation by default. But you can use that plugin to\nhave a runtime validation with the provided JSON Schemas above. This plugin uses\n[Ajv](https://ajv.js.org/) under the hood. All you have to do is to install\n`@whatwg-node/router-plugin-ajv` package and add it to the plugins.\n\n```ts\nimport { createRouter } from '@whatwg-node/router'\nimport { useAjv } from '@whatwg-node/router-plugin-ajv'\n\nconst router = createRouter({\n  plugins: [useAjv()]\n})\n```\n\n### OpenAPI Generation\n\nYou can generate OpenAPI specification from the defined routes by using OpenAPI plugin. This plugin\nalso provides you a [Swagger UI](https://swagger.io/tools/swagger-ui/) to test the API.\n\n```ts\nimport { createRouter, useOpenAPI } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [\n    useOpenAPI({\n      baseOas: {\n        openapi: '3.0.1',\n        info: {\n          title: 'Todo List Example',\n          description: 'A simple todo list example with @whatwg-node/router',\n          version: '1.0.0'\n        },\n        components: {}\n      }\n    })\n  ]\n})\n```\n\n### Using a programmatic JSON Schema builder (`zod`-like API)\n\n```ts\nimport { Static, Type } from '@sinclair/typebox'\n\nconst Todo = Type.Object({\n  id: Type.String(),\n  title: Type.String(),\n  completed: Type.Boolean()\n})\n\ntype Todo = Static<typeof Todo>\n\nconst router = createRouter().route({\n  path: '/todos',\n  schemas: {\n    request: {\n      body: Todo\n    },\n    response: {\n      200: Type.Array(Todo)\n    }\n  }\n})\n```\n\n### Type-safety on the client side\n\nWith this library, you can also type the request and response on the client side. But you have two\noptions;\n\n1. You can infer the types from the router itself by using `createRouterSDK` from this library.\n2. You can use OpenAPI client package that infers the types from the given OpenAPI document.\n\n#### Using `createRouterSDK`\n\n```ts file=examples/client.ts\nimport { createRouterSDK } from '@whatwg-node/router'\nimport type { router } from '../router'\n\nconst sdk = createRouterSDK<typeof router>({\n  endpoint: 'http://localhost:3000'\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"75f91ef17748435842205517d0c8b9c98652409e","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.1","dependencies":{"tslib":"^2.3.1","openapi-types":"12.1.0","json-schema-to-ts":"2.6.2","@whatwg-node/fetch":"0.8.2-alpha-20230301144304-75f91ef","@whatwg-node/server":"0.7.2-alpha-20230301144304-75f91ef","@whatwg-node/typed-fetch":"0.0.1-alpha-20230301144304-75f91ef"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.4.0-alpha-20230301144304-75f91ef_1677681808712_0.057848394378305246","host":"s3://npm-registry-packages"}},"0.4.0-alpha-20230301144841-a76d283":{"name":"@whatwg-node/router","version":"0.4.0-alpha-20230301144841-a76d283","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.4.0-alpha-20230301144841-a76d283","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"767391fe25637f2157973a54332de286b57452a9","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.4.0-alpha-20230301144841-a76d283.tgz","fileCount":10,"integrity":"sha512-j1kjglb8QraMCORVj080h/NP5ddJSt+Uorp7xb3J7twY20Upx0Zo1gcT1aIl9Y453g5M1U0eB6GRhKmBzdRAYA==","signatures":[{"sig":"MEYCIQCLgitG8+2o3EiKhND7rPs82THCagpZHSNNTSODojMEGAIhALn7BQWbHb/d3S1ffuZh2idjEC+o0nFR6xlbP1EEfHv5","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":58920,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj/2XiACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrPOw/+IWZzYKfTXQcYJD8REw2vJhQlohFGJxM09an0jnSQ1coJ/NcX\r\nyC2XyrJ9iSUlvSt+p4t8uH+1g1sZeFox69UxPd2d5T+d7u1VtM++3ROPtXKr\r\n0Imuf7WPoz3nntpYHVpP6nBwjJEP+fjbaGfe6JlEis3mzc8t+WLCPK/eGQEN\r\nYQ6hlWKcAsvEMfP85THJEj5/VgORpKZkV6q86RhB5qEJG2WVluMuztbxWbGN\r\noE3Udim0iLJLXM0G8OWDpeXqdW77TERz58+Ym8/YyE2bIixSm2XOs3B7C/cb\r\ncIhAg/BXXTxJXBmQ9WQIirpwBuQ8Y+JcQKlMwf//eh6x6wC4TEnZYuIkYlfi\r\n1+ofIfmodhLAftlEh6vw4FK4lRMgGXkHiftBz8oeSLTUCE5vs2hC6hAq0OfZ\r\nhggGl7tPUGYcCQ5MCYiRCb4rtubxL7h5Od0sCkBQ9WZGgV8PcccHiL3qsGtC\r\nXwPhbDCNAeg7BqRgUpKNogZCaD8xIjFTj+o494Q9FpkJniXN1hGLJrlbY2XE\r\nsjadJW8Woo3uq94RjYuAsSCQnwsIEpsuRyIV3eYFPWpqd/RBqDbG4NOnaluG\r\n0KmGF1aiLHYyfkFS+25706pgL+bwcaMAJbRfukxhpIgKhDmBCcULqiEOzEFM\r\nkk4l+C2b8qb8S1VD+LowqxQm7Ed3X8JFXDs=\r\n=Cy+s\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic fully type-safe JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\nIt also allows you to create end-to-end type-safe and validated HTTP APIs with JSON Schema without\n**ANY CODE GENERATION**.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Why should I use this package instead of tRPC?\n\ntRPC doesn't need a code generation like this library, but this library allows you export an OpenAPI\ndocument based on the JSON Schema definitions if you don't want to share TypeScript definitions\nbetween the client and the server. And this library uses [JSON Schema](https://json-schema.org/)\ninstead of a programmatic schema solution like zod which is more portable and has bigger ecosystem.\nSo even if you don't want to write JSON Schemas manually, you can use `@sinclair/typebox` to\ngenerate them by using an API like `zod` has.\n\n## Usage\n\nIt uses `.route()` method to add routes to the router with the following parameters;\n\n- `method`: The HTTP method of the request. This is optional and it handles all methods if it's not\n  given.\n- `path`: The URL pattern that the request should match. The url pattern is a string that follows\n  the [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can\n  learn more about URL patterns\n  [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n- `schemas`: An object that contains the schemas for the request and response. This brings a\n  type-safety and validation to your requests and responses. You can learn more about schemas\n  [here](#end-to-end-type-safety-and-validation-with-json-schema).\n- `handler`: The function that will be called when the request matches the given method and path.\n  This function can be either synchronous or asynchronous. If it's asynchronous, it should return a\n  `Promise` that resolves to a `Response` object.\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nYou can learn more about the original `Request` object\n[here](https://developer.mozilla.org/en-US/docs/Web/API/Request).\n\n### Basic Routing\n\n```ts\n// Then use it in any environment\nimport { createServer } from 'http'\nimport { createRouter, Response, Router } from '@whatwg-node/router'\n\nconst router = createRouter()\n  // GET collection index\n  .route({\n    method: 'GET',\n    path: '/todos',\n    handler: () => new Response('Todos Index!')\n  })\n  // GET item\n  .route({\n    method: 'GET',\n    path: '/todos/:id',\n    handler: ({ params }) => new Response(`Todo #${params.id}`)\n  })\n  // POST to the collection (we'll use async here)\n  .route({\n    method: 'POST',\n    path: '/todos',\n    handler: async request => {\n      const content = await request.json()\n      return new Response('Creating Todo: ' + JSON.stringify(content))\n    }\n  })\n\n  // Redirect to a URL\n  .route({\n    method: 'GET',\n    path: '/google',\n    handler: () => Response.redirect('http://www.google.com')\n  })\n\n  // 404 for everything else\n  .route({\n    path: '*',\n    handler: () => new Response('Not Found.', { status: 404 })\n  })\n\nconst httpServer = createServer(router)\nhttpServer.listen(4000)\n```\n\n## Example\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nconst router = createRouter()\n  .route({\n    method: 'GET',\n    path: '/users',\n    handler: () => Response.json(users)\n  })\n  // Parameters are given in the `request.params` object\n  .route({\n    method: 'GET',\n    path: '/users/:id',\n    handler: request => {\n      const user = users.find(user => user.id === request.params.id)\n\n      if (!user) {\n        return new Response(null, {\n          status: 404\n        })\n      }\n\n      return Response.json(user)\n    }\n  })\n  .route({\n    method: 'DELETE',\n    path: '/users/:id',\n    handler: request => {\n      const user = users.find(user => user.id === request.params.id)\n\n      if (!user) {\n        return new Response(null, {\n          status: 404\n        })\n      }\n\n      users.splice(users.indexOf(user), 1)\n\n      return new Response(null, {\n        status: 204\n      })\n    }\n  })\n  // Handle JSON bodies\n  .route({\n    method: 'PUT',\n    path: '/users',\n    handler: async request => {\n      const body = await request.json()\n\n      const user = {\n        id: String(users.length + 1),\n        name: body.name\n      }\n\n      users.push(user)\n\n      return Response.json(user)\n    }\n  })\n  // Handle both parameters and JSON body\n  .route({\n    method: 'PATCH',\n    path: '/users/:id',\n    handler: async request => {\n      const user = users.find(user => user.id === request.params.id)\n\n      if (!user) {\n        return new Response(null, {\n          status: 404\n        })\n      }\n\n      const body = await request.json()\n\n      user.name = body.name\n\n      return Response.json(user)\n    }\n  })\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nconst router = createRouter()\n  .route({\n    path: '*',\n    handler: request => {\n      if (!request.headers.get('Authorization')) {\n        return new Response(null, {\n          status: 401\n        })\n      }\n    }\n  })\n  .route({\n    path: '/users',\n    method: 'GET',\n    handler: request => {\n    // It doesn't reach here if the request doesn't have an `Authorization` header.\n  });\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nconst router = createRouter().route({\n  path: '/users',\n  method: 'GET',\n  handler: [\n    withAuth,\n    request => {\n      // It doesn't reach here if the request doesn't have an `Authorization` header.\n    }\n  ]\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors. Or you can use the plugins to handle errors like below.\n\n```ts\nconst router = createRouter().route({\n  path: '/users',\n  method: 'GET',\n  handler: request => {\n    try {\n      // Do something\n    } catch (error) {\n      return new Response('I handled the error gracefully', {\n        status: 500\n      })\n    }\n  }\n})\n```\n\n## Plugins to handle CORS, cookies and more\n\nThis library also provides a plugin system that allows you hook into the request/response lifecycle.\n\n- `onRequest` - Called before the request is handled by the router\n- - It has `endResponse` method that accepts a `Response` object to short-circuit the request\n- `onResponse` - Called after the request is handled by the router\n- - It allows you to modify the response before it is sent to the client\n\n### Cookie Management\n\nYou can use `useCookies` to parse cookies from the request header and set cookies in the response by\nusing Web Standard [CookieStore](https://developer.mozilla.org/en-US/docs/Web/API/CookieStore).\n\n```ts\nimport { createRouter, Response, useCookies } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [useCookies()]\n})\n.route({\n  path: '/users',\n  method: 'GET',\n  handler: request => {\n    const sessionId = await request.cookieStore.get('session_id')\n    if (!sessionId) {\n      return Response.json({ error: 'Unauthorized' }, { status: 401 })\n    }\n    const user = await getUserBySessionId(sessionId)\n    return Response.json(user)\n  }\n})\n.route({\n  path: '/login',\n  method: 'POST',\n  handler: async request => {\n    const { username, password } = await request.json()\n    const sessionId = await createSessionForUser({ username, password })\n    await request.cookieStore.set('session_id', sessionId)\n    return Response.json({ message: 'ok' })\n  }\n})\n```\n\n### CORS Management\n\nYou can also setup a CORS middleware to handle preflight CORS requests.\n\n```ts\nimport { createRouter, useCORS } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [\n    useCORS({\n      origin: '*',\n      methods: ['GET', 'POST', 'PUT', 'DELETE'],\n      headers: ['Content-Type', 'Authorization']\n    })\n  ]\n})\n```\n\n### Custom plugins\n\nYou can also create your own plugins to handle errors, logging, etc.\n\n```ts\nimport { createRouter } from '@whatwg-node/router'\n\nconst useRequestId = (): RoutePlugin => {\n  return {\n    onRequest({ request, fetchAPI }) {\n      let requestId = request.headers.get('X-Request-ID')\n      if (!requestId) {\n        requestId = fetchAPI.crypto.randomUUID()\n        request.headers.set('X-Request-ID', requestId)\n      }\n    },\n    onResponse({ response, fetchAPI }) {\n      response.headers.set('X-Request-ID', request.headers.get('X-Request-ID'))\n    }\n  }\n}\n\nconst router = createRouter({\n  plugins: [useRequestId()]\n})\n```\n\n## End-to-End Type Safety and Validation with JSON Schema\n\nEven if the library provides you some type safety with TypeScript's type inference, you can still\nuse JSON Schemas to have a better type safety on both request and response.\n\nTo define type-safe routes, we use `schemas` parameters\n\n### Typing the request\n\nYou can type individual parts of the `Request` object including JSON body, headers, query\nparameters, and URL parameters.\n\n#### JSON Body\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().route(\n  {\n    method: 'post',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      request: {\n        json: {\n          type: 'object',\n          properties: {\n            title: { type: 'string' },\n            completed: { type: 'boolean' }\n          },\n          additionalProperties: false,\n          required: ['title']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const { title, completed } = await request.json()\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n#### Headers\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().route(\n  {\n    method: 'post',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      request: {\n        headers: {\n          type: 'object',\n          properties: {\n            'x-api-key': { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['x-api-key']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const apiKey = request.headers.get('x-api-key')\n    // Would fail on TypeScript compilation\n    const wrongHeaderName = request.headers.get('x-api-key-wrong')\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n#### Path Parameters\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().route(\n  {\n    method: 'get',\n    path: '/todos/:id',\n    // Define the request body schema\n    schemas: {\n      request: {\n        params: {\n          type: 'object',\n          properties: {\n            id: { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['id']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const { id } = request.params\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n#### Query Parameters\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute({\n  method: 'get',\n  path: '/todos',\n  // Define the request body schema\n  schemas: {\n    request: {\n      query: {\n        type: 'object',\n        properties: {\n          limit: { type: 'number' },\n          offset: { type: 'number' }\n        },\n        additionalProperties: false,\n        required: ['limit']\n      },\n    }\n  }\n}, async request => {\n  // This part is fully typed\n  const { limit, offset } = request.query\n  // You can also use `URLSearchParams` API\n  const limit = request.parsedURL.searchParams.get('limit')\n  // ...\n  return Response.json({ message: 'ok' })\n})\n```\n\n### Typing the response\n\nYou can also type the response body by the status code. We strongly recommend to explicitly define\nthe status codes.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'get',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      request: {\n        headers: {\n          type: 'object',\n          properties: {\n            'x-api-key': { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['x-api-key']\n        }\n      },\n      response: {\n        200: {\n          type: 'array',\n          items: {\n            type: 'object',\n            properties: {\n              id: { type: 'string' },\n              title: { type: 'string' },\n              completed: { type: 'boolean' }\n            },\n            additionalProperties: false,\n            required: ['id', 'title', 'completed']\n          }\n        },\n        401: {\n          type: 'object',\n          properties: {\n            message: { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['message']\n        }\n      }\n    }\n  },\n  async request => {\n    const apiKey = request.headers.get('x-api-key')\n    if (!apiKey) {\n      return Response.json(\n        { message: 'API key is required' },\n        {\n          status: 401\n        }\n      )\n    }\n    const todos = await getTodos({\n      apiKey\n    })\n    // This part is fully typed\n    return Response.json(todos, {\n      status: 200\n    })\n  }\n)\n```\n\n### Runtime validation with Ajv\n\nThe library itself doesn't include a runtime validation by default. But you can use that plugin to\nhave a runtime validation with the provided JSON Schemas above. This plugin uses\n[Ajv](https://ajv.js.org/) under the hood. All you have to do is to install\n`@whatwg-node/router-plugin-ajv` package and add it to the plugins.\n\n```ts\nimport { createRouter } from '@whatwg-node/router'\nimport { useAjv } from '@whatwg-node/router-plugin-ajv'\n\nconst router = createRouter({\n  plugins: [useAjv()]\n})\n```\n\n### OpenAPI Generation\n\nYou can generate OpenAPI specification from the defined routes by using OpenAPI plugin. This plugin\nalso provides you a [Swagger UI](https://swagger.io/tools/swagger-ui/) to test the API.\n\n```ts\nimport { createRouter, useOpenAPI } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [\n    useOpenAPI({\n      // You can define the header of the OpenAPI specification here\n      baseOas: {\n        openapi: '3.0.1',\n        info: {\n          title: 'Todo List Example',\n          description: 'A simple todo list example with @whatwg-node/router',\n          version: '1.0.0'\n        },\n        components: {}\n      },\n      // You can access the Swagger UI at `/docs`\n      swaggerUIPath: '/docs',\n      // You can download the OpenAPI specification as a JSON file\n      oasPath: '/openapi.json'\n    })\n  ]\n})\n```\n\n### Using a programmatic JSON Schema builder (`zod`-like API)\n\n```ts\nimport { Static, Type } from '@sinclair/typebox'\n\nconst Todo = Type.Object({\n  id: Type.String(),\n  title: Type.String(),\n  completed: Type.Boolean()\n})\n\ntype Todo = Static<typeof Todo>\n\nconst router = createRouter().route({\n  path: '/todos',\n  schemas: {\n    request: {\n      body: Todo\n    },\n    response: {\n      200: Type.Array(Todo)\n    }\n  }\n})\n```\n\n### Type-safety on the client side\n\nWith this library, you can also type the request and response on the client side. But you have two\noptions;\n\n1. You can infer the types from the router itself by using `createRouterSDK` from this library.\n2. You can use OpenAPI client package that infers the types from the given OpenAPI document.\n\n#### Using `createRouterSDK`\n\n```ts file=examples/client.ts\nimport { createRouterSDK } from '@whatwg-node/router'\n// Notice `type` in the import to avoid to import it on runtime\nimport type { router } from '../router'\n\nconst sdk = createRouterSDK<typeof router>({\n  endpoint: 'http://localhost:3000'\n})\n\n// Everything below is fully typed\nconst response = await sdk['/todo'].put({\n  json: {\n    title: 'Buy milk',\n    completed: false\n  }\n})\nconst responseJson = await response.json()\nconsole.table(responseJson)\n```\n\n#### Using OpenAPI Client\n\nYou need to save the OpenAPI document to a code file like below;\n\n```ts\nexport default { openapi: '3.0.1' /* ... */ }\n```\n\nThen you need to import the OpenAPI document to the client code;\n\n```ts file=examples/client.ts\nimport { createOASClient, Mutable } from '@whatwg-node/oas-client'\n// Notice `type` in the import to avoid to import it on runtime\nimport type oas from './saved_openapi'\n\nconst client = createOASClient<Mutable<typeof oas>>({\n  endpoint: 'http://localhost:3000'\n})\n\n// Everything below is fully typed\nconst response = await client['/todo'].put({\n  json: {\n    title: 'Buy milk',\n    completed: false\n  }\n})\nconst responseJson = await response.json()\nconsole.table(responseJson)\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"a76d2837eefc0694a33ff4a5285bb72a069bb18e","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.1","dependencies":{"tslib":"^2.3.1","openapi-types":"12.1.0","json-schema-to-ts":"2.6.2","@whatwg-node/fetch":"0.8.2-alpha-20230301144841-a76d283","@whatwg-node/server":"0.7.2-alpha-20230301144841-a76d283","@whatwg-node/typed-fetch":"0.0.1-alpha-20230301144841-a76d283"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.4.0-alpha-20230301144841-a76d283_1677682146126_0.6003681453934393","host":"s3://npm-registry-packages"}},"0.4.0-rc-20230301165834-79d3ff1":{"name":"@whatwg-node/router","version":"0.4.0-rc-20230301165834-79d3ff1","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.4.0-rc-20230301165834-79d3ff1","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"d8daced789cd2f3bd9967481aa61df379c157ad5","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.4.0-rc-20230301165834-79d3ff1.tgz","fileCount":7,"integrity":"sha512-oXott2VpxpB0IudtRy/3pFBHjpdzLL0hU9ddC/BAOL07huueGC6qoql2mIYYo/4O8Gu2molJkKuk5xSZGc94DA==","signatures":[{"sig":"MEYCIQCFN9z0BphqbjurT+kf/Y1st5T9AcwOtYp11/P/6hoGZwIhAPf5YTGT/lyg1y7nuljq6yuzwkQfA/qjZDUHCs0ygTpp","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19305,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj/4RIACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmr3ZRAAmsbdEYQmEp7XhvHFgGUv2fYxJDoYM1U1o+cQPHLRQDEd+hHN\r\n48D3v+B7xaVbKvXa6E52L7suYgPec5DHouNEsDqnw2DxUjBwyUEly+K6CsP+\r\n/A47t3I6UBVphz3/6FpRB608tZnUXP5J0aBbhwBXbPnPdMUt4bdBYAjyXc0+\r\nhfjJPdauK9fjF0IxPKhEs27tJQCziXh6WNNEJ9TVot1cebkZYL7XYLPwB+qb\r\n14BbT1G3vGNsn70fXH9UnjtQ9xf9UfzHRGNImv1hjYwBtd9hyEA5IG9RhNxs\r\nh5ltIfSwufejuUjX0TIlGdZmTHJQcEkiw//TaO9xz3ry2eFLrKHD3L1oMLbV\r\n0ys3xGAB0LI0MG97oRY/dt1Ky3qst6t9k7UNqlvwgCD3i9F+lS+cYUJd5bD4\r\n+ANDgvsFMZYn73AxYaMF3x4dT33O+cKAzoV+LGxPGTTTONAsduAJ85RcxF6F\r\nthPab5FChvno6y4QGozd54DAOdCsrLY+OsIz6BMNbO6FkYMDmZcac6pQ+UUB\r\nmNWBNTLUj3r1mthXiSSzq+w1kPmR9eICF0JWmeciBVWJt6wdrJpWDzjuFCaI\r\nOM/Bx1Drtg9ojL+IDfmGdnQCKhjBq/PwiJnau1lTCxeiGkLfIUhlXm3CM7tC\r\nla86IC4P5fIGeuMRVFhLPFoa41Fx2+A4YLA=\r\n=WKe6\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"79d3ff1ede4292df47b2eddef9d3dcd793fd6160","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.1","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"^0.8.0","@whatwg-node/server":"^0.7.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.4.0-rc-20230301165834-79d3ff1_1677689927821_0.01673689123194766","host":"s3://npm-registry-packages"}},"0.4.0-alpha-20230301191323-b3ac93c":{"name":"@whatwg-node/router","version":"0.4.0-alpha-20230301191323-b3ac93c","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.4.0-alpha-20230301191323-b3ac93c","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"763abd710e2cacc31501ec4091a850c20ff82f89","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.4.0-alpha-20230301191323-b3ac93c.tgz","fileCount":10,"integrity":"sha512-GP/gJ64JM4m90W5RbC9dArag3AZrnQjzCPqrs3eiVnYMo8lhGceXKkWRCzQ9Mn2BvhBmQq+t8couxq+ST0ZcEg==","signatures":[{"sig":"MEUCIDTUuDDEZRx+I8stok90y4x1/qrl4AvBfNdGKEAoepKjAiEA7kuM2JYI7CJM6+8F3Ec1ZS9vF4ERoo526uZcGIh3Oz4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":59688,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj/6PsACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpVDw//dSaF79QI99hU9oW63QX0MrSLlVrjlvHwt1Emc4+390I/yI14\r\nUgJm4fomwKjdeT0Vm/GVEbYUCI9Aii1q3Ebv/vbfKBehWpDqSKDWVv3/yGqi\r\n2bYx09HvyYwPa/+PBXOij48X4j4pJ50AuiFbDX2MXEyWhGqYh3zbcsWDeYWS\r\nbJwWx2cGzdWQre/kDoL7ON9CVtqpAIoIRJBQ83/TZfRnQXi50XicHEVoIAl1\r\nK4Pxzaija1Uut6xgKgGygdRBhSUKSqLan0xMjVWNKj46kLRTbqQrVY57HqfG\r\nqoWfnuteDfZbQagB7vqQAkS9QNrIdY9RCvP9LYyBms84Wd2X2rxnRAun97dy\r\nud4p7zbRCHWZ64cd47tNR/UhiE9d/TMytLtX3qpyYNwlAVEgtCkp9xKmDekx\r\ndbcrMWWk/Tg31P4fODldWdEBoddbazda2HiSq/a5P1+cPMAaTuOY0NnXe4IA\r\nlLMl9OLokFMeAnspNPuZFREKeiyG1vGf7sKoW1tHK4RrhPbOtsWZ0pwbIV+c\r\nzYV1IZbsYSDP/7hJhbZ+PZLKXsvTt56eMM6z6X/2Uof1iw6IcRT/+51Jjm9y\r\na/WW3HxktkmQWjI/VEHdXiEMx3czZOB5/Rc+LK+qOL/sE5YV4JTjJnGuK557\r\nZCh+gMj/hd5S3LYc8T0PnoHeIDAELZfsXm0=\r\n=5nHC\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic fully type-safe JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\nIt also allows you to create end-to-end type-safe and validated HTTP APIs with JSON Schema without\n**ANY CODE GENERATION**.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Why should I use this package instead of tRPC?\n\ntRPC doesn't need a code generation like this library, but this library allows you export an OpenAPI\ndocument based on the JSON Schema definitions if you don't want to share TypeScript definitions\nbetween the client and the server. And this library uses [JSON Schema](https://json-schema.org/)\ninstead of a programmatic schema solution like zod which is more portable and has bigger ecosystem.\nSo even if you don't want to write JSON Schemas manually, you can use `@sinclair/typebox` to\ngenerate them by using an API like `zod` has.\n\n## Usage\n\nIt uses `.route()` method to add routes to the router with the following parameters;\n\n- `method`: The HTTP method of the request. This is optional and it handles all methods if it's not\n  given.\n- `path`: The URL pattern that the request should match. The url pattern is a string that follows\n  the [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can\n  learn more about URL patterns\n  [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n- `schemas`: An object that contains the schemas for the request and response. This brings a\n  type-safety and validation to your requests and responses. You can learn more about schemas\n  [here](#end-to-end-type-safety-and-validation-with-json-schema).\n- `handler`: The function that will be called when the request matches the given method and path.\n  This function can be either synchronous or asynchronous. If it's asynchronous, it should return a\n  `Promise` that resolves to a `Response` object.\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nYou can learn more about the original `Request` object\n[here](https://developer.mozilla.org/en-US/docs/Web/API/Request).\n\n### Basic Routing\n\n```ts\n// Then use it in any environment\nimport { createServer } from 'http'\nimport { createRouter, Response, Router } from '@whatwg-node/router'\n\nconst router = createRouter()\n  // GET collection index\n  .route({\n    method: 'GET',\n    path: '/todos',\n    handler: () => new Response('Todos Index!')\n  })\n  // GET item\n  .route({\n    method: 'GET',\n    path: '/todos/:id',\n    handler: ({ params }) => new Response(`Todo #${params.id}`)\n  })\n  // POST to the collection (we'll use async here)\n  .route({\n    method: 'POST',\n    path: '/todos',\n    handler: async request => {\n      const content = await request.json()\n      return new Response('Creating Todo: ' + JSON.stringify(content))\n    }\n  })\n\n  // Redirect to a URL\n  .route({\n    method: 'GET',\n    path: '/google',\n    handler: () => Response.redirect('http://www.google.com')\n  })\n\n  // 404 for everything else\n  .route({\n    path: '*',\n    handler: () => new Response('Not Found.', { status: 404 })\n  })\n\nconst httpServer = createServer(router)\nhttpServer.listen(4000)\n```\n\n## Example\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nconst router = createRouter()\n  .route({\n    method: 'GET',\n    path: '/users',\n    handler: () => Response.json(users)\n  })\n  // Parameters are given in the `request.params` object\n  .route({\n    method: 'GET',\n    path: '/users/:id',\n    handler: request => {\n      const user = users.find(user => user.id === request.params.id)\n\n      if (!user) {\n        return new Response(null, {\n          status: 404\n        })\n      }\n\n      return Response.json(user)\n    }\n  })\n  .route({\n    method: 'DELETE',\n    path: '/users/:id',\n    handler: request => {\n      const user = users.find(user => user.id === request.params.id)\n\n      if (!user) {\n        return new Response(null, {\n          status: 404\n        })\n      }\n\n      users.splice(users.indexOf(user), 1)\n\n      return new Response(null, {\n        status: 204\n      })\n    }\n  })\n  // Handle JSON bodies\n  .route({\n    method: 'PUT',\n    path: '/users',\n    handler: async request => {\n      const body = await request.json()\n\n      const user = {\n        id: String(users.length + 1),\n        name: body.name\n      }\n\n      users.push(user)\n\n      return Response.json(user)\n    }\n  })\n  // Handle both parameters and JSON body\n  .route({\n    method: 'PATCH',\n    path: '/users/:id',\n    handler: async request => {\n      const user = users.find(user => user.id === request.params.id)\n\n      if (!user) {\n        return new Response(null, {\n          status: 404\n        })\n      }\n\n      const body = await request.json()\n\n      user.name = body.name\n\n      return Response.json(user)\n    }\n  })\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nconst router = createRouter()\n  .route({\n    path: '*',\n    handler: request => {\n      if (!request.headers.get('Authorization')) {\n        return new Response(null, {\n          status: 401\n        })\n      }\n    }\n  })\n  .route({\n    path: '/users',\n    method: 'GET',\n    handler: request => {\n    // It doesn't reach here if the request doesn't have an `Authorization` header.\n  });\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nconst router = createRouter().route({\n  path: '/users',\n  method: 'GET',\n  handler: [\n    withAuth,\n    request => {\n      // It doesn't reach here if the request doesn't have an `Authorization` header.\n    }\n  ]\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors. Or you can use the plugins to handle errors like below.\n\n```ts\nimport { HTTPError, useErrorHandling } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [useErrorHandling()]\n}).route({\n  path: '/users',\n  method: 'GET',\n  handler: request => {\n    if (!request.headers.get('Authorization')) {\n      // You can use `HTTPError` to return a custom error response.\n      // It accepts a status code, a message, headers and a body.\n      // If you pass a json object as the body, the response will be a json response.\n      throw new HTTPError(\n        401,\n        'Unauthorized',\n        {\n          'WWW-Authenticate': 'Basic'\n        },\n        {\n          message: 'You need to be authenticated to access this resource.'\n        }\n      )\n    }\n  }\n})\n```\n\n## Plugins to handle CORS, cookies and more\n\nThis library also provides a plugin system that allows you hook into the request/response lifecycle.\n\n- `onRequest` - Called before the request is handled by the router\n- - It has `endResponse` method that accepts a `Response` object to short-circuit the request\n- `onResponse` - Called after the request is handled by the router\n- - It allows you to modify the response before it is sent to the client\n\n### Cookie Management\n\nYou can use `useCookies` to parse cookies from the request header and set cookies in the response by\nusing Web Standard [CookieStore](https://developer.mozilla.org/en-US/docs/Web/API/CookieStore).\n\n```ts\nimport { createRouter, Response, useCookies } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [useCookies()]\n})\n.route({\n  path: '/users',\n  method: 'GET',\n  handler: request => {\n    const sessionId = await request.cookieStore.get('session_id')\n    if (!sessionId) {\n      return Response.json({ error: 'Unauthorized' }, { status: 401 })\n    }\n    const user = await getUserBySessionId(sessionId)\n    return Response.json(user)\n  }\n})\n.route({\n  path: '/login',\n  method: 'POST',\n  handler: async request => {\n    const { username, password } = await request.json()\n    const sessionId = await createSessionForUser({ username, password })\n    await request.cookieStore.set('session_id', sessionId)\n    return Response.json({ message: 'ok' })\n  }\n})\n```\n\n### CORS Management\n\nYou can also setup a CORS middleware to handle preflight CORS requests.\n\n```ts\nimport { createRouter, useCORS } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [\n    useCORS({\n      origin: '*',\n      methods: ['GET', 'POST', 'PUT', 'DELETE'],\n      headers: ['Content-Type', 'Authorization']\n    })\n  ]\n})\n```\n\n### Custom plugins\n\nYou can also create your own plugins to handle errors, logging, etc.\n\n```ts\nimport { createRouter } from '@whatwg-node/router'\n\nconst useRequestId = (): RoutePlugin => {\n  return {\n    onRequest({ request, fetchAPI }) {\n      let requestId = request.headers.get('X-Request-ID')\n      if (!requestId) {\n        requestId = fetchAPI.crypto.randomUUID()\n        request.headers.set('X-Request-ID', requestId)\n      }\n    },\n    onResponse({ response, fetchAPI }) {\n      response.headers.set('X-Request-ID', request.headers.get('X-Request-ID'))\n    }\n  }\n}\n\nconst router = createRouter({\n  plugins: [useRequestId()]\n})\n```\n\n## End-to-End Type Safety and Validation with JSON Schema\n\nEven if the library provides you some type safety with TypeScript's type inference, you can still\nuse JSON Schemas to have a better type safety on both request and response.\n\nTo define type-safe routes, we use `schemas` parameters\n\n### Typing the request\n\nYou can type individual parts of the `Request` object including JSON body, headers, query\nparameters, and URL parameters.\n\n#### JSON Body\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().route(\n  {\n    method: 'post',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      request: {\n        json: {\n          type: 'object',\n          properties: {\n            title: { type: 'string' },\n            completed: { type: 'boolean' }\n          },\n          additionalProperties: false,\n          required: ['title']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const { title, completed } = await request.json()\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n#### Headers\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().route(\n  {\n    method: 'post',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      request: {\n        headers: {\n          type: 'object',\n          properties: {\n            'x-api-key': { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['x-api-key']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const apiKey = request.headers.get('x-api-key')\n    // Would fail on TypeScript compilation\n    const wrongHeaderName = request.headers.get('x-api-key-wrong')\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n#### Path Parameters\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().route(\n  {\n    method: 'get',\n    path: '/todos/:id',\n    // Define the request body schema\n    schemas: {\n      request: {\n        params: {\n          type: 'object',\n          properties: {\n            id: { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['id']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const { id } = request.params\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n#### Query Parameters\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute({\n  method: 'get',\n  path: '/todos',\n  // Define the request body schema\n  schemas: {\n    request: {\n      query: {\n        type: 'object',\n        properties: {\n          limit: { type: 'number' },\n          offset: { type: 'number' }\n        },\n        additionalProperties: false,\n        required: ['limit']\n      },\n    }\n  }\n}, async request => {\n  // This part is fully typed\n  const { limit, offset } = request.query\n  // You can also use `URLSearchParams` API\n  const limit = request.parsedURL.searchParams.get('limit')\n  // ...\n  return Response.json({ message: 'ok' })\n})\n```\n\n### Typing the response\n\nYou can also type the response body by the status code. We strongly recommend to explicitly define\nthe status codes.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'get',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      request: {\n        headers: {\n          type: 'object',\n          properties: {\n            'x-api-key': { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['x-api-key']\n        }\n      },\n      response: {\n        200: {\n          type: 'array',\n          items: {\n            type: 'object',\n            properties: {\n              id: { type: 'string' },\n              title: { type: 'string' },\n              completed: { type: 'boolean' }\n            },\n            additionalProperties: false,\n            required: ['id', 'title', 'completed']\n          }\n        },\n        401: {\n          type: 'object',\n          properties: {\n            message: { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['message']\n        }\n      }\n    }\n  },\n  async request => {\n    const apiKey = request.headers.get('x-api-key')\n    if (!apiKey) {\n      return Response.json(\n        { message: 'API key is required' },\n        {\n          status: 401\n        }\n      )\n    }\n    const todos = await getTodos({\n      apiKey\n    })\n    // This part is fully typed\n    return Response.json(todos, {\n      status: 200\n    })\n  }\n)\n```\n\n### Runtime validation with Ajv\n\nThe library itself doesn't include a runtime validation by default. But you can use that plugin to\nhave a runtime validation with the provided JSON Schemas above. This plugin uses\n[Ajv](https://ajv.js.org/) under the hood. All you have to do is to install\n`@whatwg-node/router-plugin-ajv` package and add it to the plugins.\n\n```ts\nimport { createRouter } from '@whatwg-node/router'\nimport { useAjv } from '@whatwg-node/router-plugin-ajv'\n\nconst router = createRouter({\n  plugins: [useAjv()]\n})\n```\n\n### OpenAPI Generation\n\nYou can generate OpenAPI specification from the defined routes by using OpenAPI plugin. This plugin\nalso provides you a [Swagger UI](https://swagger.io/tools/swagger-ui/) to test the API.\n\n```ts\nimport { createRouter, useOpenAPI } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [\n    useOpenAPI({\n      // You can define the header of the OpenAPI specification here\n      baseOas: {\n        openapi: '3.0.1',\n        info: {\n          title: 'Todo List Example',\n          description: 'A simple todo list example with @whatwg-node/router',\n          version: '1.0.0'\n        },\n        components: {}\n      },\n      // You can access the Swagger UI at `/docs`\n      swaggerUIPath: '/docs',\n      // You can download the OpenAPI specification as a JSON file\n      oasPath: '/openapi.json'\n    })\n  ]\n})\n```\n\n### Using a programmatic JSON Schema builder (`zod`-like API)\n\n```ts\nimport { Static, Type } from '@sinclair/typebox'\n\nconst Todo = Type.Object({\n  id: Type.String(),\n  title: Type.String(),\n  completed: Type.Boolean()\n})\n\ntype Todo = Static<typeof Todo>\n\nconst router = createRouter().route({\n  path: '/todos',\n  schemas: {\n    request: {\n      body: Todo\n    },\n    response: {\n      200: Type.Array(Todo)\n    }\n  }\n})\n```\n\n### Type-safety on the client side\n\nWith this library, you can also type the request and response on the client side. But you have two\noptions;\n\n1. You can infer the types from the router itself by using `createRouterSDK` from this library.\n2. You can use OpenAPI client package that infers the types from the given OpenAPI document.\n\n#### Using `createRouterSDK`\n\n```ts file=examples/client.ts\nimport { createRouterSDK } from '@whatwg-node/router'\n// Notice `type` in the import to avoid to import it on runtime\nimport type { router } from '../router'\n\nconst sdk = createRouterSDK<typeof router>({\n  endpoint: 'http://localhost:3000'\n})\n\n// Everything below is fully typed\nconst response = await sdk['/todo'].put({\n  json: {\n    title: 'Buy milk',\n    completed: false\n  }\n})\nconst responseJson = await response.json()\nconsole.table(responseJson)\n```\n\n#### Using OpenAPI Client\n\nYou need to save the OpenAPI document to a code file like below;\n\n```ts\nexport default { openapi: '3.0.1' /* ... */ }\n```\n\nThen you need to import the OpenAPI document to the client code;\n\n```ts file=examples/client.ts\nimport { createOASClient, Mutable } from '@whatwg-node/oas-client'\n// Notice `type` in the import to avoid to import it on runtime\nimport type oas from './saved_openapi'\n\nconst client = createOASClient<Mutable<typeof oas>>({\n  endpoint: 'http://localhost:3000'\n})\n\n// Everything below is fully typed\nconst response = await client['/todo'].put({\n  json: {\n    title: 'Buy milk',\n    completed: false\n  }\n})\nconst responseJson = await response.json()\nconsole.table(responseJson)\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"b3ac93c5777d9d061c3f8e5d1876e2b090c81fcd","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.1","dependencies":{"tslib":"^2.3.1","openapi-types":"12.1.0","json-schema-to-ts":"2.6.2","@whatwg-node/fetch":"0.8.2-alpha-20230301191323-b3ac93c","@whatwg-node/server":"0.7.2-alpha-20230301191323-b3ac93c","@whatwg-node/typed-fetch":"0.0.1-alpha-20230301191323-b3ac93c"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.4.0-alpha-20230301191323-b3ac93c_1677698028246_0.03645544229927289","host":"s3://npm-registry-packages"}},"0.4.0-alpha-20230301221441-4270d93":{"name":"@whatwg-node/router","version":"0.4.0-alpha-20230301221441-4270d93","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.4.0-alpha-20230301221441-4270d93","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"cfa849463468d0780cd76a993b5acb6ad605e00c","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.4.0-alpha-20230301221441-4270d93.tgz","fileCount":10,"integrity":"sha512-mtfagTYWRjrXq46UgpHwby3ETAmrxQ5Tp/jvMUBqjQ9rAyDOFCI/fkgF2flpjDgPmNHJpKniwerVJ0gIl/+bgA==","signatures":[{"sig":"MEUCIQC5dIpmTlF4Lq7zZyxVuku0CAbG4P4WsojEhaXMphuyrgIgWzM1dZV68KlW0NcG/lNmKMQ4Hu34l71+ddn/OJ3HZV8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":59528,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj/85qACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmr+uw/+JWhTq0wCpDq910l9UlnqxKvBpUqtT2i/Sozixo/x5o88j4nB\r\nkJM0AkymZpP1ue7nfkl4GHJ8mnrjhYZbN+9qunmRFt9gGdo+1HgrhmmzvcTS\r\npl+KBA6HcsZyHFcu3+DNN2yIhT/SfqP9oXYE/aOfUy6PIE5kVKF5j7TWHujV\r\nu8R6S9Gc3NkfWC8yhWjEtyw/uFna4z6jimnbiPfjeYQs2q5lmMOcx/ytCEgR\r\n540iptDJ/37FS9HuwDduzE287/QHakZF1SL8aOvwAbE0mWmIgt5U29hVpBto\r\nOaZ7cbeAGsE/irShfbRwZjWlg2U1vFyzwfsHfr33l5ORdy4rJGAQ+9F77elH\r\n8m1rzBGf4a3bjRRQFnN6R7eNWYekRCRqmS0WeGPdmBxRBd0LKZ/7Y0ZNuG6H\r\nTGoECgkRS4Oy6dNTmWnEVoLpG8S2cWZ26mbSBJUtoZSofEs5qmu16DjDbQKu\r\ngGw2p9tQKxoaJetSQf9UejZPUP4CB8P9E0nv9zA4cmRF5YX6jh7IWxk5alO4\r\nYIvFQZlVe98DUKtBnX0esWRhXMx/FgOZK9fVBhWXDFIVtkDDwwXFftaxlvuN\r\nZSc7uforfl5yiaimCciaijoqQ0mPyuZLH0DgquIiXBwClO4AXUt4aNfsfQdq\r\no6C5bdmm3kdKFw+zgkqgTye2RWU9pLtNnIM=\r\n=yaJn\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic fully type-safe JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\nIt also allows you to create end-to-end type-safe and validated HTTP APIs with JSON Schema without\n**ANY CODE GENERATION**.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Why should I use this package instead of tRPC?\n\ntRPC doesn't need a code generation like this library, but this library allows you export an OpenAPI\ndocument based on the JSON Schema definitions if you don't want to share TypeScript definitions\nbetween the client and the server. And this library uses [JSON Schema](https://json-schema.org/)\ninstead of a programmatic schema solution like zod which is more portable and has bigger ecosystem.\nSo even if you don't want to write JSON Schemas manually, you can use `@sinclair/typebox` to\ngenerate them by using an API like `zod` has.\n\n## Usage\n\nIt uses `.route()` method to add routes to the router with the following parameters;\n\n- `method`: The HTTP method of the request. This is optional and it handles all methods if it's not\n  given.\n- `path`: The URL pattern that the request should match. The url pattern is a string that follows\n  the [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can\n  learn more about URL patterns\n  [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n- `schemas`: An object that contains the schemas for the request and response. This brings a\n  type-safety and validation to your requests and responses. You can learn more about schemas\n  [here](#end-to-end-type-safety-and-validation-with-json-schema).\n- `handler`: The function that will be called when the request matches the given method and path.\n  This function can be either synchronous or asynchronous. If it's asynchronous, it should return a\n  `Promise` that resolves to a `Response` object.\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nYou can learn more about the original `Request` object\n[here](https://developer.mozilla.org/en-US/docs/Web/API/Request).\n\n### Basic Routing\n\n```ts\n// Then use it in any environment\nimport { createServer } from 'http'\nimport { createRouter, Response, Router } from '@whatwg-node/router'\n\nconst router = createRouter()\n  // GET collection index\n  .route({\n    method: 'GET',\n    path: '/todos',\n    handler: () => new Response('Todos Index!')\n  })\n  // GET item\n  .route({\n    method: 'GET',\n    path: '/todos/:id',\n    handler: ({ params }) => new Response(`Todo #${params.id}`)\n  })\n  // POST to the collection (we'll use async here)\n  .route({\n    method: 'POST',\n    path: '/todos',\n    handler: async request => {\n      const content = await request.json()\n      return new Response('Creating Todo: ' + JSON.stringify(content))\n    }\n  })\n\n  // Redirect to a URL\n  .route({\n    method: 'GET',\n    path: '/google',\n    handler: () => Response.redirect('http://www.google.com')\n  })\n\n  // 404 for everything else\n  .route({\n    path: '*',\n    handler: () => new Response('Not Found.', { status: 404 })\n  })\n\nconst httpServer = createServer(router)\nhttpServer.listen(4000)\n```\n\n## Example\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nconst router = createRouter()\n  .route({\n    method: 'GET',\n    path: '/users',\n    handler: () => Response.json(users)\n  })\n  // Parameters are given in the `request.params` object\n  .route({\n    method: 'GET',\n    path: '/users/:id',\n    handler: request => {\n      const user = users.find(user => user.id === request.params.id)\n\n      if (!user) {\n        return new Response(null, {\n          status: 404\n        })\n      }\n\n      return Response.json(user)\n    }\n  })\n  .route({\n    method: 'DELETE',\n    path: '/users/:id',\n    handler: request => {\n      const user = users.find(user => user.id === request.params.id)\n\n      if (!user) {\n        return new Response(null, {\n          status: 404\n        })\n      }\n\n      users.splice(users.indexOf(user), 1)\n\n      return new Response(null, {\n        status: 204\n      })\n    }\n  })\n  // Handle JSON bodies\n  .route({\n    method: 'PUT',\n    path: '/users',\n    handler: async request => {\n      const body = await request.json()\n\n      const user = {\n        id: String(users.length + 1),\n        name: body.name\n      }\n\n      users.push(user)\n\n      return Response.json(user)\n    }\n  })\n  // Handle both parameters and JSON body\n  .route({\n    method: 'PATCH',\n    path: '/users/:id',\n    handler: async request => {\n      const user = users.find(user => user.id === request.params.id)\n\n      if (!user) {\n        return new Response(null, {\n          status: 404\n        })\n      }\n\n      const body = await request.json()\n\n      user.name = body.name\n\n      return Response.json(user)\n    }\n  })\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nconst router = createRouter()\n  .route({\n    path: '*',\n    handler: request => {\n      if (!request.headers.get('Authorization')) {\n        return new Response(null, {\n          status: 401\n        })\n      }\n    }\n  })\n  .route({\n    path: '/users',\n    method: 'GET',\n    handler: request => {\n    // It doesn't reach here if the request doesn't have an `Authorization` header.\n  });\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nconst router = createRouter().route({\n  path: '/users',\n  method: 'GET',\n  handler: [\n    withAuth,\n    request => {\n      // It doesn't reach here if the request doesn't have an `Authorization` header.\n    }\n  ]\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors. Or you can use the plugins to handle errors like below.\n\n```ts\nimport { HTTPError, useErrorHandling } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [useErrorHandling()]\n}).route({\n  path: '/users',\n  method: 'GET',\n  handler: request => {\n    if (!request.headers.get('Authorization')) {\n      // You can use `HTTPError` to return a custom error response.\n      // It accepts a status code, a message, headers and a body.\n      // If you pass a json object as the body, the response will be a json response.\n      throw new HTTPError(\n        401,\n        'Unauthorized',\n        {\n          'WWW-Authenticate': 'Basic'\n        },\n        {\n          message: 'You need to be authenticated to access this resource.'\n        }\n      )\n    }\n  }\n})\n```\n\n## Plugins to handle CORS, cookies and more\n\nThis library also provides a plugin system that allows you hook into the request/response lifecycle.\n\n- `onRequest` - Called before the request is handled by the router\n- - It has `endResponse` method that accepts a `Response` object to short-circuit the request\n- `onResponse` - Called after the request is handled by the router\n- - It allows you to modify the response before it is sent to the client\n\n### Cookie Management\n\nYou can use `useCookies` to parse cookies from the request header and set cookies in the response by\nusing Web Standard [CookieStore](https://developer.mozilla.org/en-US/docs/Web/API/CookieStore).\n\n```ts\nimport { createRouter, Response, useCookies } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [useCookies()]\n})\n.route({\n  path: '/users',\n  method: 'GET',\n  handler: request => {\n    const sessionId = await request.cookieStore.get('session_id')\n    if (!sessionId) {\n      return Response.json({ error: 'Unauthorized' }, { status: 401 })\n    }\n    const user = await getUserBySessionId(sessionId)\n    return Response.json(user)\n  }\n})\n.route({\n  path: '/login',\n  method: 'POST',\n  handler: async request => {\n    const { username, password } = await request.json()\n    const sessionId = await createSessionForUser({ username, password })\n    await request.cookieStore.set('session_id', sessionId)\n    return Response.json({ message: 'ok' })\n  }\n})\n```\n\n### CORS Management\n\nYou can also setup a CORS middleware to handle preflight CORS requests.\n\n```ts\nimport { createRouter, useCORS } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [\n    useCORS({\n      origin: '*',\n      methods: ['GET', 'POST', 'PUT', 'DELETE'],\n      headers: ['Content-Type', 'Authorization']\n    })\n  ]\n})\n```\n\n### Custom plugins\n\nYou can also create your own plugins to handle errors, logging, etc.\n\n```ts\nimport { createRouter } from '@whatwg-node/router'\n\nconst useRequestId = (): RoutePlugin => {\n  return {\n    onRequest({ request, fetchAPI }) {\n      let requestId = request.headers.get('X-Request-ID')\n      if (!requestId) {\n        requestId = fetchAPI.crypto.randomUUID()\n        request.headers.set('X-Request-ID', requestId)\n      }\n    },\n    onResponse({ response, fetchAPI }) {\n      response.headers.set('X-Request-ID', request.headers.get('X-Request-ID'))\n    }\n  }\n}\n\nconst router = createRouter({\n  plugins: [useRequestId()]\n})\n```\n\n## End-to-End Type Safety and Validation with JSON Schema\n\nEven if the library provides you some type safety with TypeScript's type inference, you can still\nuse JSON Schemas to have a better type safety on both request and response.\n\nTo define type-safe routes, we use `schemas` parameters\n\n### Typing the request\n\nYou can type individual parts of the `Request` object including JSON body, headers, query\nparameters, and URL parameters.\n\n#### JSON Body\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().route(\n  {\n    method: 'post',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      request: {\n        json: {\n          type: 'object',\n          properties: {\n            title: { type: 'string' },\n            completed: { type: 'boolean' }\n          },\n          additionalProperties: false,\n          required: ['title']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const { title, completed } = await request.json()\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n#### Headers\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().route(\n  {\n    method: 'post',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      request: {\n        headers: {\n          type: 'object',\n          properties: {\n            'x-api-key': { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['x-api-key']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const apiKey = request.headers.get('x-api-key')\n    // Would fail on TypeScript compilation\n    const wrongHeaderName = request.headers.get('x-api-key-wrong')\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n#### Path Parameters\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().route(\n  {\n    method: 'get',\n    path: '/todos/:id',\n    // Define the request body schema\n    schemas: {\n      request: {\n        params: {\n          type: 'object',\n          properties: {\n            id: { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['id']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const { id } = request.params\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n#### Query Parameters\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute({\n  method: 'get',\n  path: '/todos',\n  // Define the request body schema\n  schemas: {\n    request: {\n      query: {\n        type: 'object',\n        properties: {\n          limit: { type: 'number' },\n          offset: { type: 'number' }\n        },\n        additionalProperties: false,\n        required: ['limit']\n      },\n    }\n  }\n}, async request => {\n  // This part is fully typed\n  const { limit, offset } = request.query\n  // You can also use `URLSearchParams` API\n  const limit = request.parsedURL.searchParams.get('limit')\n  // ...\n  return Response.json({ message: 'ok' })\n})\n```\n\n### Typing the response\n\nYou can also type the response body by the status code. We strongly recommend to explicitly define\nthe status codes.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'get',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      request: {\n        headers: {\n          type: 'object',\n          properties: {\n            'x-api-key': { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['x-api-key']\n        }\n      },\n      response: {\n        200: {\n          type: 'array',\n          items: {\n            type: 'object',\n            properties: {\n              id: { type: 'string' },\n              title: { type: 'string' },\n              completed: { type: 'boolean' }\n            },\n            additionalProperties: false,\n            required: ['id', 'title', 'completed']\n          }\n        },\n        401: {\n          type: 'object',\n          properties: {\n            message: { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['message']\n        }\n      }\n    }\n  },\n  async request => {\n    const apiKey = request.headers.get('x-api-key')\n    if (!apiKey) {\n      return Response.json(\n        { message: 'API key is required' },\n        {\n          status: 401\n        }\n      )\n    }\n    const todos = await getTodos({\n      apiKey\n    })\n    // This part is fully typed\n    return Response.json(todos, {\n      status: 200\n    })\n  }\n)\n```\n\n### Runtime validation with Ajv\n\nThe library itself doesn't include a runtime validation by default. But you can use that plugin to\nhave a runtime validation with the provided JSON Schemas above. This plugin uses\n[Ajv](https://ajv.js.org/) under the hood. All you have to do is to install\n`@whatwg-node/router-plugin-ajv` package and add it to the plugins.\n\n```ts\nimport { createRouter } from '@whatwg-node/router'\nimport { useAjv } from '@whatwg-node/router-plugin-ajv'\n\nconst router = createRouter({\n  plugins: [useAjv()]\n})\n```\n\n### OpenAPI Generation\n\nYou can generate OpenAPI specification from the defined routes by using OpenAPI plugin. This plugin\nalso provides you a [Swagger UI](https://swagger.io/tools/swagger-ui/) to test the API.\n\n```ts\nimport { createRouter, useOpenAPI } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [\n    useOpenAPI({\n      // You can define the header of the OpenAPI specification here\n      baseOas: {\n        openapi: '3.0.1',\n        info: {\n          title: 'Todo List Example',\n          description: 'A simple todo list example with @whatwg-node/router',\n          version: '1.0.0'\n        },\n        components: {}\n      },\n      // You can access the Swagger UI at `/docs`\n      swaggerUIPath: '/docs',\n      // You can download the OpenAPI specification as a JSON file\n      oasPath: '/openapi.json'\n    })\n  ]\n})\n```\n\n### Using a programmatic JSON Schema builder (`zod`-like API)\n\n```ts\nimport { Static, Type } from '@sinclair/typebox'\n\nconst Todo = Type.Object({\n  id: Type.String(),\n  title: Type.String(),\n  completed: Type.Boolean()\n})\n\ntype Todo = Static<typeof Todo>\n\nconst router = createRouter().route({\n  path: '/todos',\n  schemas: {\n    request: {\n      body: Todo\n    },\n    response: {\n      200: Type.Array(Todo)\n    }\n  }\n})\n```\n\n### Type-safety on the client side\n\nWith this library, you can also type the request and response on the client side. But you have two\noptions;\n\n1. You can infer the types from the router itself by using `createRouterSDK` from this library.\n2. You can use OpenAPI client package that infers the types from the given OpenAPI document.\n\n#### Using `createRouterSDK`\n\n```ts file=examples/client.ts\nimport { createRouterSDK } from '@whatwg-node/router'\n// Notice `type` in the import to avoid to import it on runtime\nimport type { router } from '../router'\n\nconst sdk = createRouterSDK<typeof router>({\n  endpoint: 'http://localhost:3000'\n})\n\n// Everything below is fully typed\nconst response = await sdk['/todo'].put({\n  json: {\n    title: 'Buy milk',\n    completed: false\n  }\n})\nconst responseJson = await response.json()\nconsole.table(responseJson)\n```\n\n#### Using OpenAPI Client\n\nYou need to save the OpenAPI document to a code file like below;\n\n```ts\nexport default { openapi: '3.0.1' /* ... */ }\n```\n\nThen you need to import the OpenAPI document to the client code;\n\n```ts file=examples/client.ts\nimport { createOASClient, Mutable } from '@whatwg-node/oas-client'\n// Notice `type` in the import to avoid to import it on runtime\nimport type oas from './saved_openapi'\n\nconst client = createOASClient<Mutable<typeof oas>>({\n  endpoint: 'http://localhost:3000'\n})\n\n// Everything below is fully typed\nconst response = await client['/todo'].put({\n  json: {\n    title: 'Buy milk',\n    completed: false\n  }\n})\nconst responseJson = await response.json()\nconsole.table(responseJson)\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"4270d93ea677a544d1fc108e8e9410ed448e1771","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.5.0","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.2","dependencies":{"tslib":"^2.3.1","openapi-types":"12.1.0","json-schema-to-ts":"2.6.2","@whatwg-node/fetch":"0.8.2-alpha-20230301221441-4270d93","@whatwg-node/server":"0.7.2-alpha-20230301221441-4270d93","@whatwg-node/typed-fetch":"0.0.1-alpha-20230301221441-4270d93"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.4.0-alpha-20230301221441-4270d93_1677708905863_0.58692531527615","host":"s3://npm-registry-packages"}},"0.4.0-alpha-20230301224056-1a47c50":{"name":"@whatwg-node/router","version":"0.4.0-alpha-20230301224056-1a47c50","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.4.0-alpha-20230301224056-1a47c50","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"6d065feaceb039ac9c225b7712d5d4fb416e8440","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.4.0-alpha-20230301224056-1a47c50.tgz","fileCount":10,"integrity":"sha512-6jXTMzDZvZjw9LK1rKJo5ZljUSbZZ2v4vynihNH9/nxuSYfa9bQ2tF0F8YJ8VcGZZufaeNleUAoWLfjsFEzhew==","signatures":[{"sig":"MEQCIFJPSZdNyYR8psnxbDPpT2GT4AZCvqSa8yZZ9PftLwR4AiBc0zOwxHDCUfgxiHguv1x8qCeGrDoUndCZlYfMbYy1Bw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":59528,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj/9SSACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpdeQ/+KSR03IKv9WCNSKm8SQynZRuN1uJa88ADK4/8j5F4ryBgTVF5\r\n+nKMyg3GrRw1vP3AFZAJln+U9iYAYk/t+4xssDSGvZHRXCWfKI1Yrvr5VVky\r\nhr91CJ4KS6s74nO/itRxYe6+k7M7z1DzVRzhbkk0Gjtuyn1fLo6KeVUkRJ69\r\nCwXEBVVZzKkbYwMaMju8pivxiVMUnT/eRQPc0bqAoxaaLhXSdMUxJOq3AwBb\r\n8nNxeQegpHhmUDJc4LGPWvjBsSMjv4nvuQxExzDuG+VUmyr5SY5yLLMqG57x\r\nDllSAYpNtSilyMJY7oIS0jLDufGHeHnkBN50FDIOmUJH9OadFZNtMemdn42p\r\noo3gj0PKBWzTjSYoefthsJ1WYahkcM5X3JZmNdAUAYERSIQAW1oLKYVmw3hr\r\nuKoW4sL6o4OjX4kAeXNGEMClSfPJOl47h6LSLCjBnbeiH3jorA6+EI33xru5\r\n29WBLSgHXzbKseuT0x0fYpMmZv2yXvy7QhWu63raIqirBb130e7LyX93Ee39\r\nd2MJ6OuINvgPhEviEcUyAV27htjXH7Z3Nldh/Hm4A2YtvnWL7oSiWGNlkQbL\r\ngjoCKG4ou+iigtSC/PrIb0wBDXOaiHF3jOOzNxQW1Lr+Nby8NmP84h/R16YS\r\nP/X9i9GUIUVGYAhiCTS0ffCToWIcaTHAsb8=\r\n=al+7\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic fully type-safe JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\nIt also allows you to create end-to-end type-safe and validated HTTP APIs with JSON Schema without\n**ANY CODE GENERATION**.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Why should I use this package instead of tRPC?\n\ntRPC doesn't need a code generation like this library, but this library allows you export an OpenAPI\ndocument based on the JSON Schema definitions if you don't want to share TypeScript definitions\nbetween the client and the server. And this library uses [JSON Schema](https://json-schema.org/)\ninstead of a programmatic schema solution like zod which is more portable and has bigger ecosystem.\nSo even if you don't want to write JSON Schemas manually, you can use `@sinclair/typebox` to\ngenerate them by using an API like `zod` has.\n\n## Usage\n\nIt uses `.route()` method to add routes to the router with the following parameters;\n\n- `method`: The HTTP method of the request. This is optional and it handles all methods if it's not\n  given.\n- `path`: The URL pattern that the request should match. The url pattern is a string that follows\n  the [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can\n  learn more about URL patterns\n  [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n- `schemas`: An object that contains the schemas for the request and response. This brings a\n  type-safety and validation to your requests and responses. You can learn more about schemas\n  [here](#end-to-end-type-safety-and-validation-with-json-schema).\n- `handler`: The function that will be called when the request matches the given method and path.\n  This function can be either synchronous or asynchronous. If it's asynchronous, it should return a\n  `Promise` that resolves to a `Response` object.\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nYou can learn more about the original `Request` object\n[here](https://developer.mozilla.org/en-US/docs/Web/API/Request).\n\n### Basic Routing\n\n```ts\n// Then use it in any environment\nimport { createServer } from 'http'\nimport { createRouter, Response, Router } from '@whatwg-node/router'\n\nconst router = createRouter()\n  // GET collection index\n  .route({\n    method: 'GET',\n    path: '/todos',\n    handler: () => new Response('Todos Index!')\n  })\n  // GET item\n  .route({\n    method: 'GET',\n    path: '/todos/:id',\n    handler: ({ params }) => new Response(`Todo #${params.id}`)\n  })\n  // POST to the collection (we'll use async here)\n  .route({\n    method: 'POST',\n    path: '/todos',\n    handler: async request => {\n      const content = await request.json()\n      return new Response('Creating Todo: ' + JSON.stringify(content))\n    }\n  })\n\n  // Redirect to a URL\n  .route({\n    method: 'GET',\n    path: '/google',\n    handler: () => Response.redirect('http://www.google.com')\n  })\n\n  // 404 for everything else\n  .route({\n    path: '*',\n    handler: () => new Response('Not Found.', { status: 404 })\n  })\n\nconst httpServer = createServer(router)\nhttpServer.listen(4000)\n```\n\n## Example\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nconst router = createRouter()\n  .route({\n    method: 'GET',\n    path: '/users',\n    handler: () => Response.json(users)\n  })\n  // Parameters are given in the `request.params` object\n  .route({\n    method: 'GET',\n    path: '/users/:id',\n    handler: request => {\n      const user = users.find(user => user.id === request.params.id)\n\n      if (!user) {\n        return new Response(null, {\n          status: 404\n        })\n      }\n\n      return Response.json(user)\n    }\n  })\n  .route({\n    method: 'DELETE',\n    path: '/users/:id',\n    handler: request => {\n      const user = users.find(user => user.id === request.params.id)\n\n      if (!user) {\n        return new Response(null, {\n          status: 404\n        })\n      }\n\n      users.splice(users.indexOf(user), 1)\n\n      return new Response(null, {\n        status: 204\n      })\n    }\n  })\n  // Handle JSON bodies\n  .route({\n    method: 'PUT',\n    path: '/users',\n    handler: async request => {\n      const body = await request.json()\n\n      const user = {\n        id: String(users.length + 1),\n        name: body.name\n      }\n\n      users.push(user)\n\n      return Response.json(user)\n    }\n  })\n  // Handle both parameters and JSON body\n  .route({\n    method: 'PATCH',\n    path: '/users/:id',\n    handler: async request => {\n      const user = users.find(user => user.id === request.params.id)\n\n      if (!user) {\n        return new Response(null, {\n          status: 404\n        })\n      }\n\n      const body = await request.json()\n\n      user.name = body.name\n\n      return Response.json(user)\n    }\n  })\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nconst router = createRouter()\n  .route({\n    path: '*',\n    handler: request => {\n      if (!request.headers.get('Authorization')) {\n        return new Response(null, {\n          status: 401\n        })\n      }\n    }\n  })\n  .route({\n    path: '/users',\n    method: 'GET',\n    handler: request => {\n    // It doesn't reach here if the request doesn't have an `Authorization` header.\n  });\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nconst router = createRouter().route({\n  path: '/users',\n  method: 'GET',\n  handler: [\n    withAuth,\n    request => {\n      // It doesn't reach here if the request doesn't have an `Authorization` header.\n    }\n  ]\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors. Or you can use the plugins to handle errors like below.\n\n```ts\nimport { HTTPError, useErrorHandling } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [useErrorHandling()]\n}).route({\n  path: '/users',\n  method: 'GET',\n  handler: request => {\n    if (!request.headers.get('Authorization')) {\n      // You can use `HTTPError` to return a custom error response.\n      // It accepts a status code, a message, headers and a body.\n      // If you pass a json object as the body, the response will be a json response.\n      throw new HTTPError(\n        401,\n        'Unauthorized',\n        {\n          'WWW-Authenticate': 'Basic'\n        },\n        {\n          message: 'You need to be authenticated to access this resource.'\n        }\n      )\n    }\n  }\n})\n```\n\n## Plugins to handle CORS, cookies and more\n\nThis library also provides a plugin system that allows you hook into the request/response lifecycle.\n\n- `onRequest` - Called before the request is handled by the router\n- - It has `endResponse` method that accepts a `Response` object to short-circuit the request\n- `onResponse` - Called after the request is handled by the router\n- - It allows you to modify the response before it is sent to the client\n\n### Cookie Management\n\nYou can use `useCookies` to parse cookies from the request header and set cookies in the response by\nusing Web Standard [CookieStore](https://developer.mozilla.org/en-US/docs/Web/API/CookieStore).\n\n```ts\nimport { createRouter, Response, useCookies } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [useCookies()]\n})\n.route({\n  path: '/users',\n  method: 'GET',\n  handler: request => {\n    const sessionId = await request.cookieStore.get('session_id')\n    if (!sessionId) {\n      return Response.json({ error: 'Unauthorized' }, { status: 401 })\n    }\n    const user = await getUserBySessionId(sessionId)\n    return Response.json(user)\n  }\n})\n.route({\n  path: '/login',\n  method: 'POST',\n  handler: async request => {\n    const { username, password } = await request.json()\n    const sessionId = await createSessionForUser({ username, password })\n    await request.cookieStore.set('session_id', sessionId)\n    return Response.json({ message: 'ok' })\n  }\n})\n```\n\n### CORS Management\n\nYou can also setup a CORS middleware to handle preflight CORS requests.\n\n```ts\nimport { createRouter, useCORS } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [\n    useCORS({\n      origin: '*',\n      methods: ['GET', 'POST', 'PUT', 'DELETE'],\n      headers: ['Content-Type', 'Authorization']\n    })\n  ]\n})\n```\n\n### Custom plugins\n\nYou can also create your own plugins to handle errors, logging, etc.\n\n```ts\nimport { createRouter } from '@whatwg-node/router'\n\nconst useRequestId = (): RoutePlugin => {\n  return {\n    onRequest({ request, fetchAPI }) {\n      let requestId = request.headers.get('X-Request-ID')\n      if (!requestId) {\n        requestId = fetchAPI.crypto.randomUUID()\n        request.headers.set('X-Request-ID', requestId)\n      }\n    },\n    onResponse({ response, fetchAPI }) {\n      response.headers.set('X-Request-ID', request.headers.get('X-Request-ID'))\n    }\n  }\n}\n\nconst router = createRouter({\n  plugins: [useRequestId()]\n})\n```\n\n## End-to-End Type Safety and Validation with JSON Schema\n\nEven if the library provides you some type safety with TypeScript's type inference, you can still\nuse JSON Schemas to have a better type safety on both request and response.\n\nTo define type-safe routes, we use `schemas` parameters\n\n### Typing the request\n\nYou can type individual parts of the `Request` object including JSON body, headers, query\nparameters, and URL parameters.\n\n#### JSON Body\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().route(\n  {\n    method: 'post',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      request: {\n        json: {\n          type: 'object',\n          properties: {\n            title: { type: 'string' },\n            completed: { type: 'boolean' }\n          },\n          additionalProperties: false,\n          required: ['title']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const { title, completed } = await request.json()\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n#### Headers\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().route(\n  {\n    method: 'post',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      request: {\n        headers: {\n          type: 'object',\n          properties: {\n            'x-api-key': { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['x-api-key']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const apiKey = request.headers.get('x-api-key')\n    // Would fail on TypeScript compilation\n    const wrongHeaderName = request.headers.get('x-api-key-wrong')\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n#### Path Parameters\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().route(\n  {\n    method: 'get',\n    path: '/todos/:id',\n    // Define the request body schema\n    schemas: {\n      request: {\n        params: {\n          type: 'object',\n          properties: {\n            id: { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['id']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const { id } = request.params\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n#### Query Parameters\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute({\n  method: 'get',\n  path: '/todos',\n  // Define the request body schema\n  schemas: {\n    request: {\n      query: {\n        type: 'object',\n        properties: {\n          limit: { type: 'number' },\n          offset: { type: 'number' }\n        },\n        additionalProperties: false,\n        required: ['limit']\n      },\n    }\n  }\n}, async request => {\n  // This part is fully typed\n  const { limit, offset } = request.query\n  // You can also use `URLSearchParams` API\n  const limit = request.parsedURL.searchParams.get('limit')\n  // ...\n  return Response.json({ message: 'ok' })\n})\n```\n\n### Typing the response\n\nYou can also type the response body by the status code. We strongly recommend to explicitly define\nthe status codes.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'get',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      request: {\n        headers: {\n          type: 'object',\n          properties: {\n            'x-api-key': { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['x-api-key']\n        }\n      },\n      response: {\n        200: {\n          type: 'array',\n          items: {\n            type: 'object',\n            properties: {\n              id: { type: 'string' },\n              title: { type: 'string' },\n              completed: { type: 'boolean' }\n            },\n            additionalProperties: false,\n            required: ['id', 'title', 'completed']\n          }\n        },\n        401: {\n          type: 'object',\n          properties: {\n            message: { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['message']\n        }\n      }\n    }\n  },\n  async request => {\n    const apiKey = request.headers.get('x-api-key')\n    if (!apiKey) {\n      return Response.json(\n        { message: 'API key is required' },\n        {\n          status: 401\n        }\n      )\n    }\n    const todos = await getTodos({\n      apiKey\n    })\n    // This part is fully typed\n    return Response.json(todos, {\n      status: 200\n    })\n  }\n)\n```\n\n### Runtime validation with Ajv\n\nThe library itself doesn't include a runtime validation by default. But you can use that plugin to\nhave a runtime validation with the provided JSON Schemas above. This plugin uses\n[Ajv](https://ajv.js.org/) under the hood. All you have to do is to install\n`@whatwg-node/router-plugin-ajv` package and add it to the plugins.\n\n```ts\nimport { createRouter } from '@whatwg-node/router'\nimport { useAjv } from '@whatwg-node/router-plugin-ajv'\n\nconst router = createRouter({\n  plugins: [useAjv()]\n})\n```\n\n### OpenAPI Generation\n\nYou can generate OpenAPI specification from the defined routes by using OpenAPI plugin. This plugin\nalso provides you a [Swagger UI](https://swagger.io/tools/swagger-ui/) to test the API.\n\n```ts\nimport { createRouter, useOpenAPI } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [\n    useOpenAPI({\n      // You can define the header of the OpenAPI specification here\n      baseOas: {\n        openapi: '3.0.1',\n        info: {\n          title: 'Todo List Example',\n          description: 'A simple todo list example with @whatwg-node/router',\n          version: '1.0.0'\n        },\n        components: {}\n      },\n      // You can access the Swagger UI at `/docs`\n      swaggerUIPath: '/docs',\n      // You can download the OpenAPI specification as a JSON file\n      oasPath: '/openapi.json'\n    })\n  ]\n})\n```\n\n### Using a programmatic JSON Schema builder (`zod`-like API)\n\n```ts\nimport { Static, Type } from '@sinclair/typebox'\n\nconst Todo = Type.Object({\n  id: Type.String(),\n  title: Type.String(),\n  completed: Type.Boolean()\n})\n\ntype Todo = Static<typeof Todo>\n\nconst router = createRouter().route({\n  path: '/todos',\n  schemas: {\n    request: {\n      body: Todo\n    },\n    response: {\n      200: Type.Array(Todo)\n    }\n  }\n})\n```\n\n### Type-safety on the client side\n\nWith this library, you can also type the request and response on the client side. But you have two\noptions;\n\n1. You can infer the types from the router itself by using `createRouterSDK` from this library.\n2. You can use OpenAPI client package that infers the types from the given OpenAPI document.\n\n#### Using `createRouterSDK`\n\n```ts file=examples/client.ts\nimport { createRouterSDK } from '@whatwg-node/router'\n// Notice `type` in the import to avoid to import it on runtime\nimport type { router } from '../router'\n\nconst sdk = createRouterSDK<typeof router>({\n  endpoint: 'http://localhost:3000'\n})\n\n// Everything below is fully typed\nconst response = await sdk['/todo'].put({\n  json: {\n    title: 'Buy milk',\n    completed: false\n  }\n})\nconst responseJson = await response.json()\nconsole.table(responseJson)\n```\n\n#### Using OpenAPI Client\n\nYou need to save the OpenAPI document to a code file like below;\n\n```ts\nexport default { openapi: '3.0.1' /* ... */ }\n```\n\nThen you need to import the OpenAPI document to the client code;\n\n```ts file=examples/client.ts\nimport { createOASClient, Mutable } from '@whatwg-node/oas-client'\n// Notice `type` in the import to avoid to import it on runtime\nimport type oas from './saved_openapi'\n\nconst client = createOASClient<Mutable<typeof oas>>({\n  endpoint: 'http://localhost:3000'\n})\n\n// Everything below is fully typed\nconst response = await client['/todo'].put({\n  json: {\n    title: 'Buy milk',\n    completed: false\n  }\n})\nconst responseJson = await response.json()\nconsole.table(responseJson)\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"1a47c50fa025f4bc050e32171b903dcab6579a22","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.5.0","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.2","dependencies":{"tslib":"^2.3.1","openapi-types":"12.1.0","json-schema-to-ts":"2.6.2","@whatwg-node/fetch":"0.8.2-alpha-20230301224056-1a47c50","@whatwg-node/server":"0.7.2-alpha-20230301224056-1a47c50","@whatwg-node/typed-fetch":"0.0.1-alpha-20230301224056-1a47c50"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.4.0-alpha-20230301224056-1a47c50_1677710481955_0.15801418480767215","host":"s3://npm-registry-packages"}},"0.4.0-alpha-20230301233255-89a0314":{"name":"@whatwg-node/router","version":"0.4.0-alpha-20230301233255-89a0314","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.4.0-alpha-20230301233255-89a0314","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"86cd7842991d2dce5855425434edb138071e06aa","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.4.0-alpha-20230301233255-89a0314.tgz","fileCount":10,"integrity":"sha512-OocKCZOZE3jxrBzz8WOx8F2F4IXhadk3GZ+deX7zgXWVx03C2StydK739FbjU3UbBNw14pd0kav7H2PLnVqW2g==","signatures":[{"sig":"MEYCIQDsT9wbTUfIRGZaI71affHvRRg83WOj3TJ6x7rsiwefBAIhAKeH55UHCZc3td6hZyOfLpce9JERJkIDQHxzIHw7pPOi","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":59528,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj/+C9ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmo2Tw/9H6Jv35fyumRYEPbKcS19mJI3F1LJDh+rZT+vx2Bm31wgakd5\r\n8K+5xCRJgrlSWoIb9yI/pBAtMBTKizUQAbH3+9jujavFsOuTDzGEli78K1cG\r\nz/NqOyfAq5JB5/uYjORtF8rjiUyeunJHJ/xdoDg0jatjynpMCtwHKJ4B7OH5\r\nsooOlV9nSZzZXB0E1JKgc8gSqSxKpT2q3t95jkXmzoz3IhwE2C2KJhkqacBk\r\nL5pbnmmIo1pbhCvACOK80LH+UN4h3MFB7skOv1nZmDDe5Sq+9y7UL/qap9ua\r\nQM/VXS9Zp/TAZntZ87Qjw7/5f7ceqPcFQac6rUje72300OTslcvUsiVIfmcf\r\n08od5tvQIHKaymOcCU1HyejeHy1T0ItYtNtGcORQ2EIItmEyQqRto+d3jp38\r\n7V1cKLJiUNStCHxnYcjjGKJ4Y+tJsqvATNaDxEZ3supXhhqzIVoevpfUoQbp\r\naG6LVqQhK+SDlEglDq3Bc9sW4Uai7q54Fs35/re3np89bjrUolQ12Cm7ACu7\r\nj6EWzMgdTb7WD/MS9UNRd9BdaJPDhBibX4OIW1m3rq5mVIRYuds1FEdvr6d8\r\n3rZUd/qiVmlTODINH/Qzu5zY73u04gKi8w7C02r/wEsmRVUHckq0EXJ/hi1D\r\n/Fx/WyEm6V499IinPqOSCzgMiP7CKPiUDU0=\r\n=k/IW\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic fully type-safe JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\nIt also allows you to create end-to-end type-safe and validated HTTP APIs with JSON Schema without\n**ANY CODE GENERATION**.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Why should I use this package instead of tRPC?\n\ntRPC doesn't need a code generation like this library, but this library allows you export an OpenAPI\ndocument based on the JSON Schema definitions if you don't want to share TypeScript definitions\nbetween the client and the server. And this library uses [JSON Schema](https://json-schema.org/)\ninstead of a programmatic schema solution like zod which is more portable and has bigger ecosystem.\nSo even if you don't want to write JSON Schemas manually, you can use `@sinclair/typebox` to\ngenerate them by using an API like `zod` has.\n\n## Usage\n\nIt uses `.route()` method to add routes to the router with the following parameters;\n\n- `method`: The HTTP method of the request. This is optional and it handles all methods if it's not\n  given.\n- `path`: The URL pattern that the request should match. The url pattern is a string that follows\n  the [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can\n  learn more about URL patterns\n  [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n- `schemas`: An object that contains the schemas for the request and response. This brings a\n  type-safety and validation to your requests and responses. You can learn more about schemas\n  [here](#end-to-end-type-safety-and-validation-with-json-schema).\n- `handler`: The function that will be called when the request matches the given method and path.\n  This function can be either synchronous or asynchronous. If it's asynchronous, it should return a\n  `Promise` that resolves to a `Response` object.\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nYou can learn more about the original `Request` object\n[here](https://developer.mozilla.org/en-US/docs/Web/API/Request).\n\n### Basic Routing\n\n```ts\n// Then use it in any environment\nimport { createServer } from 'http'\nimport { createRouter, Response, Router } from '@whatwg-node/router'\n\nconst router = createRouter()\n  // GET collection index\n  .route({\n    method: 'GET',\n    path: '/todos',\n    handler: () => new Response('Todos Index!')\n  })\n  // GET item\n  .route({\n    method: 'GET',\n    path: '/todos/:id',\n    handler: ({ params }) => new Response(`Todo #${params.id}`)\n  })\n  // POST to the collection (we'll use async here)\n  .route({\n    method: 'POST',\n    path: '/todos',\n    handler: async request => {\n      const content = await request.json()\n      return new Response('Creating Todo: ' + JSON.stringify(content))\n    }\n  })\n\n  // Redirect to a URL\n  .route({\n    method: 'GET',\n    path: '/google',\n    handler: () => Response.redirect('http://www.google.com')\n  })\n\n  // 404 for everything else\n  .route({\n    path: '*',\n    handler: () => new Response('Not Found.', { status: 404 })\n  })\n\nconst httpServer = createServer(router)\nhttpServer.listen(4000)\n```\n\n## Example\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nconst router = createRouter()\n  .route({\n    method: 'GET',\n    path: '/users',\n    handler: () => Response.json(users)\n  })\n  // Parameters are given in the `request.params` object\n  .route({\n    method: 'GET',\n    path: '/users/:id',\n    handler: request => {\n      const user = users.find(user => user.id === request.params.id)\n\n      if (!user) {\n        return new Response(null, {\n          status: 404\n        })\n      }\n\n      return Response.json(user)\n    }\n  })\n  .route({\n    method: 'DELETE',\n    path: '/users/:id',\n    handler: request => {\n      const user = users.find(user => user.id === request.params.id)\n\n      if (!user) {\n        return new Response(null, {\n          status: 404\n        })\n      }\n\n      users.splice(users.indexOf(user), 1)\n\n      return new Response(null, {\n        status: 204\n      })\n    }\n  })\n  // Handle JSON bodies\n  .route({\n    method: 'PUT',\n    path: '/users',\n    handler: async request => {\n      const body = await request.json()\n\n      const user = {\n        id: String(users.length + 1),\n        name: body.name\n      }\n\n      users.push(user)\n\n      return Response.json(user)\n    }\n  })\n  // Handle both parameters and JSON body\n  .route({\n    method: 'PATCH',\n    path: '/users/:id',\n    handler: async request => {\n      const user = users.find(user => user.id === request.params.id)\n\n      if (!user) {\n        return new Response(null, {\n          status: 404\n        })\n      }\n\n      const body = await request.json()\n\n      user.name = body.name\n\n      return Response.json(user)\n    }\n  })\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nconst router = createRouter()\n  .route({\n    path: '*',\n    handler: request => {\n      if (!request.headers.get('Authorization')) {\n        return new Response(null, {\n          status: 401\n        })\n      }\n    }\n  })\n  .route({\n    path: '/users',\n    method: 'GET',\n    handler: request => {\n    // It doesn't reach here if the request doesn't have an `Authorization` header.\n  });\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nconst router = createRouter().route({\n  path: '/users',\n  method: 'GET',\n  handler: [\n    withAuth,\n    request => {\n      // It doesn't reach here if the request doesn't have an `Authorization` header.\n    }\n  ]\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors. Or you can use the plugins to handle errors like below.\n\n```ts\nimport { HTTPError, useErrorHandling } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [useErrorHandling()]\n}).route({\n  path: '/users',\n  method: 'GET',\n  handler: request => {\n    if (!request.headers.get('Authorization')) {\n      // You can use `HTTPError` to return a custom error response.\n      // It accepts a status code, a message, headers and a body.\n      // If you pass a json object as the body, the response will be a json response.\n      throw new HTTPError(\n        401,\n        'Unauthorized',\n        {\n          'WWW-Authenticate': 'Basic'\n        },\n        {\n          message: 'You need to be authenticated to access this resource.'\n        }\n      )\n    }\n  }\n})\n```\n\n## Plugins to handle CORS, cookies and more\n\nThis library also provides a plugin system that allows you hook into the request/response lifecycle.\n\n- `onRequest` - Called before the request is handled by the router\n- - It has `endResponse` method that accepts a `Response` object to short-circuit the request\n- `onResponse` - Called after the request is handled by the router\n- - It allows you to modify the response before it is sent to the client\n\n### Cookie Management\n\nYou can use `useCookies` to parse cookies from the request header and set cookies in the response by\nusing Web Standard [CookieStore](https://developer.mozilla.org/en-US/docs/Web/API/CookieStore).\n\n```ts\nimport { createRouter, Response, useCookies } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [useCookies()]\n})\n.route({\n  path: '/users',\n  method: 'GET',\n  handler: request => {\n    const sessionId = await request.cookieStore.get('session_id')\n    if (!sessionId) {\n      return Response.json({ error: 'Unauthorized' }, { status: 401 })\n    }\n    const user = await getUserBySessionId(sessionId)\n    return Response.json(user)\n  }\n})\n.route({\n  path: '/login',\n  method: 'POST',\n  handler: async request => {\n    const { username, password } = await request.json()\n    const sessionId = await createSessionForUser({ username, password })\n    await request.cookieStore.set('session_id', sessionId)\n    return Response.json({ message: 'ok' })\n  }\n})\n```\n\n### CORS Management\n\nYou can also setup a CORS middleware to handle preflight CORS requests.\n\n```ts\nimport { createRouter, useCORS } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [\n    useCORS({\n      origin: '*',\n      methods: ['GET', 'POST', 'PUT', 'DELETE'],\n      headers: ['Content-Type', 'Authorization']\n    })\n  ]\n})\n```\n\n### Custom plugins\n\nYou can also create your own plugins to handle errors, logging, etc.\n\n```ts\nimport { createRouter } from '@whatwg-node/router'\n\nconst useRequestId = (): RoutePlugin => {\n  return {\n    onRequest({ request, fetchAPI }) {\n      let requestId = request.headers.get('X-Request-ID')\n      if (!requestId) {\n        requestId = fetchAPI.crypto.randomUUID()\n        request.headers.set('X-Request-ID', requestId)\n      }\n    },\n    onResponse({ response, fetchAPI }) {\n      response.headers.set('X-Request-ID', request.headers.get('X-Request-ID'))\n    }\n  }\n}\n\nconst router = createRouter({\n  plugins: [useRequestId()]\n})\n```\n\n## End-to-End Type Safety and Validation with JSON Schema\n\nEven if the library provides you some type safety with TypeScript's type inference, you can still\nuse JSON Schemas to have a better type safety on both request and response.\n\nTo define type-safe routes, we use `schemas` parameters\n\n### Typing the request\n\nYou can type individual parts of the `Request` object including JSON body, headers, query\nparameters, and URL parameters.\n\n#### JSON Body\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().route(\n  {\n    method: 'post',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      request: {\n        json: {\n          type: 'object',\n          properties: {\n            title: { type: 'string' },\n            completed: { type: 'boolean' }\n          },\n          additionalProperties: false,\n          required: ['title']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const { title, completed } = await request.json()\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n#### Headers\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().route(\n  {\n    method: 'post',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      request: {\n        headers: {\n          type: 'object',\n          properties: {\n            'x-api-key': { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['x-api-key']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const apiKey = request.headers.get('x-api-key')\n    // Would fail on TypeScript compilation\n    const wrongHeaderName = request.headers.get('x-api-key-wrong')\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n#### Path Parameters\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().route(\n  {\n    method: 'get',\n    path: '/todos/:id',\n    // Define the request body schema\n    schemas: {\n      request: {\n        params: {\n          type: 'object',\n          properties: {\n            id: { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['id']\n        }\n      }\n    }\n  },\n  async request => {\n    // This part is fully typed\n    const { id } = request.params\n    // ...\n    return Response.json({ message: 'ok' })\n  }\n)\n```\n\n#### Query Parameters\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute({\n  method: 'get',\n  path: '/todos',\n  // Define the request body schema\n  schemas: {\n    request: {\n      query: {\n        type: 'object',\n        properties: {\n          limit: { type: 'number' },\n          offset: { type: 'number' }\n        },\n        additionalProperties: false,\n        required: ['limit']\n      },\n    }\n  }\n}, async request => {\n  // This part is fully typed\n  const { limit, offset } = request.query\n  // You can also use `URLSearchParams` API\n  const limit = request.parsedURL.searchParams.get('limit')\n  // ...\n  return Response.json({ message: 'ok' })\n})\n```\n\n### Typing the response\n\nYou can also type the response body by the status code. We strongly recommend to explicitly define\nthe status codes.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter().addRoute(\n  {\n    method: 'get',\n    path: '/todos',\n    // Define the request body schema\n    schemas: {\n      request: {\n        headers: {\n          type: 'object',\n          properties: {\n            'x-api-key': { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['x-api-key']\n        }\n      },\n      response: {\n        200: {\n          type: 'array',\n          items: {\n            type: 'object',\n            properties: {\n              id: { type: 'string' },\n              title: { type: 'string' },\n              completed: { type: 'boolean' }\n            },\n            additionalProperties: false,\n            required: ['id', 'title', 'completed']\n          }\n        },\n        401: {\n          type: 'object',\n          properties: {\n            message: { type: 'string' }\n          },\n          additionalProperties: false,\n          required: ['message']\n        }\n      }\n    }\n  },\n  async request => {\n    const apiKey = request.headers.get('x-api-key')\n    if (!apiKey) {\n      return Response.json(\n        { message: 'API key is required' },\n        {\n          status: 401\n        }\n      )\n    }\n    const todos = await getTodos({\n      apiKey\n    })\n    // This part is fully typed\n    return Response.json(todos, {\n      status: 200\n    })\n  }\n)\n```\n\n### Runtime validation with Ajv\n\nThe library itself doesn't include a runtime validation by default. But you can use that plugin to\nhave a runtime validation with the provided JSON Schemas above. This plugin uses\n[Ajv](https://ajv.js.org/) under the hood. All you have to do is to install\n`@whatwg-node/router-plugin-ajv` package and add it to the plugins.\n\n```ts\nimport { createRouter } from '@whatwg-node/router'\nimport { useAjv } from '@whatwg-node/router-plugin-ajv'\n\nconst router = createRouter({\n  plugins: [useAjv()]\n})\n```\n\n### OpenAPI Generation\n\nYou can generate OpenAPI specification from the defined routes by using OpenAPI plugin. This plugin\nalso provides you a [Swagger UI](https://swagger.io/tools/swagger-ui/) to test the API.\n\n```ts\nimport { createRouter, useOpenAPI } from '@whatwg-node/router'\n\nconst router = createRouter({\n  plugins: [\n    useOpenAPI({\n      // You can define the header of the OpenAPI specification here\n      baseOas: {\n        openapi: '3.0.1',\n        info: {\n          title: 'Todo List Example',\n          description: 'A simple todo list example with @whatwg-node/router',\n          version: '1.0.0'\n        },\n        components: {}\n      },\n      // You can access the Swagger UI at `/docs`\n      swaggerUIPath: '/docs',\n      // You can download the OpenAPI specification as a JSON file\n      oasPath: '/openapi.json'\n    })\n  ]\n})\n```\n\n### Using a programmatic JSON Schema builder (`zod`-like API)\n\n```ts\nimport { Static, Type } from '@sinclair/typebox'\n\nconst Todo = Type.Object({\n  id: Type.String(),\n  title: Type.String(),\n  completed: Type.Boolean()\n})\n\ntype Todo = Static<typeof Todo>\n\nconst router = createRouter().route({\n  path: '/todos',\n  schemas: {\n    request: {\n      body: Todo\n    },\n    response: {\n      200: Type.Array(Todo)\n    }\n  }\n})\n```\n\n### Type-safety on the client side\n\nWith this library, you can also type the request and response on the client side. But you have two\noptions;\n\n1. You can infer the types from the router itself by using `createRouterSDK` from this library.\n2. You can use OpenAPI client package that infers the types from the given OpenAPI document.\n\n#### Using `createRouterSDK`\n\n```ts file=examples/client.ts\nimport { createRouterSDK } from '@whatwg-node/router'\n// Notice `type` in the import to avoid to import it on runtime\nimport type { router } from '../router'\n\nconst sdk = createRouterSDK<typeof router>({\n  endpoint: 'http://localhost:3000'\n})\n\n// Everything below is fully typed\nconst response = await sdk['/todo'].put({\n  json: {\n    title: 'Buy milk',\n    completed: false\n  }\n})\nconst responseJson = await response.json()\nconsole.table(responseJson)\n```\n\n#### Using OpenAPI Client\n\nYou need to save the OpenAPI document to a code file like below;\n\n```ts\nexport default { openapi: '3.0.1' /* ... */ }\n```\n\nThen you need to import the OpenAPI document to the client code;\n\n```ts file=examples/client.ts\nimport { createOASClient, Mutable } from '@whatwg-node/oas-client'\n// Notice `type` in the import to avoid to import it on runtime\nimport type oas from './saved_openapi'\n\nconst client = createOASClient<Mutable<typeof oas>>({\n  endpoint: 'http://localhost:3000'\n})\n\n// Everything below is fully typed\nconst response = await client['/todo'].put({\n  json: {\n    title: 'Buy milk',\n    completed: false\n  }\n})\nconst responseJson = await response.json()\nconsole.table(responseJson)\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"89a0314bd2a85200a2bd925a189931c1020eb2ba","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.5.0","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.2","dependencies":{"tslib":"^2.3.1","openapi-types":"12.1.0","json-schema-to-ts":"2.6.2","@whatwg-node/fetch":"0.8.2-alpha-20230301233255-89a0314","@whatwg-node/server":"0.7.2-alpha-20230301233255-89a0314","@whatwg-node/typed-fetch":"0.0.1-alpha-20230301233255-89a0314"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.4.0-alpha-20230301233255-89a0314_1677713597781_0.9417505563953048","host":"s3://npm-registry-packages"}},"0.4.0-alpha-20230302054248-5bb7838":{"name":"@whatwg-node/router","version":"0.4.0-alpha-20230302054248-5bb7838","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.4.0-alpha-20230302054248-5bb7838","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"141bd851d0062ad8d851cddadd85321213561185","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.4.0-alpha-20230302054248-5bb7838.tgz","fileCount":7,"integrity":"sha512-lm7gbveq8NuJREZ8AQyaaOHXyMkGWMP6B/k5MMqLKpvRJx6JxcIlJjGUNOLCiwVJFd9Z+ssX+GQyoBMRk9J2Fg==","signatures":[{"sig":"MEUCIQD0A69gDXVFzOvOve3pZHvbOQ5jHCaB20dneOKPftuU3QIgCTTIsWykz6ChStyGnhshfdx/H+gxD9KLTBPdojlPcTo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19308,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkADdoACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmp5jA//eqmDXF0QVDmIjNW211gi9cHQRbZuwEO1Goi+4fHJ0nlDmnAU\r\nsvrvrUkM5YJt9WycW/1FLMQ9100ztTp0smrUrstnicmLMmrM3ddLllKit3Qd\r\nmFiJkGIUkQD3uRw5F9izwcvxJUV2Zvpuw7hcbUDUM8JKtlwBQUMo/fOaH3l2\r\n4Y3tJvl+tEwHmb2XMX/bRi+364Y2kqS373ulmpbdlwWSCQ4KgjO3C5yT3eoC\r\nDTd8lNh56nKKoSR3qOkTHCqOg1C0UAlTsmPZgbhd0FAjU8OI/bVBSJEiSM/d\r\nZT4COoEiCSBFmJeTyWkgjTEGeOpgxSOdB1kPKvu+duZPUOCCUgbR/oIjKeKe\r\n6zT9wjEZlaHx98a59LEQ0U/K6hOF1YGjxZpTe7UdQ6OniIF1MqOZSZ5Lw9tw\r\n4vDU9nRp4wgw2FGSQq0RVYnWAifMZNtSio8V1xZ4KacpKL5B/nAc65qd8ZHk\r\nseQp2SYMScMVxJCt95h6ngVhSWWHU92YuXpvi930/b12xOH3AjyfEgtY1MUG\r\nQqO96a0x83NhyAwlxTXqcj7NncVLuCCPF93a9w7GTJ9Y1hz4UWtcOAMhy8EK\r\n65IVpHdvL8RLh6QHReTQBPMaDMl5/BpGKZb5zl5Vlrsb3ZG6xUySLA/CVtg2\r\nAt72uOlk9bUSJ/RyFZxWq0d/t3LJxBIsXjM=\r\n=EE9c\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"5bb78381645a2b691891339b949fb9fdc53bdfd6","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.3.1","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.1","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"^0.8.0","@whatwg-node/server":"^0.7.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.4.0-alpha-20230302054248-5bb7838_1677735784021_0.24851762400980948","host":"s3://npm-registry-packages"}},"0.4.0-alpha-20230302123908-6a2d38f":{"name":"@whatwg-node/router","version":"0.4.0-alpha-20230302123908-6a2d38f","author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","_id":"@whatwg-node/router@0.4.0-alpha-20230302123908-6a2d38f","maintainers":[{"name":"ardatan","email":"ardatanrikulu@gmail.com"}],"homepage":"https://github.com/ardatan/whatwg-node#readme","bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"dist":{"shasum":"43e64ba9da35bc19a7ea0c97c3af986e379b3087","tarball":"https://registry.npmjs.org/@whatwg-node/router/-/router-0.4.0-alpha-20230302123908-6a2d38f.tgz","fileCount":7,"integrity":"sha512-/7/D8PCUrismozw3GLauh/wDul4PeNR7Y47XMNST3jqKSlrJFSdGv+xn5CyimORVFHXC21+E9RYni1c4JMInWw==","signatures":[{"sig":"MEQCIA9JBu9wYealBuH9wxE9q8t74Kz86/4rJnicRaBowvcbAiBm9c0ElzMP5tbzqQmb/ASBiiRCWvcE2L/rZf6AvwbErg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19308,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkAJj+ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrODxAAonEvBWFs6KQClBFwmNbkxg3mF0VSsgMDYf4XCroWq0WC/hQK\r\n6AhvNrtqVmvPFwKCJ6xxHbpr00NpSVPt/F70AekZcCrsXzXTnFcr8WIDtssS\r\nAJHc23Eo22AofYOJsQYnDl1G0NLGG2h8oVEmUaB5xCtvo0qj5S4SPQf7YeS/\r\n4v3V9mPQoWKqRPN6+353/DiPnaiW1Ja1yWnDM0t5pubDHh4K0NxrxmLmVJrO\r\nUX62t460b7n5+Pm8lTiI978eSO2kwrx7NEO4tgHVk9IVAUBqzJkBa4KnHXPf\r\nXRy2vTf8lCs1So966zDAWebAn115L1g9Q3rqyjgu/Et3GZ48qG1Ri1siD5p9\r\nhpjUBQ64DUve34LrhRWeisa9kMx4cQPVZLAOcvhMavlOC46X3HfdjfQnl8ik\r\nf/HNkt2ZzJoagjwQYx/XnArsgcfHho5PisYWhNkru+7x2rbM9LiIGrVXQ8gq\r\n7gtN1Ccj9CYPsSYyLVJGsc0Xu543G7u/r+kGlTIo9KPtvZ7pr8h2Wv2sylSl\r\nbeQSlCxc0bqVjdjXg3toOX8uf00DX1pxa2M2528Rj/lJ9YoC9JjKS10rN+aU\r\n6s97GVaoCDhzvyhYyzZBwF1wlQAVFOS4sPENFNOVb8J4IsqaKBhriMQanjmO\r\nwJqhtuNabK5QYKpu0FPQLqPrvvGT6gM0Cmg=\r\n=Z6kP\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","module":"index.mjs","readme":"# Platform agnostic JavaScript HTTP Router\n\n[![npm version](https://badge.fury.io/js/%40whatwg-node%2Frouter.svg)](https://badge.fury.io/js/%40whatwg-node%2Frouter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`@whatwg-node/router` is a package that allows you to create modern JavaScript HTTP router with the\nWHATWG Fetch API that works in any JavaScript environment including Node.js, Deno, Bun, Cloudflare\nWorkers, Next.js, Fastify, Express, AWS Lambdas and even in browsers.\n\n## Installation\n\n```bash\nyarn add @whatwg-node/router\n```\n\n## Why should I use this package instead of other packages like `itty-router`, `express` or `fastify`?\n\nThere are many packages out there that allow you to create HTTP routers, but they are not platform\nagnostic. They are only for Node.js or only for those specific environments. But if you use this\npackage, your router will work in any environment that uses JavaScript.\n\n## Usage\n\nIt follows the similar pattern to the `express` package, so basically you create a `Router` instance\nand extend it with routers by using the HTTP methods like `get`, `post`, `put`, `patch`, `delete`,\n`head` and `options`. And there is also `all` method that allows you to match all HTTP methods.\n\nThe first argument of these methods is the url pattern, and the following functions are handlers or\nmiddlewares that will be called when the request matches the pattern.\n\n> Note: The url pattern is a string that follows the\n> [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) standard. You can learn\n> more about URL patterns\n> [here](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern#matching_a_pathname).\n\n`Router` gives you an extended version of the regular `Request` object that has the following\nproperties:\n\n- `request.params`: An object that contains the parameters that are given in the url pattern.\n- `request.query`: An object that contains the query parameters that are given in the url.\n\nLet's create a basic REST API that manages users.\n\n```ts\nimport { createRouter, Response } from '@whatwg-node/router'\n\nconst router = createRouter()\n\nconst users = [\n  { id: '1', name: 'John' },\n  { id: '2', name: 'Jane' }\n]\n\nrouter.get('/users', request => Response.json(users))\n\n// Parameters are given in the `request.params` object\nrouter.get('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  return Response.json(user)\n})\n\nrouter.delete('/users/:id', request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  users.splice(users.indexOf(user), 1)\n\n  return new Response(null, {\n    status: 204\n  })\n})\n\n// Handle JSON bodies\nrouter.put('/users', async request => {\n  const body = await request.json()\n\n  const user = {\n    id: String(users.length + 1),\n    name: body.name\n  }\n\n  users.push(user)\n\n  return Response.json(user)\n})\n\n// Handle both parameters and JSON body\nrouter.post('/users/:id', async request => {\n  const user = users.find(user => user.id === request.params.id)\n\n  if (!user) {\n    return new Response(null, {\n      status: 404\n    })\n  }\n\n  const body = await request.json()\n\n  user.name = body.name\n\n  return Response.json(user)\n})\n```\n\n## Middlewares\n\nYou can also use middlewares to handle requests. Middlewares are functions that are called before\nthe request is handled by the router. You can use them to handle authentication, logging, etc.\n\nIf a handler function doesn't return a `Response` object, the request will be passed to the next\nhandler.\n\n```ts\n// In the following example, we are checking if the request has an `Authorization` header.\nrouter.all('*', request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n})\nrouter.get('/users', request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n### Handler chaining\n\nYou can also chain multiple handlers to a single route. In the following example, we are checking if\nthe request has an `Authorization` header and if the user is an admin.\n\n```ts\nimport { RouteHandler } from '@whatwg-node/router'\n\nconst withAuth: RouteHandler = request => {\n  if (!request.headers.get('Authorization')) {\n    return new Response(null, {\n      status: 401\n    })\n  }\n}\n\nrouter.get('/users', withAuth, request => {\n  // It doesn't reach here if the request doesn't have an `Authorization` header.\n})\n```\n\n## Error handling\n\nIf an unexpected error is thrown, the response will have a `500` status code. You can use the\n`try/catch` method to handle errors.\n\n```ts\nrouter.get('/users', request => {\n  try {\n    // Do something\n  } catch (error) {\n    return new Response('I handled the error gracefully', {\n      status: 500\n    })\n  }\n})\n```\n\n## Usage in environments\n\n`Router` is actually an instance of `ServerAdapter` of `@whatwg-node/server` package. So you can use\nit in any environment just like `ServerAdapter`. See the [documentation](../server/README.md) of\n`@whatwg-node/server` package for more information.\n","exports":{".":{"import":"./index.mjs","require":"./index.js"},"./*":{"import":"./*.mjs","require":"./*.js"},"./package.json":"./package.json"},"gitHead":"6a2d38fe76be0170a8e7b9df9b0ad310f8e5d5a4","typings":"index.d.ts","_npmUser":{"name":"ardatan","email":"ardatanrikulu@gmail.com"},"repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"typescript":{"definition":"index.d.ts"},"_npmVersion":"9.5.0","description":"Fetch API compliant HTTP Router","directories":{},"sideEffects":false,"_nodeVersion":"18.14.2","dependencies":{"tslib":"^2.3.1","@whatwg-node/fetch":"^0.8.0","@whatwg-node/server":"^0.7.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.4.0-alpha-20230302123908-6a2d38f_1677760766085_0.16105524246082825","host":"s3://npm-registry-packages"}}},"time":{"created":"2022-12-20T10:15:46.635Z","modified":"2025-03-19T08:59:00.981Z","0.0.1-alpha-20221220101531-15f683b":"2022-12-20T10:15:46.896Z","0.0.1-alpha-20221220104236-d3ce2f8":"2022-12-20T10:42:49.584Z","0.0.1-alpha-20221220105110-a226647":"2022-12-20T10:51:23.498Z","0.0.1-alpha-20221220120052-cd1457c":"2022-12-20T12:01:07.927Z","0.0.1-alpha-20221220143426-2744af4":"2022-12-20T14:34:43.872Z","0.0.1-alpha-20221220144402-dce2fb1":"2022-12-20T14:44:16.008Z","0.0.1-alpha-20221220145232-524e5a0":"2022-12-20T14:52:48.708Z","0.0.1-alpha-20221221152949-1840032":"2022-12-21T15:30:02.178Z","0.0.1-alpha-20221221153028-3a6ed6e":"2022-12-21T15:30:44.808Z","0.0.1-alpha-20221221160202-c5565ed":"2022-12-21T16:02:17.255Z","0.0.1-alpha-20221225150206-ee1c0c8":"2022-12-25T15:02:20.567Z","0.0.1-alpha-20221225150335-6bbf958":"2022-12-25T15:03:47.932Z","0.0.1-alpha-20221225155445-dfcb269":"2022-12-25T15:54:57.918Z","0.0.1-alpha-20221225155816-6b54cb4":"2022-12-25T15:58:30.878Z","0.0.1-alpha-20221225160212-6d4b104":"2022-12-25T16:02:25.829Z","0.0.1-alpha-20221225160313-0935cfd":"2022-12-25T16:03:31.683Z","0.0.1-alpha-20221225172458-8684a84":"2022-12-25T17:25:12.515Z","0.0.1-alpha-20221225173053-f9310f6":"2022-12-25T17:31:08.114Z","0.0.1-alpha-20221225175918-b8ec28d":"2022-12-25T17:59:32.012Z","0.0.1-alpha-20221225203520-794aee0":"2022-12-25T20:35:32.967Z","0.0.1-alpha-20221225210907-6de9f3a":"2022-12-25T21:09:20.306Z","0.0.1":"2022-12-26T07:20:36.472Z","0.0.2-alpha-20221226093125-61200ea":"2022-12-26T09:31:38.501Z","0.0.2":"2022-12-26T09:38:08.265Z","0.0.3-alpha-20221226141545-8392bc6":"2022-12-26T14:16:01.229Z","0.0.3-alpha-20221228080239-7c1fd2a":"2022-12-28T08:02:52.723Z","0.0.3-alpha-20221228080444-fb2baa0":"2022-12-28T08:05:01.674Z","0.0.3-alpha-20221228081333-b271a45":"2022-12-28T08:13:48.716Z","0.0.3-alpha-20221228081805-75e6dc7":"2022-12-28T08:18:22.904Z","0.0.3-alpha-20221228082016-9ef2266":"2022-12-28T08:20:30.845Z","0.0.3-alpha-20221228083733-4041c71":"2022-12-28T08:37:48.868Z","0.0.3-alpha-20221228110205-1d6dcac":"2022-12-28T11:02:23.533Z","0.0.3-alpha-20221228110541-2aa6aea":"2022-12-28T11:05:55.348Z","0.0.3-alpha-20221228115139-6b81aa1":"2022-12-28T11:51:56.380Z","0.0.3-alpha-20221228172034-08ac509":"2022-12-28T17:20:46.479Z","0.0.3-alpha-20221228193325-21c8f71":"2022-12-28T19:33:39.622Z","0.0.3-alpha-20221228193327-daecf41":"2022-12-28T19:33:40.508Z","0.0.3-alpha-20221229225529-0521d37":"2022-12-29T22:55:41.671Z","0.0.3-alpha-20221229234839-9347e41":"2022-12-29T23:48:53.015Z","0.0.3-alpha-20221230002545-d84fa28":"2022-12-30T00:25:57.071Z","0.0.3-alpha-20221230002610-34d2b2e":"2022-12-30T00:26:27.193Z","0.0.3-alpha-20221230002923-0c64426":"2022-12-30T00:29:36.371Z","0.0.3-alpha-20221230003229-556f2f2":"2022-12-30T00:32:43.240Z","0.0.3-alpha-20221230012104-11e4902":"2022-12-30T01:21:21.111Z","0.0.3":"2022-12-30T01:23:13.893Z","0.0.4-alpha-20221230075257-cc3a93b":"2022-12-30T07:53:14.767Z","0.0.4-alpha-20221230080146-72104f6":"2022-12-30T08:02:01.306Z","0.0.4-alpha-20221230080207-dec357b":"2022-12-30T08:02:25.103Z","0.0.4-alpha-20221230081647-5963234":"2022-12-30T08:17:02.869Z","0.0.4-alpha-20221230091810-6546310":"2022-12-30T09:18:26.305Z","0.1.0-alpha-20230102083143-994de43":"2023-01-02T08:31:56.153Z","0.1.0-alpha-20230102083740-9f85a58":"2023-01-02T08:37:54.644Z","0.1.0-alpha-20230102083950-79c2f3c":"2023-01-02T08:40:04.100Z","0.1.0-alpha-20230102085949-c0d9fb6":"2023-01-02T09:00:04.682Z","0.1.0-alpha-20230102090155-ca7176e":"2023-01-02T09:02:10.891Z","0.1.0-alpha-20230102090436-0e536cc":"2023-01-02T09:04:51.756Z","0.1.0-alpha-20230102091529-d9879f9":"2023-01-02T09:15:45.449Z","0.1.0-alpha-20230102092103-b37f339":"2023-01-02T09:21:17.082Z","0.1.0-alpha-20230102092905-2ddada0":"2023-01-02T09:29:19.133Z","0.1.0-alpha-20230102093209-0e66e12":"2023-01-02T09:32:21.810Z","0.1.0-alpha-20230102093752-e4b70f6":"2023-01-02T09:38:05.076Z","0.1.0-alpha-20230102094215-153dd37":"2023-01-02T09:42:31.668Z","0.1.0-alpha-20230102094417-14e45e1":"2023-01-02T09:44:31.498Z","0.1.0":"2023-01-02T09:45:35.426Z","0.1.1":"2023-01-02T10:22:33.096Z","0.1.2-alpha-20230102102521-2e7c4e5":"2023-01-02T10:25:36.750Z","0.1.2-alpha-20230102112342-8d6524e":"2023-01-02T11:23:54.944Z","0.1.2-alpha-20230102114041-59cec65":"2023-01-02T11:40:56.214Z","0.1.2-alpha-20230102114250-2497755":"2023-01-02T11:43:05.958Z","0.1.2-alpha-20230102191116-e4ff740":"2023-01-02T19:11:30.309Z","0.1.2-alpha-20230102191119-d592bf7":"2023-01-02T19:11:32.422Z","0.1.2":"2023-01-02T19:18:23.690Z","0.1.3":"2023-01-03T11:07:03.714Z","0.1.4-alpha-20230109165738-8edf269":"2023-01-09T16:57:57.477Z","0.1.4-alpha-20230111213850-946da63":"2023-01-11T21:39:04.188Z","0.1.4-alpha-20230111220448-f74dc45":"2023-01-11T22:05:04.839Z","0.1.4":"2023-01-11T23:40:04.774Z","0.1.5-alpha-20230117081522-969e299":"2023-01-17T08:15:36.633Z","0.1.5-alpha-20230117084928-a052439":"2023-01-17T08:49:42.130Z","0.1.5-alpha-20230117095738-14df726":"2023-01-17T09:57:51.866Z","0.1.5-alpha-20230117102027-734f015":"2023-01-17T10:20:46.337Z","0.1.5-alpha-20230117102108-86636f9":"2023-01-17T10:21:22.078Z","0.1.5-alpha-20230117102822-72dd4dc":"2023-01-17T10:28:35.579Z","0.1.5-alpha-20230117103221-bf2adb0":"2023-01-17T10:32:37.796Z","0.1.5-alpha-20230118095720-6a2d2f0":"2023-01-18T09:57:37.632Z","0.1.5-alpha-20230120130300-bc9d705":"2023-01-20T13:03:12.381Z","0.1.5-alpha-20230120130512-94ff6e7":"2023-01-20T13:05:25.652Z","0.1.5":"2023-01-20T13:07:54.613Z","0.1.6":"2023-01-23T16:48:52.751Z","0.1.7":"2023-01-23T19:32:34.689Z","0.1.8-alpha-20230126122734-e16acbb":"2023-01-26T12:27:49.222Z","0.1.8-alpha-20230126122900-db01245":"2023-01-26T12:29:18.829Z","0.1.8-alpha-20230130162825-1e02017":"2023-01-30T16:28:40.998Z","0.1.8-alpha-20230130163402-dac6604":"2023-01-30T16:34:24.158Z","0.1.8":"2023-01-30T16:46:28.595Z","0.1.9":"2023-01-30T18:03:13.952Z","0.1.10":"2023-01-30T18:17:16.978Z","0.1.11-alpha-20230202080931-398001d":"2023-02-02T08:09:50.170Z","0.1.11-alpha-20230202081836-d7810ac":"2023-02-02T08:18:52.048Z","0.1.11-alpha-20230202081906-5436414":"2023-02-02T08:19:21.977Z","0.1.11-alpha-20230202120346-11ebc77":"2023-02-02T12:04:03.561Z","0.1.11-alpha-20230202120635-b6521c4":"2023-02-02T12:06:52.955Z","0.1.11-alpha-20230202121242-e83ff5f":"2023-02-02T12:12:57.757Z","0.1.11-alpha-20230202123533-cd68953":"2023-02-02T12:35:50.362Z","0.1.11-alpha-20230202123956-d8daaf7":"2023-02-02T12:40:11.078Z","0.1.11-alpha-20230202125441-e9e7afb":"2023-02-02T12:54:55.511Z","0.1.11-alpha-20230202125732-7b89867":"2023-02-02T12:57:46.856Z","0.1.11-alpha-20230202184428-e0c4cca":"2023-02-02T18:44:47.916Z","0.1.11-alpha-20230202184911-724f9bd":"2023-02-02T18:49:31.428Z","0.1.11-alpha-20230202185216-2aa5539":"2023-02-02T18:52:34.892Z","0.1.11-alpha-20230202185231-82dd436":"2023-02-02T18:52:45.197Z","0.1.11-alpha-20230202185611-a55ab16":"2023-02-02T18:56:27.345Z","0.1.11-alpha-20230202192735-c9da64f":"2023-02-02T19:27:50.793Z","0.2.0":"2023-02-03T11:36:14.798Z","0.2.1":"2023-02-03T12:04:43.311Z","0.2.2-alpha-20230203144149-868d6ff":"2023-02-03T14:42:03.200Z","0.2.2":"2023-02-03T15:00:43.994Z","0.2.3-alpha-20230205160101-d3a1033":"2023-02-05T16:01:15.607Z","0.2.3-alpha-20230205160326-cd8fd84":"2023-02-05T16:03:42.385Z","0.2.3-alpha-20230205160404-daaf017":"2023-02-05T16:04:19.971Z","0.2.3-alpha-20230205160723-6e9b185":"2023-02-05T16:07:36.869Z","0.2.3":"2023-02-05T16:26:47.116Z","0.2.4":"2023-02-06T12:27:09.800Z","0.2.5-alpha-20230206135508-d9b0cd5":"2023-02-06T13:55:23.109Z","0.2.5-alpha-20230206135558-1370a81":"2023-02-06T13:56:13.384Z","0.2.5":"2023-02-06T14:06:45.157Z","0.2.6-alpha-20230207093208-c16434f":"2023-02-07T09:32:26.927Z","0.2.6-alpha-20230207093213-131f46f":"2023-02-07T09:32:31.412Z","0.2.6-alpha-20230207100807-5eb50c6":"2023-02-07T10:08:21.475Z","0.2.6-alpha-20230207114030-349e836":"2023-02-07T11:40:44.939Z","0.2.6":"2023-02-07T11:52:52.887Z","0.2.7-alpha-20230210093840-06aaaf0":"2023-02-10T09:38:55.842Z","0.2.7-alpha-20230210095043-408a558":"2023-02-10T09:51:00.520Z","0.2.7-alpha-20230210105523-366e74c":"2023-02-10T10:55:38.875Z","0.2.7":"2023-02-10T11:07:08.450Z","0.3.0-alpha-20230215085115-d099e0b":"2023-02-15T08:51:43.342Z","0.3.0-alpha-20230215085143-56e6bef":"2023-02-15T08:52:07.441Z","0.3.0-alpha-20230215085620-3393c60":"2023-02-15T08:56:44.077Z","0.3.0-alpha-20230215090500-a3d0322":"2023-02-15T09:05:25.290Z","0.3.0-alpha-20230221104542-ee6a58b":"2023-02-21T10:46:01.603Z","0.3.0-alpha-20230221104701-9322aaf":"2023-02-21T10:47:16.339Z","0.3.0-alpha-20230221105155-000d664":"2023-02-21T10:52:09.797Z","0.3.0-alpha-20230221105718-142b959":"2023-02-21T10:57:35.656Z","0.3.0-alpha-20230221105958-43ce377":"2023-02-21T11:00:15.443Z","0.3.0-rc-20230221114448-01b38cd":"2023-02-21T11:45:02.651Z","0.3.0-alpha-20230221114745-06568a3":"2023-02-21T11:48:06.185Z","0.3.0-alpha-20230221115149-9b16d88":"2023-02-21T11:52:06.324Z","0.3.0-rc-20230221115504-d14aa5a":"2023-02-21T11:55:18.507Z","0.3.0-rc-20230221120256-dec7b50":"2023-02-21T12:03:10.295Z","0.3.0-rc-20230221120455-b9ab400":"2023-02-21T12:05:11.703Z","0.3.1-rc-20230221120759-2a26ab6":"2023-02-21T12:08:14.289Z","0.3.0":"2023-02-21T12:10:08.276Z","0.4.0-alpha-20230222104450-ef9edfd":"2023-02-22T10:45:04.648Z","0.4.0-alpha-20230222104536-27888c7":"2023-02-22T10:46:01.188Z","0.4.0-alpha-20230222122711-75f542a":"2023-02-22T12:27:26.281Z","0.4.0-alpha-20230222122922-afb98ac":"2023-02-22T12:29:37.296Z","0.4.0-rc-20230222123132-90e12ec":"2023-02-22T12:31:47.638Z","0.4.0-alpha-20230222123356-1c93bff":"2023-02-22T12:34:13.483Z","0.4.0-alpha-20230222134347-496b85e":"2023-02-22T13:44:03.833Z","0.4.0-alpha-20230222165405-b7f3333":"2023-02-22T16:54:23.909Z","0.4.0-alpha-20230222172456-a1adb6d":"2023-02-22T17:25:13.018Z","0.4.0-alpha-20230222174610-1d1aaed":"2023-02-22T17:46:27.685Z","0.4.0-alpha-20230222180513-791bc09":"2023-02-22T18:05:35.292Z","0.4.0-alpha-20230223104455-93c17a9":"2023-02-23T10:45:14.504Z","0.4.0-alpha-20230223105049-e2a7bfd":"2023-02-23T10:51:08.708Z","0.4.0-alpha-20230223141917-77f3e42":"2023-02-23T14:19:47.066Z","0.4.0-alpha-20230223143304-9f436b0":"2023-02-23T14:33:29.226Z","0.4.0-alpha-20230223162156-200d60c":"2023-02-23T16:22:15.033Z","0.4.0-alpha-20230223202135-67801d4":"2023-02-23T20:21:49.630Z","0.4.0-rc-20230223204558-baafc65":"2023-02-23T20:46:13.077Z","0.4.0-alpha-20230224012919-d66ad8a":"2023-02-24T01:29:33.859Z","0.4.0-alpha-20230224053228-01ba7b6":"2023-02-24T05:32:44.573Z","0.4.0-rc-20230224053308-85b327d":"2023-02-24T05:33:23.952Z","0.4.0-rc-20230224070404-60c7fd4":"2023-02-24T07:04:21.590Z","0.4.0-alpha-20230224121407-a1be8e1":"2023-02-24T12:14:32.441Z","0.4.0-alpha-20230224123711-eff8ac3":"2023-02-24T12:37:33.148Z","0.4.0-alpha-20230224130759-d51f621":"2023-02-24T13:08:19.616Z","0.4.0-alpha-20230224143204-f98eefc":"2023-02-24T14:32:29.968Z","0.4.0-alpha-20230224183853-237400d":"2023-02-24T18:39:13.807Z","0.4.0-alpha-20230225004247-e22aa7d":"2023-02-25T00:43:03.065Z","0.4.0-rc-20230225042529-7d928b3":"2023-02-25T04:25:48.147Z","0.4.0-alpha-20230226114644-367e082":"2023-02-26T11:46:59.507Z","0.4.0-rc-20230226150216-7ac4f5e":"2023-02-26T15:02:31.148Z","0.4.0-alpha-20230226233400-388f8e3":"2023-02-26T23:34:14.886Z","0.4.0-rc-20230227023116-6f97cb1":"2023-02-27T02:31:32.875Z","0.4.0-alpha-20230227130032-9550f6c":"2023-02-27T13:00:53.584Z","0.4.0-alpha-20230227130053-a2fb518":"2023-02-27T13:01:14.865Z","0.4.0-alpha-20230227131024-08db2e7":"2023-02-27T13:10:47.210Z","0.4.0-alpha-20230227152152-ebc4f40":"2023-02-27T15:22:10.710Z","0.4.0-alpha-20230227154338-576087f":"2023-02-27T15:43:58.968Z","0.4.0-alpha-20230227195238-be99321":"2023-02-27T19:52:53.322Z","0.4.0-alpha-20230227223133-11ddf9d":"2023-02-27T22:31:47.633Z","0.4.0-rc-20230227223359-a88acf2":"2023-02-27T22:34:17.193Z","0.4.0-alpha-20230228084440-36a394c":"2023-02-28T08:45:02.402Z","0.4.0-alpha-20230228090751-8c97448":"2023-02-28T09:08:12.047Z","0.4.0-rc-20230228100653-a986914":"2023-02-28T10:07:09.289Z","0.4.0-alpha-20230228121813-6a22ee6":"2023-02-28T12:18:32.813Z","0.4.0-alpha-20230228123813-b78e09d":"2023-02-28T12:38:37.231Z","0.4.0-alpha-20230228124206-1e319de":"2023-02-28T12:42:28.296Z","0.4.0-alpha-20230228151748-5c26743":"2023-02-28T15:18:10.692Z","0.4.0-alpha-20230228152145-fde8c53":"2023-02-28T15:22:09.988Z","0.4.0-alpha-20230228153302-5b1cd55":"2023-02-28T15:33:22.436Z","0.4.0-alpha-20230228160609-08baffb":"2023-02-28T16:06:29.410Z","0.4.0-alpha-20230228164431-66d6bec":"2023-02-28T16:44:53.884Z","0.4.0-alpha-20230301045639-3f96977":"2023-03-01T04:56:55.104Z","0.4.0-rc-20230301090452-7e2e4ed":"2023-03-01T09:05:07.198Z","0.4.0-alpha-20230301133541-9e26be0":"2023-03-01T13:35:56.536Z","0.4.0-alpha-20230301144304-75f91ef":"2023-03-01T14:43:28.908Z","0.4.0-alpha-20230301144841-a76d283":"2023-03-01T14:49:06.345Z","0.4.0-rc-20230301165834-79d3ff1":"2023-03-01T16:58:47.969Z","0.4.0-alpha-20230301191323-b3ac93c":"2023-03-01T19:13:48.384Z","0.4.0-alpha-20230301221441-4270d93":"2023-03-01T22:15:06.034Z","0.4.0-alpha-20230301224056-1a47c50":"2023-03-01T22:41:22.120Z","0.4.0-alpha-20230301233255-89a0314":"2023-03-01T23:33:17.943Z","0.4.0-alpha-20230302054248-5bb7838":"2023-03-02T05:43:04.175Z","0.4.0-alpha-20230302123908-6a2d38f":"2023-03-02T12:39:26.302Z"},"bugs":{"url":"https://github.com/ardatan/whatwg-node/issues"},"author":{"name":"Arda TANRIKULU","email":"ardatanrikulu@gmail.com"},"license":"MIT","homepage":"https://github.com/ardatan/whatwg-node#readme","repository":{"url":"git+https://github.com/ardatan/whatwg-node.git","type":"git","directory":"packages/router"},"description":"Fetch API compliant HTTP Router","maintainers":[{"email":"ardatanrikulu@gmail.com","name":"ardatan"},{"email":"bot@the-guild.dev","name":"theguild-bot"}],"readme":"","readmeFilename":""}