{"_id":"@any-router/core","_rev":"3-443b54435e90a292cc0c90cac38501a3","name":"@any-router/core","dist-tags":{"latest":"0.0.3"},"versions":{"0.0.1":{"name":"@any-router/core","version":"0.0.1","keywords":["router","route","path"],"author":{"name":"kgroat","email":"apps@kgroat.dev"},"license":"BSD-2-Clause","_id":"@any-router/core@0.0.1","maintainers":[{"name":"kgroat","email":"apps@kgroat.dev"}],"homepage":"https://github.com/kgroat/Route-Anything#readme","bugs":{"url":"https://github.com/kgroat/Route-Anything/issues"},"dist":{"shasum":"7b7431a9ce9a8a132c331d2e198db4bc97a3bb02","tarball":"https://registry.npmjs.org/@any-router/core/-/core-0.0.1.tgz","fileCount":14,"integrity":"sha512-DlfERe1L4yk0QusfYH770KiW8yG3surPvNvTRzb0DU20k4JHIzMxJv7NGaZM22v7CAI5mzWrCnr1B3qw75He7A==","signatures":[{"sig":"MEQCIAo+aEYRrDT1NOQyeZdstKTt3w+mgJ4JHb4Vy9MZ2UruAiBMBvOROPuCh/H8wAmlMt8a/C+oBcXz8S5Vt+1njZh0cw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":24052},"main":"dist/index.js","type":"module","types":"./dist/index.d.ts","exports":{".":"./dist/index.js","./*":"./dist/"},"gitHead":"8f1228a5d6cd129aef79ce7abb14de2ef2dab771","scripts":{"test":"npm run test:types && npm run test:unit","build":"tsc","clean":"rm -rf dist","prepack":"npm run clean && npm run build","test:unit":"vitest run","test:types":"tsc -p tests/tsconfig.json"},"_npmUser":{"name":"kgroat","email":"apps@kgroat.dev"},"repository":{"url":"git+https://github.com/kgroat/Route-Anything.git","type":"git"},"_npmVersion":"10.9.2","description":"A powerful but minimal router","directories":{},"_nodeVersion":"22.14.0","_hasShrinkwrap":false,"devDependencies":{"zod":"^3.24.4","vite":"^6.3.5","vitest":"^3.1.3","prettier":"^3.5.3","typescript":"^5.8.3","@vitest/coverage-v8":"^3.1.3","vite-tsconfig-paths":"^5.1.4","@type-challenges/utils":"^0.1.1"},"peerDependencies":{"zod":"^3.0.0"},"_npmOperationalInternal":{"tmp":"tmp/core_0.0.1_1746648982152_0.13190447262429394","host":"s3://npm-registry-packages-npm-production"}},"0.0.2":{"name":"@any-router/core","version":"0.0.2","keywords":["router","route","path"],"author":{"name":"kgroat","email":"apps@kgroat.dev"},"license":"BSD-2-Clause","_id":"@any-router/core@0.0.2","maintainers":[{"name":"kgroat","email":"apps@kgroat.dev"}],"homepage":"https://github.com/kgroat/Route-Anything#readme","bugs":{"url":"https://github.com/kgroat/Route-Anything/issues"},"dist":{"shasum":"efa34b6829a7694fc257bce66de8e0f61360f267","tarball":"https://registry.npmjs.org/@any-router/core/-/core-0.0.2.tgz","fileCount":125,"integrity":"sha512-C7KShTc9dj4nWHgPcH6RArE1HtargxYpDursnAC9jzCb6r0LEsknaRj6EbStltCGXOWWdD5azolg9C7SpUidDg==","signatures":[{"sig":"MEUCIQCuLZAeMWxTq7RY8NuAHwes8C5srv2j6pYw3d/ehkn6QgIgL0zpPZBq9USr60e4yw0XqQFM83T9zF/wGeRPVvnXCik=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":2456490},"main":"dist/index.js","type":"module","_from":"file:any-router-core-0.0.2.tgz","types":"./dist/index.d.ts","exports":{".":"./dist/index.js","./*":"./dist/"},"scripts":{"test":"npm run test:types && npm run test:unit","build":"tsc","clean":"rm -rf dist","test:unit":"vitest run","test:types":"tsc -p tests/tsconfig.json"},"_npmUser":{"name":"kgroat","email":"apps@kgroat.dev"},"_resolved":"/tmp/ec5ad4a297ec4df8ec4f2872f2ed1a75/any-router-core-0.0.2.tgz","_integrity":"sha512-C7KShTc9dj4nWHgPcH6RArE1HtargxYpDursnAC9jzCb6r0LEsknaRj6EbStltCGXOWWdD5azolg9C7SpUidDg==","repository":{"url":"git+https://github.com/kgroat/Route-Anything.git","type":"git"},"_npmVersion":"10.9.2","description":"A powerful but minimal router","directories":{},"_nodeVersion":"22.14.0","_hasShrinkwrap":false,"devDependencies":{"zod":"^3.24.4","vite":"^6.3.5","vitest":"^3.1.3","prettier":"^3.5.3","typescript":"^5.8.3","@vitest/coverage-v8":"^3.1.3","vite-tsconfig-paths":"^5.1.4","@type-challenges/utils":"^0.1.1"},"peerDependencies":{"zod":"^3.0.0"},"_npmOperationalInternal":{"tmp":"tmp/core_0.0.2_1749308778165_0.2180023985203463","host":"s3://npm-registry-packages-npm-production"}},"0.0.3":{"name":"@any-router/core","version":"0.0.3","description":"A powerful but minimal router","type":"module","main":"dist/index.js","exports":{".":"./dist/index.js","./routing":"./dist/routing.js","./protected":"./dist/protected/index.js"},"repository":{"type":"git","url":"git+https://github.com/kgroat/Route-Anything.git"},"keywords":["router","route","path"],"author":{"name":"kgroat","email":"apps@kgroat.dev"},"license":"BSD-2-Clause","bugs":{"url":"https://github.com/kgroat/Route-Anything/issues"},"homepage":"https://github.com/kgroat/Route-Anything#readme","devDependencies":{"@type-challenges/utils":"^0.1.1","@vitest/coverage-v8":"^3.1.3","prettier":"^3.5.3","typescript":"^5.8.3","vite":"^6.3.5","vite-tsconfig-paths":"^5.1.4","vitest":"^3.1.3","zod":"^3.24.4"},"peerDependencies":{"zod":"^3.0.0"},"scripts":{"clean":"rm -rf dist","build":"tsc","build:local":"tsc --inlineSourceMap","test":"npm run test:types && npm run test:unit","test:types":"tsc -p tests/tsconfig.json","test:unit":"vitest run"},"_id":"@any-router/core@0.0.3","types":"./dist/index.d.ts","_integrity":"sha512-NTexsQ0ZGezp/W+Ih4BHPcP1WPf3RD0HirKxr2Mbjd+T7gfEAOp8uhPOt5QAavOwhV76HF1+kFuDc91b+/kszQ==","_resolved":"/tmp/2196c0f46f9d32f65c45be59e37f50ed/any-router-core-0.0.3.tgz","_from":"file:any-router-core-0.0.3.tgz","_nodeVersion":"22.14.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-NTexsQ0ZGezp/W+Ih4BHPcP1WPf3RD0HirKxr2Mbjd+T7gfEAOp8uhPOt5QAavOwhV76HF1+kFuDc91b+/kszQ==","shasum":"75f1a39f3e4c3707f42f11f709d4448b3def5744","tarball":"https://registry.npmjs.org/@any-router/core/-/core-0.0.3.tgz","fileCount":18,"unpackedSize":18382,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCZEsItDRlsiF0VTBCWdTCZcqFPU4kplpx/Sh6nouTCOwIhANtcXiwPEAJ6i7XS5UWZ6uQS6mFltRH/tEcz1R75Gihx"}]},"_npmUser":{"name":"kgroat","email":"apps@kgroat.dev"},"directories":{},"maintainers":[{"name":"kgroat","email":"apps@kgroat.dev"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/core_0.0.3_1749475678567_0.8480515208372503"},"_hasShrinkwrap":false}},"time":{"created":"2025-05-07T20:16:22.019Z","modified":"2025-06-09T13:27:58.954Z","0.0.1":"2025-05-07T20:16:22.348Z","0.0.2":"2025-06-07T15:06:18.440Z","0.0.3":"2025-06-09T13:27:58.747Z"},"bugs":{"url":"https://github.com/kgroat/Route-Anything/issues"},"author":{"name":"kgroat","email":"apps@kgroat.dev"},"license":"BSD-2-Clause","homepage":"https://github.com/kgroat/Route-Anything#readme","keywords":["router","route","path"],"repository":{"type":"git","url":"git+https://github.com/kgroat/Route-Anything.git"},"description":"A powerful but minimal router","maintainers":[{"name":"kgroat","email":"apps@kgroat.dev"}],"readme":"# @any-router/core\n\nA powerful but minimal router\n\n##\n\n### Installation\n\n```bash\nnpm install @any-router/core\n```\n\n### Example\n\n```ts\nimport { compileRouters, routerBuilder } from '@any-router/core'\nimport { z } from 'zod'\nimport { IncomingMessage, createServer } from 'node:http'\n\nimport { userRepo, commentRepo } from './repositories'\n\ntype RouteResult = {\n  statusCode: number\n  body: unknown\n}\n\n// Define your request and response types\nconst nodeRouterBuilder = routerBuilder<IncomingMessage, RouteResult>()\n\n// Define your routers\nconst userRouter = nodeRouterBuilder('/user/:userId')\n  .get(async ({ routeResult: { userId } }) => ({\n    statusCode: 200,\n    body: await userRepo.getUser(userId),\n  }))\n  .put(\n    z.object({ name: z.string() }),\n    async ({ routeResult: { userId }, body: { name } }) => ({\n      statusCode: 200,\n      body: await userRepo.updateUser(userId, name),\n    }),\n  )\n  .build()\n\nconst commentRouter = nodeRouterBuilder('/user/:userId/comment/:commentId')\n  // ... handlers for GET, POST, PUT, DELETE, or PATCH\n  .build()\n\n// Compile your routers\nconst handler = compileRouters([userRouter, commentRouter])\n\n// Use your route handler\nconst server = createServer(async (req, res) => {\n  const result = handler('/user/123/comment/456', 'GET', getBody(req), req)\n\n  res.writeHead(result.statusCode)\n  res.end(JSON.stringify(result.body))\n})\n\nfunction getBody(req: IncomingMessage): unknown {\n  // ... Parse the body of the request\n}\n```\n","readmeFilename":"README.md"}