{"_id":"@arisris/next-api-router","_rev":"16-c87dc7406d93fae3790474dcba4c0047","name":"@arisris/next-api-router","dist-tags":{"latest":"1.0.8"},"versions":{"1.0.7":{"name":"@arisris/next-api-router","version":"1.0.7","description":"Simple router for Next.js api. inspired by itty-router","main":"dist/cjs/index.js","module":"dist/mjs/index.js","types":"index.d.ts","private":false,"scripts":{"build":"rm -rf index.d.ts dist && tsc --module commonjs --outDir dist/cjs --declarationDir ./ && tsc --module es6 --outDir dist/mjs --declaration false","test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/arisris/next-api-router.git"},"keywords":["Next.js","Api","Vercel","itty-router"],"author":{"name":"Aris Riswanto"},"license":"MIT","bugs":{"url":"https://github.com/arisris/next-api-router/issues"},"homepage":"https://github.com/arisris/next-api-router#readme","devDependencies":{"next":"^12.0.1","typescript":"^4.5.4"},"gitHead":"b488e8d8aeaf4b43a56b8e8cf3e6914d304e9b07","_id":"@arisris/next-api-router@1.0.7","_nodeVersion":"16.13.1","_npmVersion":"8.1.2","dist":{"integrity":"sha512-NVrXerMWzrhdUMvmo328DvqapqWSG/1uqn699tDLlG/2dE2QpLQa0Cje4t4L6j2x6kpyKMYZwcMVXPx1QLa4sw==","shasum":"a39a5159733c051272d3b1b8ccc09a93640580d1","tarball":"https://registry.npmjs.org/@arisris/next-api-router/-/next-api-router-1.0.7.tgz","fileCount":9,"unpackedSize":30328,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh61qNCRA9TVsSAnZWagAALOcP/0nGoNNl1Xj5mXfc4Dd7\nJJhz7iqSjX+8IKgXhJuAcla8tf/O3SrjI9ONEGP5Wp2NnfPIe2dXovzYoRPk\nrbhhsJdnFJBV5SODyRaqmI/Kr/A5LTlvkioj0dmLjhDNGslGdGR8Wt5mj5bX\nZb9bt4N/n0jp8I0wRt6v94QtGLm1t0JRnEz7WyE1oDX9KtAHXiAzbo2o4be5\nNPEIKN2emwND1T6HyCxr4j/q6wN2SQGfYv1HLbElfCAb07iyC6K4+qc0jTOT\nNr1FzSUSRsE3e0bIOHfQimeDAnl54dNPnRckEjdGa8bL/DGqDD75Z2OEfbHF\neAfvvMCjYP1PkUMiOtvmXgnmd2wB9iO+aNlaBS+xPX7NSwDPfouZ4WARCkPK\nv8ZdIzwQGLD861M+mzyVmeCROvUSaHsLabdKpapmvAWtL3ItPnV6vgi7wtdZ\ng5lEqUlP5odPai9FDdGZBOk90c+MREo6bFwHgbE0rpJIkgtqZ+8B7GnENdZi\nB9ykm8KV6LKnmnDfsJ9b9aocW6xUWTj0h0ODK5qXTXYf8VkLa3PPSl+vwQUT\n1Pbj4x505jxp9H9BnYsp+TU1va+jzS8x8Sx9b+0dsIYamlx3pW6kaFiIHvFl\neFdoZnqW6k5GDnEFmnDNUiHg21Fyy8gEWAvBELdGpVNMt0oupI6guGtxBiIF\ntvZ3\r\n=2Y3w\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDMRmjIQPSVX+K31X+db4/PgGqhwENP9HBM3ZptPo0ZUgIgHAD/27hQVUoikubHaRMOyglWxp5SCSYGw66iFoY9050="}]},"_npmUser":{"name":"arisris","email":"kangazib@gmail.com"},"directories":{},"maintainers":[{"name":"arisris","email":"kangazib@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/next-api-router_1.0.7_1642814093247_0.014256949592851509"},"_hasShrinkwrap":false},"1.0.8":{"name":"@arisris/next-api-router","version":"1.0.8","description":"Simple router for Next.js api. inspired by itty-router","main":"dist/cjs/index.js","module":"dist/mjs/index.js","types":"index.d.ts","private":false,"scripts":{"build":"rm -rf index.d.ts dist && tsc --module commonjs --outDir dist/cjs --declarationDir ./ && tsc --module es6 --outDir dist/mjs --declaration false","test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/arisris/next-api-router.git"},"keywords":["Next.js","Api","Vercel","itty-router"],"author":{"name":"Aris Riswanto"},"license":"MIT","bugs":{"url":"https://github.com/arisris/next-api-router/issues"},"homepage":"https://github.com/arisris/next-api-router#readme","devDependencies":{"next":"^12.0.1","typescript":"^4.5.4"},"gitHead":"2c31ba2ed17dc40db08f0c2c5a7ff95cd1eb29b6","_id":"@arisris/next-api-router@1.0.8","_nodeVersion":"16.13.1","_npmVersion":"8.1.2","dist":{"integrity":"sha512-Q4N+FqsCj8atA6BiwVITO7EhjjWKm4RpXVUxMJIxQbrgWKJENOk8SDBIBQbpD9t9ABgGIjDXkaWCcWD/KFOQcw==","shasum":"1ec5a85999f894e1dc2b64d915a7a965e9c48a1a","tarball":"https://registry.npmjs.org/@arisris/next-api-router/-/next-api-router-1.0.8.tgz","fileCount":9,"unpackedSize":30625,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh66RwCRA9TVsSAnZWagAAZnYQAIB4UnCL2Hg6Uqf6Vfmu\nMdULsoG+rtGOlXIDb/9Mryw0Sim6gA5UiHy09bLVuUdPSXpff0a0QKjw65K/\nRV8HtHPWL1+RFVQSHJ9LEXJlBNA9Feo+m3IZ3Sr2RxIC+RvhwL1aGAaL8edB\nbiCWKXKvlEujbT7WW55wp9VmvXMYwX7YL9d09YXInZlms5If27M1C/VpM79Y\n0jUELPUH5wxS4lO9a9yhswrkDHb8yGRoPr9ce5XP1sPhj7LcpXMB7MHNUmsT\nbEF50m36h3t/YeNl3QDkPKylZEH3p9TcsrIEczhU09CReZU62Pi4t08DhzSh\nY51ftOI1Ybu492rZ0psKZ/cI30zyK/JLItQuiRcWCiWOXPcwmiTgGEC4FauR\nyOKVWEfWSWFm3lPhx6v+JFhTS153UadiOtaYB3whSJ0dwsgduTqFWSTtRC70\nYSAr1tMA+Tf3uNbEEJrB7cLTcJPfFfn6tlTG5yVPHSVEYQfFeYCqsJxz/EzX\nwXAr1pjWK3nP03bmI2Q9O65h3xcXtmLJqbwpUSiItH2HJ12g8+T7nz+nv8o0\nR91iM8PV/kSYlZjH+eYaWIuU6Gqh//g1EIDv5djc2MRx+YyfBjF3CY4QYsSt\nAs3dFPGjAPXLhJYgCquU6CW9zNO8Kh1FwxBUj7lg6mByakBDE59lkc7gFL47\nHyHA\r\n=nPgW\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBgYH5LzVimsjRfoBTni/4aiV868xu0wtBUW8Nb+3ohjAiAtHOWWjp+IMCw5aWjHM2JJBAcYpWAcjC2ga5C8EVqTtQ=="}]},"_npmUser":{"name":"arisris","email":"kangazib@gmail.com"},"directories":{},"maintainers":[{"name":"arisris","email":"kangazib@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/next-api-router_1.0.8_1642833008065_0.9261090267888545"},"_hasShrinkwrap":false}},"time":{"created":"2022-01-21T02:31:50.604Z","1.0.0":"2022-01-21T02:31:50.831Z","modified":"2022-04-04T15:27:51.676Z","1.0.1":"2022-01-21T02:36:21.063Z","1.0.2":"2022-01-21T02:39:28.981Z","1.0.3":"2022-01-21T02:49:17.445Z","1.0.4":"2022-01-21T03:35:21.943Z","1.0.5":"2022-01-21T15:06:54.310Z","1.0.6":"2022-01-22T00:42:30.913Z","1.0.7":"2022-01-22T01:14:53.497Z","1.0.8":"2022-01-22T06:30:08.239Z"},"maintainers":[{"name":"arisris","email":"kangazib@gmail.com"}],"description":"Simple router for Next.js api. inspired by itty-router","homepage":"https://github.com/arisris/next-api-router#readme","keywords":["Next.js","Api","Vercel","itty-router"],"repository":{"type":"git","url":"git+https://github.com/arisris/next-api-router.git"},"author":{"name":"Aris Riswanto"},"bugs":{"url":"https://github.com/arisris/next-api-router/issues"},"license":"MIT","readme":"## Next.js Api Router\n\nA chainable router designed for Next.js api. inspired and regex based from itty-router\n\n### Features\n\n- [x] Tiny ([~8xx bytes](https://bundlephobia.com/package/@arisris/next-api-router) compressed) with zero dependencies.\n- [x] Strong typing with typescript also javascript with VSCode\n- [x] Anything is async/await handler\n- [x] Route params, with wildcards and optionals (e.g. `/base/:collection/:id?`)\n- [x] Middleware support\n- [x] By default error handler response is json\n- [x] Support anything of HTTP methods\n- [x] Chainable route declarations\n- [x] No dependencies\n\n### Installation\n\n```bash\nnpm i @arisris/next-api-router\n```\n\n### Example Usage\n\n```typescript\n// file: pages/api/[...any].ts\nimport NextApiRoute from \"@arisris/next-api-router\";\n\nexport default NextApiRoute({\n  key: \"all\", // a rest params default to \"any\"\n  timeout: 5000, // timeout in ms default to 10000ms\n  //onError: (error, req, res) => res.status(500).send(\"Internal Server Error\") // By default handled with json response\n})\n  .all(\"*\", async () => true) // middleware should return true\n  .get(\"/hello\", async (_, res) => res.send(\"Hello World\")) // simple\n  .get(\n    \"/wait\",\n    async () => await new Promise((resolve) => setTimeout(resolve, 3000)), // wait for 3000ms\n    async (_, res) => res.json({ msg: \"Done...\" })\n  )\n  .get(\"/error\", async () => {\n    throw new Error(\"OMG!\");\n  })\n  .get(\"/timeout\", async () => {\n    // No response is considered timeout\n  })\n  .get(\"/user/:name?\", async (req, res) => res.json({ params: req.params }))\n  // not found\n  .all(\"*\", async (_, res) => res.status(404).send(\"Not Found\"))\n  .handle; // Final handler of NextApiHandler\n```\n\n### Todo better documentation\n\n--\n\n### Links\n\n[My Website](https://arisris.com/)\n[itty-router](https://github.com/kwhitley/itty-router)\n","readmeFilename":"README.md"}