{"_id":"@abradley2/koa-validated-route","_rev":"2-46f9cd81aef50b9b323d1794d4557d73","name":"@abradley2/koa-validated-route","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"@abradley2/koa-validated-route","version":"1.0.0","description":"koa-route with validation courtesy of \"is-my-json-valid\"","main":"index.js","scripts":{"test":"standard && tape tizzest.js","lint":"standard --fix"},"repository":{"type":"git","url":"git+https://github.com/abradley2/koa-validated-route.git"},"author":{"name":"Tony"},"license":"MIT","bugs":{"url":"https://github.com/abradley2/koa-validated-route/issues"},"homepage":"https://github.com/abradley2/koa-validated-route#readme","dependencies":{"is-my-json-valid":"^2.17.2","koa-route":"^3.2.0"},"devDependencies":{"koa":"^2.5.1","koa-bodyparser":"^4.2.0","standard":"^11.0.1","supertest":"^3.0.0","tap-nyan":"^1.1.0","tape":"^4.9.0"},"gitHead":"0049e23d104ba5377a9c9e6e8829029cd2246cf9","_id":"@abradley2/koa-validated-route@1.0.0","_npmVersion":"5.8.0","_nodeVersion":"9.4.0","_npmUser":{"name":"abradley2","email":"antbradley91@gmail.com"},"dist":{"integrity":"sha512-jFDwAc1BP7FcW/ZuydECZfVjLWOdBeDuiWQY19WrsK8Ay/GbLjqyFDoj0ize7x7MBxVHOugAWToOBz+G0Nr5mQ==","shasum":"955ed3bcc2213ee3faa0e2ca409ab2c3355e85f0","tarball":"https://registry.npmjs.org/@abradley2/koa-validated-route/-/koa-validated-route-1.0.0.tgz","fileCount":5,"unpackedSize":5850,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJa5QvYCRA9TVsSAnZWagAAAoIP/04+xRPJkWipJGS/xv5z\nKSas81bmDeE5YlyEqu20ddZ/rs4webKz+wyMrcMkcQLc0Z5WrwjT/wNXZ34Z\n0jWdrKUzau8GMM4i2NyaYCbErlNq2hVd/pcF4bE+b4BG1Wcu7B8mALtX2yeZ\n8vvrYA4IvQe6kXdzHrHBNaCQmy2R2CXJUJKr4R99UjWcKmb2XkSVX3sxzTvH\n2pmBWJEhrJVl/7wADmewQfHWb9Zmbn6ceobrkIC9tEXwjcaput9R2C+d4j4k\n4aGeA1vZW9X4rMaN0uF9KRPUZAkEXP6FiTEnEczs3NtxhjA53KvGK8yqOZP2\nLDi0QqTEmzJbb7GD46FuoYPhIdbPSStak1fLvKj3FHuMo4CIaHFhct99Wi1P\n3qv2HeqLDLKLDkZYEVNnnBAHHNEV31jwL+fqpKloWa13vyN5YHVM9Js6eKUp\nxbJHGz90G86XmvNCz9TgV6m3JybLBIs42fxKL7VNeni84k0evu8wdUQf263E\nwxoSx1dBv5iGWgWUAJrNwvUj7oloUyogLlbTFVDyzO3rvO6z//rKAYTNIi45\nqFPDCz3GnBPfAc6zPQ09q4bxK/pe2ogH0tJ2nSO2J13s8Rhb0uNrh1Kaqr05\n6UIMAJ1thwzdD5N06Qqv/2pIyZmqkK2yInPPle6IppssWbbFPktD6G66zkol\nIIMo\r\n=NbhW\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDzVOI7gHt05cZey1ccYGsxrDeXPmR2lBpZkDBn+tTE/AiEAtrjmBNhR1dGch8suGh58sfKIP8pe7zGS+/Gwaze7VLQ="}]},"maintainers":[{"name":"abradley2","email":"antbradley91@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/koa-validated-route_1.0.0_1524960215236_0.19098694260490867"},"_hasShrinkwrap":false},"1.0.1":{"name":"@abradley2/koa-validated-route","version":"1.0.1","description":"koa-route with validation courtesy of \"is-my-json-valid\"","main":"index.js","scripts":{"test":"standard && tape tizzest.js","lint":"standard --fix"},"repository":{"type":"git","url":"git+https://github.com/abradley2/koa-validated-route.git"},"author":{"name":"Tony"},"license":"MIT","bugs":{"url":"https://github.com/abradley2/koa-validated-route/issues"},"homepage":"https://github.com/abradley2/koa-validated-route#readme","dependencies":{"is-my-json-valid":"^2.17.2","koa-route":"^3.2.0"},"devDependencies":{"koa":"^2.5.1","koa-bodyparser":"^4.2.0","standard":"^11.0.1","supertest":"^3.0.0","tap-nyan":"^1.1.0","tape":"^4.9.0"},"gitHead":"4c1b7522a22de034a569ea7b18a07a4481e73761","_id":"@abradley2/koa-validated-route@1.0.1","_npmVersion":"5.8.0","_nodeVersion":"9.4.0","_npmUser":{"name":"abradley2","email":"antbradley91@gmail.com"},"dist":{"integrity":"sha512-v/iiSsRP7pHTtMiCNSb/ddOhOjiv2w3ncN6xhRIlzHhD+L6F+Or3RzI2XJcCEBi2PMgkOc4ChftVRhLiPqdLjg==","shasum":"4f944f4f40a017e6927f1fcfb5348ef20f462dca","tarball":"https://registry.npmjs.org/@abradley2/koa-validated-route/-/koa-validated-route-1.0.1.tgz","fileCount":5,"unpackedSize":5806,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJa5cgcCRA9TVsSAnZWagAAs7AP/0/1gA5P0OIYP15sNZJQ\ng+mbDllPSdFAN2SwOHkxhsndbdS+GSJO/Vb4qaltTjM1KJ71mnjKaJnKCxxE\n3gcyExGPTo0W1eK+XA2l7tZJCOJm6M7EfxbcflMjtFh242RxCoclaQDe4w0x\n5BFQfMAZYglzwyIc06xQaHh4mdCmIvGGD/LZjiu55A8OaB6dG6/xhqApu+5n\n9xevKzwZI1H70pcxIogryx7oK5FZ6deI5uYtnjy3vVPYMOi/Yekk1yYSE19l\nELMTf4V60GY0DghI5yZPIV6AYWoYgVUcE9OPIikC66ow6SMD+B37f+7XVXfC\n78945Mw48lK+iSeXijCx+jALUm42FZpgZi4cVGtAunYmJBbJICumNVEq5aw2\nhvWVoLGh9ijfsUtsdN8o2h6nCp+Wf9ED8O2dafI1xHQJli8OLGLreD8tdRuM\nGVs3FKLFF7lzbGbMij48ahARa0lrXoPhKaAkgkD4omSmfZJpj7OkcfpSOxxo\n94hf2yBzLf0sVC40i5rAED8YzlmNv4qM0hvwo75ELk97Wys1pJ5t9swQzZC+\n/2geBM40ywmbUVTRz4lve4QONrKqyQ32BSlptPi+CnSXzyk01o81Pd9JWVI+\nMiT4TQbymxXBr8wMFn520PmpNmdAAc9VZ4hxsG1A5eJjLrUPIQXvRuV12mUp\nA/O/\r\n=r/jq\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDHapeEOoYteg7i12cs+oPfkw21CeO8eVOOjtzi5sJTcgIhAKARokiVeNpG6m5eN9MKwjn7irVO9Rd6GY5R1Np+A8WD"}]},"maintainers":[{"name":"abradley2","email":"antbradley91@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/koa-validated-route_1.0.1_1525008411372_0.7008048723164291"},"_hasShrinkwrap":false}},"time":{"created":"2018-04-29T00:03:35.173Z","1.0.0":"2018-04-29T00:03:35.324Z","modified":"2022-04-04T11:01:38.030Z","1.0.1":"2018-04-29T13:26:51.454Z"},"maintainers":[{"name":"abradley2","email":"antbradley91@gmail.com"}],"description":"koa-route with validation courtesy of \"is-my-json-valid\"","homepage":"https://github.com/abradley2/koa-validated-route#readme","repository":{"type":"git","url":"git+https://github.com/abradley2/koa-validated-route.git"},"author":{"name":"Tony"},"bugs":{"url":"https://github.com/abradley2/koa-validated-route/issues"},"license":"MIT","readme":"# Koa validated route\n\n`npm install --save @abradley2/koa-validated-route`\n\nThis is a very simple wrapper around [koa-route](https://github.com/koajs/route) and [is-my-json-valid](https://github.com/mafintosh/is-my-json-valid).\nRefer to their documentation for how route argument passing, matching, and schema\nvalidation work. This simply adds them together in a simple wrapper so you\ndon't need to manually initialize validators, and send back 400s with the error list yourself\n\n### API\n\nUse the main exported method the same you would with **koa-route** as this\nmodule simply wraps your handler and proxies to that. For any route handler\nthat has a `validate` object property, this property will be used to generate\nvalidation schemas for the body or query of the request (note you don't need to\nbother with `type: object, required: true` on the root of any body or query schema,\nthis is taken care of).\n\nThe specification underlying this validation \nis [this big scary spec document with lots of words](http://json-schema.org/latest/json-schema-validation.html)\nbut it's actually fairly straight-forward in practice\n\n### Example\n\n```\nconst app = require('koa')()\nconst withValidation = require('koa-validated-route')\n\nfunction submitRoute(ctx, sessionId) {\n  // we won't reach here if the validation fails.\n  // so now we can proceed with confidence!\n}\n\nsubmitRoute.schema = {\n  body: {\n    title: {\n      type: 'string',\n      required: true\n    },\n    isMarried: {\n      type: 'boolean',\n      required: true\n    }\n  },\n  query: {\n    userId: {\n      type: 'string', // all query params are going to be string so duh\n      required: false\n    }\n  }\n}\n\napp.use(\n  withValidation.post('/submit/:sessionId', submitRoute)\n)\n```","readmeFilename":"README.md"}