{"_id":"trpc","_rev":"42-18359cf5695233b2036efd8358e01d71","name":"trpc","dist-tags":{"latest":"0.11.3","beta":"0.11.3-beta.2"},"versions":{"0.0.2":{"name":"trpc","version":"0.0.2","description":"Learn [Zod](https://github.com/vriad/zod) here.","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"keywords":[],"author":{"name":"Colin McDonnell"},"license":"ISC","_id":"trpc@0.0.2","_npmVersion":"6.4.1","_nodeVersion":"10.15.3","_npmUser":{"name":"vriad","email":"colin@vriad.com"},"dist":{"integrity":"sha512-8CxsxxxDhOeXcYpR+T5NN/no/YhpY2IOj4HTgouYj/l552uuhM+sxUbsECPgs9YFwvavq1Zu25VLV69o4QSxtg==","shasum":"d9e3c6a77a8f22c682bce66354c4cb90c16913da","tarball":"https://registry.npmjs.org/trpc/-/trpc-0.0.2.tgz","fileCount":3,"unpackedSize":326,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfKKC8CRA9TVsSAnZWagAAVrMP/Aqmp+RDA0F0jxeiEjVQ\njxsJeusbhlFH+BNIJe0sb234zc8a9sX0JzT8F3+nBKVx8PmmdFTA06qnULek\n8fYahvDORWKNeqFA2wNulyP6ZKNJSrLZOjHkXGGtHFU5oveeO2J0rsvGf9DH\nrysymjeD0pLq66aKVnMrsarIUll6/b0pTyJ+563dy9B0oTpN0+zOTVMzK+h3\nggGysBk0beVNcEYMZ0FmnBy+TyyNp9d5oh2pcFmDypgZMtD3b/xPjp5iH7ca\njd5avrKuh7GNtEmnWPc9iTr+ehLMRPPiNjSOS/FpKcRZemB5WVuv6pOvCFIh\nMYO3/qkQe7zUkaH806cz/hqud2vb5ckIF0a9tRcLueI3eu5qqHxoZPZUinFg\ndLGb53UGPijLI/LPJTCpM6piFYEYP+68U4rZnGBZ0zmA5SYe256q+J1sJ8y6\nv/tzYVPGmDbgkUP3+k3RoxQnzk1Zesv4wIFEroTb8qnMSHwbGljS41ZO1DJS\njJBTU/DeWs5k3mId0qN9N/RK0ELzlrLQsQ0fKPxMKK+/yM3loD9lVmhRqRzd\n6rl1FPU+pBQJPYS1a/U2Hbz7Ve6rGsgOoGhaUcAoFr4dUyt55BHQIs7Y6uDB\nCrzOBzsG1LydpDy+Sh4zXqemjA5B1lWX9T2PPMjLyOTju/7BHhvYI5bAm7cE\n2J2L\r\n=vDEb\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGRIjxWIZFsIqyVVRLC0zGLMHcQcRGp94ClkNJhH9BciAiEA/vKY23RAEu0o0p76C9jLV/B9wJp9Nz+d4NaPZ9nQlgw="}]},"maintainers":[{"name":"vriad","email":"colin@vriad.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/trpc_0.0.2_1596498107932_0.9932301929508958"},"_hasShrinkwrap":false},"0.1.0":{"name":"trpc","version":"0.1.0","description":"TypeScript-first toolkit for building RPC APIs","main":"./lib/src/index.js","types":"./lib/src/index.d.ts","repository":{"type":"git","url":"git+https://github.com/vriad/trpc.git"},"author":{"name":"Colin McDonnell","email":"colin@vriad.com"},"license":"MIT","sideEffects":false,"bugs":{"url":"https://github.com/vriad/trpc/issues"},"homepage":"https://github.com/vriad/trpc","dependencies":{},"tags":[],"keywords":[],"include":["src"],"exclude":["node_modules","**/__tests__/*"],"scripts":{"clean":"rm -rf lib/*","build":"yarn run clean && tsc --p tsconfig.package.json","format":"prettier --write \"src/**/*.ts\" \"src/**/*.js\"","lint":"tslint -p tsconfig.json","test":"jest --config jestconfig.json --coverage","testone":"jest --config jestconfig.json","prepublishOnly":"npm run build","play":"nodemon -e ts -w . -x ts-node src/playground.ts"},"devDependencies":{"@types/jest":"^25.1.4","axios":"^0.19.2","jest":"^25.1.0","nodemon":"^2.0.2","prettier":"^2.0.5","ts-jest":"^25.2.1","typescript":"^4.0.0-dev.20200717","zod":"^1.10.1"},"gitHead":"5469b5add3b03346f28ed390521e0e6a1b60a258","_id":"trpc@0.1.0","_npmVersion":"6.4.1","_nodeVersion":"10.15.3","_npmUser":{"name":"vriad","email":"colin@vriad.com"},"dist":{"integrity":"sha512-0M/ZLkx/+wlPENBQjTKvOExF6e5XZVDrvDgZpZA/Pk4UUsrHT3hxBS1TqFgaOuWFRFpGv62JPx1p/rpIJ2xCaQ==","shasum":"68c6525a3e8df37ae8e520a72fb4e89272db17fb","tarball":"https://registry.npmjs.org/trpc/-/trpc-0.1.0.tgz","fileCount":34,"unpackedSize":60140,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfLhZoCRA9TVsSAnZWagAA4PIP/1t+RO1IuvenSbvt0WgJ\nK40dEMWeljIuPzMd2gqIy84sVkDwWRrNzewOsOVI0bTd2HL9sNiiYG00U5I1\nxK1LxMW8ukwZ8kwH3rUjYWn1DwZMohuwOpj0xslPbZaLun2mcGqoLLcxbImp\ngYGgmfWpgqtZZNYJBtR+h4wm1zGVGLld5/IfTDabIz+SoxtR9UrehRvB4qEY\n3e9jwgw2Xlhpgte62tOpAl7Hh43T0Fx35d9IolDrNVQvfYgUkhZlfBE51aK1\ndbOzaFoku6Z1rup4qUM2q/vL4yHMBli5FoGhwXVk+HHA4bk9mxXabN+ZyJBC\nC+5tsMiO0M8gZdE5WuqM2PbIZMDOL2N9c0QNLy6Ygu6Ptr6gLY7QcV1f+YYf\nPT6zDv2ScM6awHGKQeGeEPGuJ1YTRZfdLZTsCC5Mm3GMQgZvO/tZtB0ButjY\n3IfWBZVzX+SpbXfrypfVpnQfQG22MUumJq/9kXBHIVqRvRQI+A+V9uENIrms\naQMFGEaiDFY0i4dHoCcRFK4m9B+jZrMA2y2f8x3AH7GgNLKBkiu7PWu5oteA\nfwSRxAoqfxP88Hcf5o4tKCYN9dQLtg18sHTNVp7ARyzPAVskeTsnWVAy+ZPk\nc8eogHLANgs0P7gBprai3MRSBkl6Agi7PzZaR/RqyGFMxhi8nX3DG0d9AxxH\n5VgW\r\n=kPTX\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFs+N+WsDJSynNljKx9JU8xFbr6zV74z3DNyM5+KditAAiBLUvXTe/o+xq+bV4EP34gGSV4lZ/9HUzEyn7gd1Kvy6A=="}]},"maintainers":[{"name":"vriad","email":"colin@vriad.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/trpc_0.1.0_1596855912485_0.6050731909484026"},"_hasShrinkwrap":false,"deprecated":"supersseded by @trpc/*-packages - see tRPC.io"},"0.2.0":{"name":"trpc","version":"0.2.0","description":"TypeScript-first toolkit for building RPC APIs","main":"./lib/src/index.js","types":"./lib/src/index.d.ts","repository":{"type":"git","url":"git+https://github.com/vriad/trpc.git"},"author":{"name":"Colin McDonnell","email":"colin@vriad.com"},"license":"MIT","sideEffects":false,"bugs":{"url":"https://github.com/vriad/trpc/issues"},"homepage":"https://github.com/vriad/trpc","dependencies":{},"tags":[],"keywords":[],"include":["src"],"exclude":["node_modules","**/__tests__/*"],"scripts":{"clean":"rm -rf lib/*","build":"yarn run clean && tsc --p tsconfig.package.json","format":"prettier --write \"src/**/*.ts\" \"src/**/*.js\"","lint":"tslint -p tsconfig.json","test":"jest --config jestconfig.json --coverage","testone":"jest --config jestconfig.json","prepublishOnly":"npm run build","play":"nodemon -e ts -w . -x ts-node src/playground.ts"},"devDependencies":{"@types/compression":"^1.7.0","@types/cors":"^2.8.7","@types/express":"^4.17.7","@types/jest":"^25.1.4","axios":"^0.19.2","compression":"^1.7.4","cors":"^2.8.5","express":"^4.17.1","jest":"^25.1.0","nodemon":"^2.0.2","prettier":"^2.0.5","ts-jest":"^25.2.1","typescript":"^4.0.0-dev.20200717","zod":"^1.10.1"},"gitHead":"c5275861cc7f65e79e18171fabaa88b77970370f","_id":"trpc@0.2.0","_npmVersion":"6.4.1","_nodeVersion":"10.15.3","_npmUser":{"name":"vriad","email":"colin@vriad.com"},"dist":{"integrity":"sha512-4hCAOwaI4lcjOd6Y5Do6ZU8aF+7T+MeawYE5KCDXuwsKNH3W5JERUu46SM/TQ+e7l8tmfFJWSyr9vMBaGlGWIw==","shasum":"7b95102d6dab28b71a1f16a5b668a878f83b3d33","tarball":"https://registry.npmjs.org/trpc/-/trpc-0.2.0.tgz","fileCount":37,"unpackedSize":65953,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfLkF1CRA9TVsSAnZWagAA96MP/2QJLjeWI4mG9fPVoClq\nnqSlD70OCFUyjQJnX9AClHUpooU3NYgBTrn/rXGsZkRoORXfbOcILfzDCTz6\n8txGs6aqLfKQ0I6bxlX9eGeWNfEV6Q4K0gesexB0KJ1qjjpzDUR4qcFEaEj+\ns/sXH29CMcGRBznu5WRG/6Yh9+WEU0hilktIp2SIrTZnKfZ4wDkXHz159l8D\nKNC5LLOqr6gIMzCOyt4xGL5LYNDTXHnxkLutHi0Qv37lusWwddbYigvKWY0K\n+K6Mrj3NLzNS+OYziBHT6/5e2h8XOizKzwJmAWAVAeuU4duTAUlxZiUQCKHh\n6xrek39s5gYMPorQF9WWuDhMyEm5LkvuZcIOtUQBVZ3ckwdeh2p6+uhgrAGo\nCc+J5HEOqGweTXOglpyovmgCV7CfF7L/OBKW66SohDxdAan5xOasAsyQk2qJ\nGprwbfYQLyub8zSVAvOmqxHOxkizMjutOtEBS/H0UbToK/B+7wxYGo/UuoAh\nm1AWKcFmW6+Qzy0fjDQb+Yhr3/yi/PBdf8iyWlPvqzijRG3zSWmF1UVp8cEI\nYtTHrc8Q8FswS0QA0TGEph/AUaxismg8bWiq/jd12vDiaO3DxeyAsx2pgWeQ\n/nTKtr3ocEndmVd4ZcJrYps9nwi/S8ICRSrpbu3HqylYB1DSwufthGAnqI6E\nZ71q\r\n=Tkpd\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDqPbsSBtoGeQCTY2h5AYTpMBPXxBkB/ZrfMC9v4IGoOAIgBRfm88culEhYx+L2bMDU35Ihp9OQDuLj4zKoTQh7wGM="}]},"maintainers":[{"name":"vriad","email":"colin@vriad.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/trpc_0.2.0_1596866932665_0.5184824143757851"},"_hasShrinkwrap":false},"0.3.0":{"name":"trpc","version":"0.3.0","description":"TypeScript-first toolkit for building RPC APIs","main":"./lib/src/index.js","types":"./lib/src/index.d.ts","repository":{"type":"git","url":"git+https://github.com/vriad/trpc.git"},"author":{"name":"Colin McDonnell","email":"colin@vriad.com"},"license":"MIT","sideEffects":false,"bugs":{"url":"https://github.com/vriad/trpc/issues"},"homepage":"https://github.com/vriad/trpc","dependencies":{},"tags":[],"keywords":[],"include":["src"],"exclude":["node_modules","**/__tests__/*"],"scripts":{"clean":"rm -rf lib/*","build":"yarn run clean && tsc --p tsconfig.package.json","format":"prettier --write \"src/**/*.ts\" \"src/**/*.js\"","lint":"tslint -p tsconfig.json","test":"jest --config jestconfig.json --coverage","testone":"jest --config jestconfig.json","dryrun":"nodemon -e ts -w . -x ts-node src/dryrun.ts","prepublishOnly":"npm run build","play":"nodemon -e ts -w . -x ts-node src/playground.ts"},"devDependencies":{"@types/compression":"^1.7.0","@types/cors":"^2.8.7","@types/express":"^4.17.7","@types/jest":"^25.1.4","axios":"^0.19.2","compression":"^1.7.4","cors":"^2.8.5","express":"^4.17.1","jest":"^25.1.0","nodemon":"^2.0.2","prettier":"^2.0.5","ts-jest":"^25.2.1","typescript":"^4.0.0-dev.20200717","zod":"^1.10.1"},"gitHead":"e57cf41befe611a7476b4157c55b89a25d4fc1a6","_id":"trpc@0.3.0","_npmVersion":"6.4.1","_nodeVersion":"10.15.3","_npmUser":{"name":"vriad","email":"colin@vriad.com"},"dist":{"integrity":"sha512-2/wNvzxxyctXku3rdfK5LnujVCCuJibLv3eSRwxSvXXHTGmz0iMSL4+n70nOY9NiBmwzM9H89xHbtTZsYASIrQ==","shasum":"dfdbed35449c65b3c4549f91f8854cfbe2459436","tarball":"https://registry.npmjs.org/trpc/-/trpc-0.3.0.tgz","fileCount":37,"unpackedSize":68282,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfLkSvCRA9TVsSAnZWagAAluUP/3rjn4nldX3o1v1XPBvD\nkQzbHBi25dBjRddfH9xTtRLhBDTsa3kQdAriTXCH0Ie5qeZHQgWbtbJEdLXJ\nStUqASNLuXGCC/LFwWTO41ODtE/BJTbZn/s5LppJZBo+dUp74lxiULNaFsYv\nrNwSxpCccsgxHjRfdMh09w5hTaHyDnDCvsuuEmYPZfaN0LkEAbkA/exe5Yij\nbtI5jxvjEsiH+roCS0T9LsCto2KsErcDw1Rzysdxv1kytWIHhRdPbHV5Dq5s\nAh/ZxuvVI3uZo1jbu5KyWeosiIsohaaL2owiZdHoItk68tOrlz+Sb+T5+2Cq\nwHYv38cu8doi+vAl/ap0mHMdYqQ+Nsln6a7T2lc5MLKvo9p5OsomOCyb6TsX\nxyhry7hQEvlnji0RbIoFDBpi7TAcGLyPv+hD/JWaSqhFG2u6IEtbBynW0+Vs\nRbBKqbiGdQ078Bst65HaRsQKd9pI2Fsl0tmTTXRdg89QvpyyWg8haQQ7eahL\nHwvScDX+HZtqUYASAF0zogDZjN2LifNnVfCJPwhC1zcj068XgRphohhtoZR7\nR4wqyoD9oph/YBRfmtqWDLNDqgVNPTqAYE4yTmcJxIeP/4fSS76zA5XJez5m\nuEzbUwkhMHarWOO+PpOjfeSKf19wz1C4tIEN/X0YRHiMp2h8JVZo5LNUOtXN\nKPH8\r\n=uSDJ\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCjknRqir28gFUJWIHP704N0x1mx+K5ku/197a4QsOnjQIgUfY8E21apcM6Ii3kdg75yclOtVTmnedKMCr6D1cSUAU="}]},"maintainers":[{"name":"vriad","email":"colin@vriad.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/trpc_0.3.0_1596867758681_0.245263656911884"},"_hasShrinkwrap":false},"0.4.0":{"name":"trpc","version":"0.4.0","description":"TypeScript-first toolkit for building RPC APIs","main":"./lib/src/index.js","types":"./lib/src/index.d.ts","repository":{"type":"git","url":"git+https://github.com/vriad/trpc.git"},"author":{"name":"Colin McDonnell","email":"colin@vriad.com"},"license":"MIT","sideEffects":false,"bugs":{"url":"https://github.com/vriad/trpc/issues"},"homepage":"https://github.com/vriad/trpc","dependencies":{},"tags":[],"keywords":[],"include":["src"],"exclude":["node_modules","**/__tests__/*"],"scripts":{"clean":"rm -rf lib/*","build":"yarn run clean && tsc --p tsconfig.package.json","format":"prettier --write \"src/**/*.ts\" \"src/**/*.js\"","lint":"tslint -p tsconfig.json","test":"jest --config jestconfig.json --coverage","testone":"jest --config jestconfig.json","dryrun":"nodemon -e ts -w . -x ts-node src/dryrun.ts","prepublishOnly":"npm run build","play":"nodemon -e ts -w . -x ts-node src/playground.ts"},"devDependencies":{"@types/compression":"^1.7.0","@types/cors":"^2.8.7","@types/express":"^4.17.7","@types/jest":"^25.1.4","axios":"^0.19.2","compression":"^1.7.4","cors":"^2.8.5","express":"^4.17.1","jest":"^25.1.0","nodemon":"^2.0.2","prettier":"^2.0.5","ts-jest":"^25.2.1","typescript":"^4.0.0-dev.20200717","zod":"^1.10.1"},"gitHead":"283e39f983dfe7c662d8c1fa2441e017f86da0ae","_id":"trpc@0.4.0","_npmVersion":"6.4.1","_nodeVersion":"10.15.3","_npmUser":{"name":"vriad","email":"colin@vriad.com"},"dist":{"integrity":"sha512-P52zn7fGpO4XcWj0Qum4Qf6HWHzdv1mJCXmkNjdOaBRVdMMQ8dPJmM9oTXpORBt4hthZFTmxIQNxCGHqecpPMQ==","shasum":"569be65427d0f942f2c3a178c4dcfcaa11c6db1d","tarball":"https://registry.npmjs.org/trpc/-/trpc-0.4.0.tgz","fileCount":37,"unpackedSize":70647,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfL4xNCRA9TVsSAnZWagAA+HkP/iguRWAU92Nxmj7B6UnX\nYOrj6+LZEpq5hJWliF1c5Qld2inob5ZZIsDnJd6WcQg6tmIlGeWksnMGPdCq\ny+D1eQuIQ3UyCr6m09hg5HMDL1d3sf0v2NnRYbulQVtQ8TxJdm/HaNR6Hk2K\nO9m+TqCo2NVQvJ4xz5WsVqKMAfkFZSMKKrQ5921lWXqtkFvyp9OL5XA+LwnT\niGIYrRymK6IZ3GwMEyz0+m1We/obUNYZN1CFkuLr/U32HjR8ELYxPZMrBb62\nd6Kqmsl5lxjzIC7G/XXix4vdxRb/l+VYIzzMzNl+JRg122So6p5AxJTavsrF\n/UuZYcxkU5MfFvxDakuarpi8ggQGypqxk+dhykLV7k4KYM7wYqKA6QpBgpJ7\ntbCuZX2aJ9gM8SyXhMJj8xHaF/etruKAQMBx3f45fzGHVvb0yl8Rz3Y606AQ\nYOFBkNRdNLAajLkJTYWK2AIFg0ZHa2DbW7CCGFvCwZo51465cmHhAr3dwunF\nF+FG2lyXlxlyf+Z4sBOwgGfSGnWtt9GuQo4U//3Bx1AAcM/PGQj9eaZbfklu\nqHxRfSYcwp8HuwhoZ/WCu1fF4sHoGpCd209eCU3VJnMI9v37etlC61pBOHCa\nFfA4j1YyzvWXZe5+B1Ni6tIw2SftqOs6JDcB90ySWyCvJDTR2sqZXtkWYA73\nrYff\r\n=LGD8\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCtSsH7ORgfjyPlArUBSji4IKtDdzvio4nj0Qh/HkEQZgIgA19Ag8hNl56EB4ooKvX9EsJXoMqnMefsdscWphY+BHE="}]},"maintainers":[{"name":"vriad","email":"colin@vriad.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/trpc_0.4.0_1596951629379_0.6510083283177566"},"_hasShrinkwrap":false},"0.4.1":{"name":"trpc","version":"0.4.1","description":"TypeScript-first toolkit for building RPC APIs","main":"./lib/src/index.js","types":"./lib/src/index.d.ts","repository":{"type":"git","url":"git+https://github.com/vriad/trpc.git"},"author":{"name":"Colin McDonnell","email":"colin@vriad.com"},"license":"MIT","sideEffects":false,"bugs":{"url":"https://github.com/vriad/trpc/issues"},"homepage":"https://github.com/vriad/trpc","dependencies":{},"tags":[],"keywords":[],"include":["src"],"exclude":["node_modules","**/__tests__/*"],"scripts":{"clean":"rm -rf lib/*","build":"yarn run clean && tsc --p tsconfig.package.json","format":"prettier --write \"src/**/*.ts\" \"src/**/*.js\"","lint":"tslint -p tsconfig.json","test":"jest --config jestconfig.json --coverage","testone":"jest --config jestconfig.json","dryrun":"nodemon -e ts -w . -x ts-node src/dryrun.ts","prepublishOnly":"npm run build","play":"nodemon -e ts -w . -x ts-node src/playground.ts"},"devDependencies":{"@types/compression":"^1.7.0","@types/cors":"^2.8.7","@types/express":"^4.17.7","@types/jest":"^25.1.4","axios":"^0.19.2","compression":"^1.7.4","cors":"^2.8.5","express":"^4.17.1","jest":"^25.1.0","nodemon":"^2.0.2","prettier":"^2.0.5","ts-jest":"^25.2.1","typescript":"^4.0.0-dev.20200717","zod":"^1.10.1"},"gitHead":"c4dc24e451fe53568f9ae3c89c8c11b91976454f","_id":"trpc@0.4.1","_npmVersion":"6.4.1","_nodeVersion":"10.15.3","_npmUser":{"name":"vriad","email":"colin@vriad.com"},"dist":{"integrity":"sha512-rjNl1n7mW218XTBOPgW3iJGDxfTlWAYe8gnruFKYbAGSrqp0AAxPFkwtSjSNeV+Od3oP5pgLkac+GXVAXsKEpQ==","shasum":"73725843573090877f4719c2971407d1348239e1","tarball":"https://registry.npmjs.org/trpc/-/trpc-0.4.1.tgz","fileCount":37,"unpackedSize":71033,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfL4/zCRA9TVsSAnZWagAAeNkQAJFmUCyMn7k2WGbNNKk5\nclkiJZuygfI+MsFaUxXUNsXMnkbuJDCu/l6oeaJu8U4OPVx1BNp5vcvR1z3i\nmH5JIIDRiVY1o4BgPBPF+osDeUXS0jJAFOh4jephvhQiGhc7SVZiJH7+Ga5y\niOzanbgFjafLYfqAV5epyBRqSPLDzLDVeHAlk3OvN93humIB0R/ddkLOFq3/\n3RBxd0l7sGVxQ6zJNeSD4Vjzf//DN2cxuEGNISrt2i8cY11rhyRsdAhIety3\n8nMlvlazhoYED5MB/3GIWNZ93XH4CXQlRUFhfs8HdfJfSp57+dJm0G6RZBiQ\nVzZncmgCBV9/vKgk+QrmbQDvB+7YKpg8HULZ3S0j3DWuE0sarTbV4oKuLkX5\nyquKDRYDcwmEzkVWwAEgOdunjfi0jEqRJ2fQeR9JLaJIkQdmtzEzN4Gy8gDI\ndoH5C8a7h7mbyFlT/yMQN71VFsh5xoxYKZIhBF2T72LwcNWPs75ttmVTVFQg\nkA1KxhVgHLSM9AQ0DCl766lsLh7U3WZPw0/afIUOPWEjf5VprKS5moG0Wfhx\nT1zN3kovdF/v2J7S4cxEXWysDW7RwQUUYThYMrMdgky0osGBAJ7AkNV9UyXF\nYhvQfp0ZCA7GPJDPsA3cDYe2UL12UAKbBJyeGADEJzAsbKVEs0J5XTjNmJOh\nHQkX\r\n=owKW\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCIwJeHewRSUJXo0scuE4ozmZjBMMqFYTmAS5zm3QaT7wIhAMfMVaweFXIzBPt8BWvGGYkdOvAku8MI2IshkKvi37Zw"}]},"maintainers":[{"name":"vriad","email":"colin@vriad.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/trpc_0.4.1_1596952562841_0.35664979698609134"},"_hasShrinkwrap":false},"0.4.3":{"name":"trpc","version":"0.4.3","description":"TypeScript-first toolkit for building RPC APIs","main":"./lib/src/index.js","types":"./lib/src/index.d.ts","repository":{"type":"git","url":"git+https://github.com/vriad/trpc.git"},"author":{"name":"Colin McDonnell","email":"colin@vriad.com"},"license":"MIT","sideEffects":false,"bugs":{"url":"https://github.com/vriad/trpc/issues"},"homepage":"https://github.com/vriad/trpc","dependencies":{},"tags":[],"keywords":[],"include":["src"],"exclude":["node_modules","**/__tests__/*"],"scripts":{"clean":"rm -rf lib/*","build":"yarn run clean && tsc --p tsconfig.package.json","format":"prettier --write \"src/**/*.ts\" \"src/**/*.js\"","lint":"tslint -p tsconfig.json","test":"jest --config jestconfig.json --coverage","testone":"jest --config jestconfig.json","dryrun":"nodemon -e ts -w . -x ts-node src/dryrun.ts","prepublishOnly":"npm run build","play":"nodemon -e ts -w . -x ts-node src/playground.ts"},"devDependencies":{"@types/compression":"^1.7.0","@types/cors":"^2.8.7","@types/express":"^4.17.7","@types/jest":"^25.1.4","axios":"^0.19.2","compression":"^1.7.4","cors":"^2.8.5","express":"^4.17.1","jest":"^25.1.0","nodemon":"^2.0.2","prettier":"^2.0.5","ts-jest":"^25.2.1","typescript":"^4.0.0-dev.20200717","zod":"^1.10.1"},"gitHead":"053e97c60374e8c7506192c7cba3b53c85811ffe","_id":"trpc@0.4.3","_npmVersion":"6.4.1","_nodeVersion":"10.15.3","_npmUser":{"name":"vriad","email":"colin@vriad.com"},"dist":{"integrity":"sha512-NBLZ+2Cm/nf2e95wpUnwDLkwXMFNg0OY4p+4lnyadKvwDy+8xUhyBkqIM0U71ZTQQCCczpjKKshxjLQDPTt+ag==","shasum":"4baee096fd1e3b6980058a39fbb6a41dfeca6723","tarball":"https://registry.npmjs.org/trpc/-/trpc-0.4.3.tgz","fileCount":37,"unpackedSize":71122,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfL5LwCRA9TVsSAnZWagAA4/sP/1kzTVuaDvAvTvAG+2Qp\nNq2cXxZjtpY53eYJ4zXxoMbZz33NMNgTCNNKZe+lGdQHRPEERknJwBciQqQ4\niwnOR8ONjqZwi9X1EyD2Lyn7Aovan8UP//No79LztYslheJme8bgeeTCPOC1\nqRneqFr0oOrYPpq+fkVqPmKnMl3e0fO19qNc8hoK+Kt32rUoGCyFbHQqSKJI\n973yOHC90gL3bYUtN9DROUr89uaGsMl92/2FlDrMBUWM1CNmdEwDjq0qVS0L\nrmwXTdBimP7C5IyT5sN+WK2etZAOnvWMJhoIG/fsRm0ggu0TR7bX+qhk1TRd\nATkxl4UQ110v2QbkuiKeY21fjtCXd0i84umxjGuU/yrRc/3OC/qkvpDEBbMA\nCKclamDNnv5SMXPU4VEDZnT2tOc5aTR97Hx/CfTmfR/kUUPazKiSLKfDxVQa\nexykBNQOpMpEZRjxYMjUap4WhwxKaaDlS4z4HCXrCcLcR8gQQ4271bWG21Fg\n6w3GDlcVQMFYUTlmDzkJwxvOv0X+OvjDgqgGqNqZlBGbAwFjOtqYr1tJLh7Q\n6wKIw4Yf/T93CCwR9Uix3QdGu9INjoGSb+Lp+n0KMeryH7dqPFNb37DLaW6x\nOASJD8Ophq4LrybaMjkmIu833blsU3mCFenTvn6tuMaLjZjhP8nR0/c6AO04\nk0TH\r\n=GzI8\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCLyAshu4VeIb7F9aU/XAeKUMhyPbqIHRoB5BHD1d9uxwIgWPtiEsqbA7YDuY62Pak3rhWl3WEPZTUJ5qBqnqlQ+tM="}]},"maintainers":[{"name":"vriad","email":"colin@vriad.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/trpc_0.4.3_1596953328021_0.27851551794729956"},"_hasShrinkwrap":false},"0.4.4":{"name":"trpc","version":"0.4.4","description":"TypeScript-first toolkit for building RPC APIs","main":"./lib/src/index.js","types":"./lib/src/index.d.ts","repository":{"type":"git","url":"git+https://github.com/vriad/trpc.git"},"author":{"name":"Colin McDonnell","email":"colin@vriad.com"},"license":"MIT","sideEffects":false,"bugs":{"url":"https://github.com/vriad/trpc/issues"},"homepage":"https://github.com/vriad/trpc","dependencies":{},"tags":[],"keywords":[],"include":["src"],"exclude":["node_modules","**/__tests__/*"],"scripts":{"clean":"rm -rf lib/*","build":"yarn run clean && tsc --p tsconfig.package.json","format":"prettier --write \"src/**/*.ts\" \"src/**/*.js\"","lint":"tslint -p tsconfig.json","test":"jest --config jestconfig.json --coverage","testone":"jest --config jestconfig.json","dryrun":"nodemon -e ts -w . -x ts-node src/dryrun.ts","prepublishOnly":"npm run build","play":"nodemon -e ts -w . -x ts-node src/playground.ts"},"devDependencies":{"@types/compression":"^1.7.0","@types/cors":"^2.8.7","@types/express":"^4.17.7","@types/jest":"^25.1.4","axios":"^0.19.2","compression":"^1.7.4","cors":"^2.8.5","express":"^4.17.1","jest":"^25.1.0","nodemon":"^2.0.2","prettier":"^2.0.5","ts-jest":"^25.2.1","typescript":"^4.0.0-dev.20200717","zod":"^1.10.1"},"gitHead":"cf1ca1341f34220ee29248a95f03ed854ed116f0","_id":"trpc@0.4.4","_npmVersion":"6.4.1","_nodeVersion":"10.15.3","_npmUser":{"name":"vriad","email":"colin@vriad.com"},"dist":{"integrity":"sha512-2ArkmaGuprmqWE5I5vj3eTRGi0l6y4LQtlOBWpiAvbfMeQpnS1j2jDEKVUqvpNgt14KnK8zvvV6bAV0JLowMPA==","shasum":"4ea1f63b9272b203f36575ca01cbcb394079306c","tarball":"https://registry.npmjs.org/trpc/-/trpc-0.4.4.tgz","fileCount":37,"unpackedSize":71341,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfL5PKCRA9TVsSAnZWagAA3VwP/2ViZ36vCUb2XkyWqgYR\nCh0OPdESGa9sg0H2UXeeDDOV30nlhRFP+fnaH4Ab/ZztepfzkfhEWvs4mh1f\nrH9nOkhRCm5XQRK+A39W01pTJsglGRu89Zb2QryVd6d2KQD76F+58T1vlNAb\ncP2j+ca5wa20VMaeuj4f0FWeDaXFaL1fgg8tkXK7AFKw7+VE10Wyod+FcWCV\nhf8yb74/YLB9AT/DRx3O+g1WHASfKnzxdREe9NimeaQEr/tw8UOtZGnv13MB\nA9b7AsXkWdUaF/QBX8Afx+EMKbB5GbwcvJzLN2c0WlELupk0TpJR9tWtjUik\nwx5lvzLUIBbue501EGIhqW+rALqePnl4FuSZKfu8mD2jfaQW1nxrReUsNnxn\nI5Hjhv1Ko5XRceuIvP/eKm9V9zsxjYpMS0vHx7yFe+sOXhaZ/AETu+THCW/Z\nfLEuAsnprHTqu7sd1e6xPOf/NoZX1nlis2nhLwqclszGJNX3pLPEuN9fZhJ8\nRjI8t+UGYWFgq3pBUTsQ2wt1sG+v4oQbhxwCUDf2NbM7l9YnkGsXjsqjnegu\nESf2F9VbKTwN6p558m4IziNrNyONrCW8dDkTnLxBCU+X5ADO6M0BkJY50hLk\nZfWSb4mlRJNdgus4n37Ay5I2hVjJhKk56EUXBbseR8QOblbu0jhbFf/CAZMl\nXy2B\r\n=Zqto\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGL1HfnhraflbuyKBDNDlYgBYFkOVYIU6b2kMjVZjTyhAiAY3l6868w4dVR1RekUAYn/B+Vfqpz1oPM6W+CaBOxqDg=="}]},"maintainers":[{"name":"vriad","email":"colin@vriad.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/trpc_0.4.4_1596953546389_0.7386279491588872"},"_hasShrinkwrap":false},"0.4.5":{"name":"trpc","version":"0.4.5","description":"TypeScript-first toolkit for building RPC APIs","main":"./lib/src/index.js","types":"./lib/src/index.d.ts","repository":{"type":"git","url":"git+https://github.com/vriad/trpc.git"},"author":{"name":"Colin McDonnell","email":"colin@vriad.com"},"license":"MIT","sideEffects":false,"bugs":{"url":"https://github.com/vriad/trpc/issues"},"homepage":"https://github.com/vriad/trpc","dependencies":{},"tags":[],"keywords":[],"include":["src"],"exclude":["node_modules","**/__tests__/*"],"scripts":{"clean":"rm -rf lib/*","build":"yarn run clean && tsc --p tsconfig.package.json","format":"prettier --write \"src/**/*.ts\" \"src/**/*.js\"","lint":"tslint -p tsconfig.json","test":"jest --config jestconfig.json --coverage","testone":"jest --config jestconfig.json","dryrun":"nodemon -e ts -w . -x ts-node src/dryrun.ts","prepublishOnly":"npm run build","play":"nodemon -e ts -w . -x ts-node src/playground.ts"},"devDependencies":{"@types/compression":"^1.7.0","@types/cors":"^2.8.7","@types/express":"^4.17.7","@types/jest":"^25.1.4","axios":"^0.19.2","compression":"^1.7.4","cors":"^2.8.5","express":"^4.17.1","jest":"^25.1.0","nodemon":"^2.0.2","prettier":"^2.0.5","ts-jest":"^25.2.1","typescript":"^4.0.0-dev.20200717","zod":"^1.10.1"},"gitHead":"e6bf7d4087624f12f20b45ef848b1c954674f672","_id":"trpc@0.4.5","_npmVersion":"6.4.1","_nodeVersion":"10.15.3","_npmUser":{"name":"vriad","email":"colin@vriad.com"},"dist":{"integrity":"sha512-box6ft07TBULJ9sHicw+dgMU0CpOpDszXwu+ZLEfHIeWE55whtUINPfqzaTpGbj/IQc3x2gaMKBWsrWtwwfmyQ==","shasum":"b6e7b9597153e6d998029e3822a639776df0a254","tarball":"https://registry.npmjs.org/trpc/-/trpc-0.4.5.tgz","fileCount":37,"unpackedSize":71124,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfL5Y+CRA9TVsSAnZWagAAf9kP/jAsZ5HecL7EEqOyRIlH\nfAOqhc7E34zt9+D3pta+Ipd49TiHodpBQhbIUUdjCkd68N0ty/9Pv0n+L7n0\nvIBxhQf3+as69Tod4nbb+W6D0S4nGBf2Zas/WgDrKVXcbiUFY339VOKWBtfj\n5Zc3wV5ssRmwKru3UvXxT+mUmboYQJ99cZqcASa7sk2vFB4UdnFMu/Zp0PIp\nlKmyKzsULlnAtbl9jXTFp33Nx3pG5w39jGkrGe+MqIbs/Qg1TEXeyYAiqKzB\ndfc6DFFcR2mV9M3X8l2xnBYEqUCoIXqncFaFzYWWuak2qSuiF7AkMGVq4NUZ\naL1vZ+1gLH1lNxx7Eu0ipfMSQXjtxd1YeDDMM1uYmYgrvWHvUeESiSjtqZmE\n1mXduhsuVuqzqgvx2T0aRuxpAB/Rdg9eFVg3l/GRC1cAcRFwDe1rA0uBb9vM\nGY/f1/ML8P1T0H2gvaetGFxjRoNkBF92hceyTxL0bqBk99OaUiyK07RE6jw0\njRgYRu26GnGxP9Y7aW1cDiRQ4lTicq3LyPGWcL/lpBSI08v8amLczpUqzBd3\ntYcjGxy5nJjVY/TDcTb5E+CPOivWLtYL3F85WrvgjPRPGRVL8b4ttu5wSgus\nkVr7Kb3VgtOOcp8oJYrwLz6Q/i6VyZCNNR4hjG6h9W4uqGMlz91ZvvyUnTpB\n7Ann\r\n=ssk7\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD5FPVq/y5l+aznzoZ19kTIcWSjAfh/s780l6G0pZDfmQIhAMkui3/tnjJtJSsUra2pN3NfzVnDozluNyVkduw7Ma7S"}]},"maintainers":[{"name":"vriad","email":"colin@vriad.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/trpc_0.4.5_1596954174311_0.3591577117915974"},"_hasShrinkwrap":false},"0.5.0":{"name":"trpc","version":"0.5.0","description":"TypeScript-first toolkit for building RPC APIs","main":"./lib/src/index.js","types":"./lib/src/index.d.ts","repository":{"type":"git","url":"git+https://github.com/vriad/trpc.git"},"author":{"name":"Colin McDonnell","email":"colin@vriad.com"},"license":"MIT","sideEffects":false,"bugs":{"url":"https://github.com/vriad/trpc/issues"},"homepage":"https://github.com/vriad/trpc","dependencies":{},"tags":[],"keywords":[],"include":["src"],"exclude":["node_modules","**/__tests__/*"],"scripts":{"clean":"rm -rf lib/*","build":"yarn run clean && tsc --p tsconfig.package.json","format":"prettier --write \"src/**/*.ts\" \"src/**/*.js\"","lint":"tslint -p tsconfig.json","test":"jest --config jestconfig.json --coverage","testone":"jest --config jestconfig.json","dryrun":"nodemon -e ts -w . -x ts-node src/dryrun.ts","prepublishOnly":"npm run build","play":"nodemon -e ts -w . -x ts-node src/playground.ts"},"devDependencies":{"@types/compression":"^1.7.0","@types/cors":"^2.8.7","@types/express":"^4.17.7","@types/jest":"^25.1.4","axios":"^0.19.2","compression":"^1.7.4","cors":"^2.8.5","express":"^4.17.1","jest":"^25.1.0","nodemon":"^2.0.2","prettier":"^2.0.5","ts-jest":"^25.2.1","typescript":"^4.0.0-dev.20200717","zod":"^1.10.1"},"gitHead":"ec0fb9d7219c8af975fa2910a17701e4bcde10e9","_id":"trpc@0.5.0","_npmVersion":"6.4.1","_nodeVersion":"10.15.3","_npmUser":{"name":"vriad","email":"colin@vriad.com"},"dist":{"integrity":"sha512-ilyrPmJZVVFJRjJs7sBqjkWGf0mpBsR5CmNv37FZwR1D1+62/Jd8L3ItX3PFICLtY4InJOtCiQ1f0zoI1jl0fQ==","shasum":"acde28c1e11823f682f72a9cddd0928711fe56be","tarball":"https://registry.npmjs.org/trpc/-/trpc-0.5.0.tgz","fileCount":37,"unpackedSize":71765,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfL5/oCRA9TVsSAnZWagAAYQMP/0kNLrlPowwrtqb9iHn7\nGIkOBt28PQ2/ZdcM6YAoOVp9X+rvH1hUL15J4spOwpQXqwyMY8NXt+5spH/c\n8Jx87jZjpY6m4N357976X7ZO1zcHnCcGvAyHg+4BR9e5CwDofY4P2/FxCkbr\nDiBvosRTLGNeYrNIfq4mYIqy5UU2RJzCPmXFlQteyAauCtZ9YS1W2k2xmlaJ\n+5R/VPhQouy+lMgluhl2UUeTzMBozB5C4NmCrQF9WEE/1pzikPRORfu+cPDG\nWigVA2N8bkRnx4UH+wcfru+lYR8L8V6q4jD9cNQ6HuwrmqhGUEPIi60TkYlr\n2EUc+TPE2bbNbrEnEut1xWiwe2gsTqkr9RTGkFX7xZCd+0P41YnPlX0jXVgb\n7kD1GJGWA990U9NCwc59uTRI3bn2onHA42RSmFsADRl2uTGBMdgIbN7d2Uha\nXe6QImESiUSfA4Qk2/dJiMoeRtY1mzCiP/EVbZzwsfBkdoXPF8HOPbobATRD\ndCsHoPEd9HdRjqCo8K+yj8f7mGWItTI7DEPAsXuCqonWT5w8kdGKVw+ON61L\ncAM35IMqRD01JwOOJpgHnEMRQrYajG1I9e/0j5YvQ61jynVpjDKCgtSUXsdI\nes2hG/oQ9nXnxgUe6E4d1RhItAWbSSTI+qkqZqQLGqpuNFV2M/GWE/aAtBjc\nbQLZ\r\n=lqrs\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD7ezeJDh1Zuk7yd8ThdC/ruVQwhgGu5qOofY0CC6K2LQIgVo76p+7kD3aiBlDyErODBydkE9sEfleUrrAgio2SVmM="}]},"maintainers":[{"name":"vriad","email":"colin@vriad.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/trpc_0.5.0_1596956647956_0.6561861793438954"},"_hasShrinkwrap":false},"0.6.0":{"name":"trpc","version":"0.6.0","description":"TypeScript-first toolkit for building RPC APIs","main":"./lib/src/index.js","types":"./lib/src/index.d.ts","repository":{"type":"git","url":"git+https://github.com/vriad/trpc.git"},"author":{"name":"Colin McDonnell","email":"colin@vriad.com"},"license":"MIT","sideEffects":false,"bugs":{"url":"https://github.com/vriad/trpc/issues"},"homepage":"https://github.com/vriad/trpc","dependencies":{},"tags":[],"keywords":[],"include":["src"],"exclude":["node_modules","**/__tests__/*"],"scripts":{"clean":"rm -rf lib/*","build":"yarn run clean && tsc --p tsconfig.package.json","format":"prettier --write \"src/**/*.ts\" \"src/**/*.js\"","lint":"tslint -p tsconfig.json","test":"jest --config jestconfig.json --coverage","testone":"jest --config jestconfig.json","dryrun":"nodemon -e ts -w . -x ts-node src/dryrun.ts","prepublishOnly":"npm run build","play":"nodemon -e ts -w . -x ts-node src/playground.ts"},"devDependencies":{"@types/compression":"^1.7.0","@types/cors":"^2.8.7","@types/express":"^4.17.7","@types/jest":"^25.1.4","axios":"^0.19.2","compression":"^1.7.4","cors":"^2.8.5","express":"^4.17.1","jest":"^25.1.0","nodemon":"^2.0.2","prettier":"^2.0.5","ts-jest":"^25.2.1","typescript":"^4.0.0-dev.20200717","zod":"^1.10.1"},"gitHead":"9f36c863d42d7e13eeafd380d5318a0d09859489","_id":"trpc@0.6.0","_npmVersion":"6.4.1","_nodeVersion":"10.15.3","_npmUser":{"name":"vriad","email":"colin@vriad.com"},"dist":{"integrity":"sha512-1tlpFjGU+1zIhoSLCGUvDoq58a626jBrDQbbgVsuQJr83QFMZYnKCR8+x08shrVu45RXXfVeuHWWLPqkLZCJmw==","shasum":"4ff2db2847ca166a3b62b99e8a9f056d58e2c6f4","tarball":"https://registry.npmjs.org/trpc/-/trpc-0.6.0.tgz","fileCount":37,"unpackedSize":66386,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfL61xCRA9TVsSAnZWagAAJUcP+wfJGnulbM71OogMhYW4\nQo+mO23zEWFjnBsEF+mq5rmRhTLm0A3td83wQANKSec/R9OmA5KnH2HE+vJS\nNxIYUnJ7wWW6pCuqGxxuFp+lbsxX9z2wJb+ZXRyj0HmmT/vCZ6yhkZt6rfZU\nig+qPR/cTbC65x5Ak0mhDjUs1IhmH+FNBZTBKVohLy3b4uRuKfpYE9TRUN8W\nWavfvDYeExp3MULK3e6rInVAt/4p8bt8D6vsb9Kq1VI+fNt6TuCoPxCz/uRW\nSpqMX4kP6Ma80hPSfD049eXNGe7HMXmg5V2q49ooMRX+ImMuJEZBZhxKlrch\nSy+6fd6vMxboGPihOQSwnUYYuECh0ZlcmZuA/26Ciueev1wEvi269upDwUMv\n40nLMwxj5gSB0k2rs+PO/16OOqXlezhgcGI+aLi4l9JcdOUwPYPa2Y1r6PzP\ntPBTRpNJqcz0aA6H0XXgcAutO3Z3RVH2iYUfRLXHfdxLkOZF3uY/PNvtpaHv\nFiB+Fx8wV8IdZn9ziErMXQraHS5BhYg9Op+YEe3TxNvhvvm3bpGIVfUotVUq\nsmoLs94kz5z5o70+/Se+usFbJkdLelKkInOIJB547nbXBMNXt8zSYhZRxmEN\n9Y2uXVo9C+r8KKtskYCt6rSyomqvGchou//VV9FG50I90XpZJARwkSLnGWzS\n4TjW\r\n=V2Tw\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDWjeVoGuVbvKNJTQXTLebin9Enxb98zaH0o0M4XYGCTQIgCFQ4VJ6n5mGiWeTQ8knfp0xhcOcP5pG5DYDpxzb0scc="}]},"maintainers":[{"name":"vriad","email":"colin@vriad.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/trpc_0.6.0_1596960113398_0.07531322870974821"},"_hasShrinkwrap":false},"0.6.1":{"name":"trpc","version":"0.6.1","description":"TypeScript-first toolkit for building RPC APIs","main":"./lib/src/index.js","types":"./lib/src/index.d.ts","repository":{"type":"git","url":"git+https://github.com/vriad/trpc.git"},"author":{"name":"Colin McDonnell","email":"colin@vriad.com"},"license":"MIT","sideEffects":false,"bugs":{"url":"https://github.com/vriad/trpc/issues"},"homepage":"https://github.com/vriad/trpc","dependencies":{},"tags":[],"keywords":[],"include":["src"],"exclude":["node_modules","**/__tests__/*"],"scripts":{"clean":"rm -rf lib/*","build":"yarn run clean && tsc --p tsconfig.package.json","format":"prettier --write \"src/**/*.ts\" \"src/**/*.js\"","lint":"tslint -p tsconfig.json","test":"jest --config jestconfig.json --coverage","testone":"jest --config jestconfig.json","dryrun":"nodemon -e ts -w . -x ts-node src/dryrun.ts","prepublishOnly":"npm run build","play":"nodemon -e ts -w . -x ts-node src/playground.ts"},"devDependencies":{"@types/compression":"^1.7.0","@types/cors":"^2.8.7","@types/express":"^4.17.7","@types/jest":"^25.1.4","axios":"^0.19.2","compression":"^1.7.4","cors":"^2.8.5","express":"^4.17.1","jest":"^25.1.0","nodemon":"^2.0.2","prettier":"^2.0.5","ts-jest":"^25.2.1","typescript":"^4.0.0-dev.20200717","zod":"^1.10.1"},"gitHead":"dd42d83a17f7da7df6ad182c760e397220e931aa","_id":"trpc@0.6.1","_npmVersion":"6.4.1","_nodeVersion":"10.15.3","_npmUser":{"name":"vriad","email":"colin@vriad.com"},"dist":{"integrity":"sha512-njMSNQT/ltRlvmOrrni0ZURb6uAWvZMKhVihuk3XR0wsfYMbP5CEDXGkSY7sewZLnS1VSlGoAwPw4dyufY4YhA==","shasum":"8599e6d52192d9458159c72deb591d5ad807f6bd","tarball":"https://registry.npmjs.org/trpc/-/trpc-0.6.1.tgz","fileCount":37,"unpackedSize":66716,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfL7A0CRA9TVsSAnZWagAAoy8P/A128nkfkxT+L7aRPb/j\nFop0T9fSqJY6uLQQqgVF20O0NDJ44mlpLGR+c37PlRM2i4kD53AB7KBX7oKE\nUKFNRM8zFw1k3gO1xMlXXk+OLE93fF6vvjfbEZQSRT+fN58/XA/31rtOAM+F\nHsR89g7aQeX27gQp4CRg51nH8mJ79yWj+MCuLwKhnd9WKHevCARfzrC4Ik/G\nCfrHTNGNCKM1+lf922qZ2D/o03F13nr0j7xZrzBvZgA1CAL4bJ6aN6Y8kmAZ\nA3rDf4U6IPwbAlG4UzLvdRxNuqti3BBZ9NwwenUlZpAqCgGz5+md215GfboS\n+pxj990iik3CXHNyJBgCGNwXAEJwNsPrRuJPC8D8MFEIEomVCWWWFaHR1Uig\nXRVuRBtCEZDMpHV4YflPWQj9PJ3clAGIFM8Yhyzd8CQPAvBh4iCOUB7saZ0i\ni3h2Wd/V8Yq1JFNGEmoXHlcTMYSC3BUmaaOCzumgR+00EWzO9YZq1PYMclyL\nsNML+FkJJFl0n5WI+NlledJR4cxkNu64rxfTF9iBZtu/6Mdu0ie/XyHudXAF\nbU3sZcKl/RHoqI1DlNE+P2oOlW8ui1wVga/ceUju1hMWCFXD/oJcDjjodlVh\nz0RLguFCOkhYq1svGn+wHZO2VF+iBblZXjSjO71xak3EvPtZzTX2aFWVw3VT\nX1k+\r\n=uJf3\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDP94iWac3/xeTmPCxrvSabrU+JBGvlRPTLc9Pj9jZfEwIhAOKhNHGyhFgvcsI+1y688Ch8OL7A0eh3+pQl6M/GkjBN"}]},"maintainers":[{"name":"vriad","email":"colin@vriad.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/trpc_0.6.1_1596960819754_0.5357001050827217"},"_hasShrinkwrap":false},"0.6.2":{"name":"trpc","version":"0.6.2","description":"TypeScript-first toolkit for building RPC APIs","main":"./lib/src/index.js","types":"./lib/src/index.d.ts","repository":{"type":"git","url":"git+https://github.com/vriad/trpc.git"},"author":{"name":"Colin McDonnell","email":"colin@vriad.com"},"license":"MIT","sideEffects":false,"bugs":{"url":"https://github.com/vriad/trpc/issues"},"homepage":"https://github.com/vriad/trpc","dependencies":{},"tags":[],"keywords":[],"include":["src"],"exclude":["node_modules","**/__tests__/*"],"scripts":{"clean":"rm -rf lib/*","build":"yarn run clean && tsc --p tsconfig.package.json","format":"prettier --write \"src/**/*.ts\" \"src/**/*.js\"","lint":"tslint -p tsconfig.json","test":"jest --config jestconfig.json --coverage","testone":"jest --config jestconfig.json","dryrun":"nodemon -e ts -w . -x ts-node src/dryrun.ts","prepublishOnly":"npm run build","play":"nodemon -e ts -w . -x ts-node src/playground.ts"},"devDependencies":{"@types/compression":"^1.7.0","@types/cors":"^2.8.7","@types/express":"^4.17.7","@types/jest":"^25.1.4","axios":"^0.19.2","compression":"^1.7.4","cors":"^2.8.5","express":"^4.17.1","jest":"^25.1.0","nodemon":"^2.0.2","prettier":"^2.0.5","ts-jest":"^25.2.1","typescript":"^4.0.0-dev.20200717","zod":"^1.10.1"},"gitHead":"0341af1af35d1f04e9de2eac26377c7178a7dcbc","_id":"trpc@0.6.2","_npmVersion":"6.4.1","_nodeVersion":"10.15.3","_npmUser":{"name":"vriad","email":"colin@vriad.com"},"dist":{"integrity":"sha512-0RI8EGQgHA+bUKA17GCpm0q1d0qnRekDLbqLc0zVQLbMuSE2EJFLaX3MX4Fth2se7Phw0JBfEsqk/j2zAP9Ylw==","shasum":"87d13e07ccbece39da9c8d7bc84b23f3423842c6","tarball":"https://registry.npmjs.org/trpc/-/trpc-0.6.2.tgz","fileCount":37,"unpackedSize":64472,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfL7GeCRA9TVsSAnZWagAAMxEP/0ter1yJig7/MRfp1JBZ\nq/6s3tXgbZOmLe0I4NZrqvt1J2oQq4Ffa5GsVCdOS/ooCWVOqxJ7zCS2Bfo3\neP6P4G+bBMU9PHqFeEJS90RA6mnwbjuszgE0jN6NR0RgKHZwQNf04VJZlLit\nTaqVzQdyYZWf02IQLa2rd7hbN1FAEFw0Q9o7Hfnf9EhK7VGlvH3bv5C27Uv1\nM/7QyQgmY8rDJbc1Edaeo2N/zsTHeP/BrBJm/enEHxOBtIeSNnpPujqRCG04\nVQ3Kt0Pex7kl76nZcyh/WQeCv5TV3yypVhdCvq9mdWYgecvkO6Qj8CRyd5ov\nIKQdkJwqtt5Xtno/LhS3xRfwuj8oFCP5LawpDrStDbCUeDU4vdGVGl4Idq0C\nIeLMOXgvIvvnq+MJwatkca2X88kBO2WKLPGspSCzt6A99zHDno2rqsH5lIBt\nQuilQ8qhvTu+SORcvjtrO5jQePBejc1sA4ks3QR3f2RK8yaopDEle4zG/QHo\nfGGhKPEi8OlwgpY7hCCkNDFXESM1Wi/fNAunYwg+Llwe53hl3Ybt25CMyxgO\nWPqAD4S9+I7UIImMIL4tH/iuk6+tbj4rGKrlzV3rSHJSFgQH4UCFBzoWMZp2\nWELPDCcbhFqLi9YAdAE20IqdiMfUEcpmWj/b96hw8zioAut57FplCZF7Zy0V\nQf99\r\n=okq4\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD8F0eK8wTuFbjYyLYwBnfHNKJAKXupJ+bFu2goNgKrWQIhAOtpRu52i6oCKyRPRD0TY2Tamc7SwJEz1f2ZqOHrw8ff"}]},"maintainers":[{"name":"vriad","email":"colin@vriad.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/trpc_0.6.2_1596961181780_0.721590682987221"},"_hasShrinkwrap":false},"0.7.0":{"name":"trpc","version":"0.7.0","description":"TypeScript-first toolkit for building RPC APIs","main":"./lib/src/index.js","types":"./lib/src/index.d.ts","repository":{"type":"git","url":"git+https://github.com/vriad/trpc.git"},"author":{"name":"Colin McDonnell","email":"colin@vriad.com"},"license":"MIT","sideEffects":false,"bugs":{"url":"https://github.com/vriad/trpc/issues"},"homepage":"https://github.com/vriad/trpc","dependencies":{},"tags":[],"keywords":[],"include":["src"],"exclude":["node_modules","**/__tests__/*"],"scripts":{"clean":"rm -rf lib/*","build":"yarn run clean && tsc --p tsconfig.package.json","format":"prettier --write \"src/**/*.ts\" \"src/**/*.js\"","lint":"tslint -p tsconfig.json","test":"jest --config jestconfig.json --coverage","testone":"jest --config jestconfig.json","dryrun":"nodemon -e ts -w . -x ts-node src/dryrun.ts","prepublishOnly":"npm run build","play":"nodemon -e ts -w . -x ts-node src/playground.ts"},"devDependencies":{"@types/compression":"^1.7.0","@types/cors":"^2.8.7","@types/express":"^4.17.7","@types/jest":"^25.1.4","axios":"^0.19.2","compression":"^1.7.4","cors":"^2.8.5","express":"^4.17.1","jest":"^25.1.0","nodemon":"^2.0.2","prettier":"^2.0.5","ts-jest":"^25.2.1","typescript":"^4.0.0-dev.20200717","zod":"^1.10.1"},"gitHead":"f4357f4f973d76e94f4a4d3c2304ba4f69bfdfa8","_id":"trpc@0.7.0","_npmVersion":"6.4.1","_nodeVersion":"10.15.3","_npmUser":{"name":"vriad","email":"colin@vriad.com"},"dist":{"integrity":"sha512-aimXuFKqogCizreqtWCJypjGVjAKmYxzUqNo/2DpzZhlWabPf+v0SuyZoQOC+zjfx8dKFFd3nBj6KMLaCtnnGA==","shasum":"e3d5bc9ecf269f7540940acb2f5f73b6fb17cb6b","tarball":"https://registry.npmjs.org/trpc/-/trpc-0.7.0.tgz","fileCount":31,"unpackedSize":55518,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfMRQ2CRA9TVsSAnZWagAA9IYP/04vbQOewxf6tHc7fLrL\nSHDGqNF+M/YRm2yPZoW+uhw1EZFJyZQETkszsayZanpT3Drf5os0EXsc06lu\nLt2AoKfW7dc9R30RkN2UrHWvU1/X+sIs5DiyJYlmURn1AlHvs22Fym9UI7YG\ni3njII3RIMhCFU5cJzUr6mL8RCIE3z1Zb1ROhh6w6MmgWwXBjj4bRNp9YvOr\nMQnfKFQvetDm6Gkh9X1rwIeXoCj6zJyXnSSNabyA94wuZuk1alItxc2nRvzl\n56bkHKhQ9XS6yZLlRYvWsMJx2YxjBy46N7M70DH5UAWHM2B+n2w3YEmHKQIx\nvqAiFxSKF2ejKL7WV9k8f3PJhKsaBEHxbl0oSZUIvYjLmvAXc2WPrwxspRZj\nuSiKTZ8VDX0GTFpvaZ2hCE0U2hjqD6ibEF2yhE7nGuT4IVzjpfoJc3zY9UDg\nYhmghsJ7wzmzXKdNgt1RY+4FcDZ4UfnAEuC95xuYg82e6fMzDKbu8eHpaWkw\nwrbtMRGtU9EsHOVe/fk6NQTmO1bcu57Gv7dOPTae7RNLz4YI9gVaGZK+Zkkp\nHNlMBZ7SJyO+eHmaC4y0Qd/DKNbMlaHj2vEo8log7VaEl8WXqzUHjhJFHst4\nhZWXYZFVvCdUHype+HLv41lXbQIAgYiwQpB4v6+kYay3NRR+vCFOghsJABUr\noEmi\r\n=+Yap\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCtWEju2zp9tN3/PJ93/lVwdhyHwPBlKyEKwUM93AaipwIhAKrP20sWmiQxIjFrxSJjkSHcmC/KAtK/b1/CWACws/3i"}]},"maintainers":[{"name":"vriad","email":"colin@vriad.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/trpc_0.7.0_1597051957997_0.6254074058760661"},"_hasShrinkwrap":false},"0.8.0":{"name":"trpc","version":"0.8.0","description":"TypeScript-first toolkit for building RPC APIs","main":"./lib/src/index.js","types":"./lib/src/index.d.ts","repository":{"type":"git","url":"git+https://github.com/vriad/trpc.git"},"author":{"name":"Colin McDonnell","email":"colin@vriad.com"},"license":"MIT","sideEffects":false,"bugs":{"url":"https://github.com/vriad/trpc/issues"},"homepage":"https://github.com/vriad/trpc","dependencies":{},"tags":[],"keywords":[],"include":["src"],"exclude":["node_modules","**/__tests__/*"],"scripts":{"clean":"rm -rf lib/*","build":"yarn run clean && tsc --p tsconfig.package.json","format":"prettier --write \"src/**/*.ts\" \"src/**/*.js\"","lint":"tslint -p tsconfig.json","test":"jest --config jestconfig.json --coverage","testone":"jest --config jestconfig.json","dryrun":"nodemon -e ts -w . -x ts-node src/dryrun.ts","prepublishOnly":"npm run build","play":"nodemon -e ts -w . -x ts-node src/playground.ts"},"devDependencies":{"@types/compression":"^1.7.0","@types/cors":"^2.8.7","@types/express":"^4.17.7","@types/jest":"^25.1.4","axios":"^0.19.2","compression":"^1.7.4","cors":"^2.8.5","express":"^4.17.1","jest":"^25.1.0","nodemon":"^2.0.2","prettier":"^2.0.5","ts-jest":"^25.2.1","typescript":"3.2","zod":"^1.10.1"},"gitHead":"e5726952a82db173b0d6a24aa9f10e1983e93df0","_id":"trpc@0.8.0","_npmVersion":"6.4.1","_nodeVersion":"10.15.3","_npmUser":{"name":"vriad","email":"colin@vriad.com"},"dist":{"integrity":"sha512-nekcQDxMAT866Ku/a9MK6uFuszqNchbo9cFfzvFJ2JUCkcakciqcAzbJW1xIMm/GcPf7MlRLyziQFI7LasHPFA==","shasum":"f9bcadcc1af7e4b6f5f1be39b30f6f19751fad59","tarball":"https://registry.npmjs.org/trpc/-/trpc-0.8.0.tgz","fileCount":34,"unpackedSize":58787,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfPfvYCRA9TVsSAnZWagAAP/QQAKHxO2XxWmkd7ZsSY7i3\n/1Rd7IQvELdkcYpZ5B8DvVHinEQcMp7+berWXu1fzeREUCOG6onmEA863gdT\nhC5mPL+bRq4jQaxCOOu4TEKW6M3SLsYwfUUX3mg23CJqxSwv+HPZF92f8hfQ\nDQ2t1+fSL9Obq6bdvWunbIkkCtvxctXSnkAXVvXm3ysCt9SqJtcuXJ4kMD4+\nCNQfJLfbr/r9mv+PxYoA0+sECGf6s86l97sp724+mBAZZC5EQyT2yNTf+nqK\n6Gf5Qp6+16ht+MZuH+wtP4zNksfVX3hgRaMpzSNmjcGcVCkV34kk2Wo9RjMt\nFxbNvyKAUx406Q1M63shs1xXvN5dqkLnKatX1yJUPynRuKb2WtbEPU/HUBLR\nkluwGEADsRPsoRGrZI4VAwfwjkq7W1zxEmwLrx5nZ0WTHU/9u3wX1xVvpbUi\nKlmF0thNKLlNNQ9D3ASDaUhxF6hmRITlOkKUqSpum2F6eyLUSjIYI99y9VfN\nGlkP9OeIdbv4d1G0Lh1nGh06jr/6oSs/RbIs0RBcjRQcb7MYTrEqKM01hUoN\nDO7lhzth/g6K4VwYPncJ3uK+4nyikyvYjcBxw4mhjkgvtQ37qOK7vuPIUPVa\nXq4GCW7ux7hUV41VZPkCgGBF7uSXXh0Eu5v5zhNOfjAHebNwaITqu6Pi7l1k\n7Xsk\r\n=3zx1\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD8E6MYgHGfGoFSyFxgBNRrpSMUfNGVi4k8XdVYM+4t4AIhALaE2ajdaCYtNQEP1Pmd/P4MPZ+ooMNXUO0KWuffwoCQ"}]},"maintainers":[{"name":"vriad","email":"colin@vriad.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/trpc_0.8.0_1597897687290_0.07974044545179493"},"_hasShrinkwrap":false},"0.8.1":{"name":"trpc","version":"0.8.1","description":"TypeScript-first toolkit for building RPC APIs","main":"./lib/src/index.js","types":"./lib/src/index.d.ts","repository":{"type":"git","url":"git+https://github.com/vriad/trpc.git"},"author":{"name":"Colin McDonnell","email":"colin@vriad.com"},"license":"MIT","sideEffects":false,"bugs":{"url":"https://github.com/vriad/trpc/issues"},"homepage":"https://github.com/vriad/trpc","dependencies":{},"tags":[],"keywords":[],"include":["src"],"exclude":["node_modules","**/__tests__/*"],"scripts":{"clean":"rm -rf lib/*","build":"yarn run clean && tsc --p tsconfig.package.json","format":"prettier --write \"src/**/*.ts\" \"src/**/*.js\"","lint":"tslint -p tsconfig.json","test":"jest --config jestconfig.json --coverage","testone":"jest --config jestconfig.json","dryrun":"nodemon -e ts -w . -x ts-node src/dryrun.ts","prepublishOnly":"npm run build","play":"nodemon -e ts -w . -x ts-node src/playground.ts"},"devDependencies":{"@types/compression":"^1.7.0","@types/cors":"^2.8.7","@types/express":"^4.17.7","@types/jest":"^25.1.4","axios":"^0.19.2","compression":"^1.7.4","cors":"^2.8.5","express":"^4.17.1","jest":"^25.1.0","nodemon":"^2.0.2","prettier":"^2.0.5","ts-jest":"^25.2.1","typescript":"3.2","zod":"^1.10.1"},"readme":"<div align=\"center\">\n  <h1 align=\"center\">tRPC</h1>\n  <p>a toolkit for building end-to-end TypeScript data layers</p>\n</div>\n\n<br/>\n<br/>\n\n# Motivation\n\n⚠️ This library is undergoing rapid development and should be considered experimental. Not recommended for use in production. 🤙\n\ntRPC is a framework for building strongly typed RPC APIs with TypeScript. Alternatively, you can think of it as a way to avoid APIs altogether.\n\n# Usage\n\n### Installation\n\n`npm install trpc`\n\n`yarn add trpc`\n\n### Importing\n\n```ts\nimport { trpc } from 'trpc';\n```\n\n### Compatibility\n\ntRPC depends on the Proxy API and dynamic imports, both of which are [not supported in IE11 and earlier](https://caniuse.com/#feat=proxy).\n\nCompatible with TypeScript 3.2+.\n\n## Define your endpoints\n\n`trpc.endpoint(func: (ctx: any) => (...args: any[]) => any)=>TRPCEndpoint`\n\nInstantiate an endpoint with `trpc.endpoint()`. This function takes a _function that returns a function_.\n\n```ts\nconst computeLength = trpc.endpoint(() => (data: string) => {\n  return data.length;\n});\n```\n\nThe outer function can (optionally) accept a single `ctx` argument. This is how tRPC makes the `ctx` of your RPC calls avaiable to your endpoint logic.\n\n<!-- If you don't need context, you should include it. You'll see why later. Naming the variable `_ctx` will prevent TypeScript from complaining about unused variables. -->\n\n```ts\ntype Ctx = { token: string };\n\nconst getUsername = trpc.endpoint((ctx: Ctx) => () => {\n  const user = await getUserFromToken(ctx.token);\n  return user.username;\n});\n```\n\nThat is a simple endpoint that doesn't actually accept any inputs. Here's a more complex example that posts new \"tweets\" to the user's account.\n\n```ts\ntype Ctx = { token: string };\n\nconst postTweet = trpc.endpoint((ctx: Ctx) => (data: { content: string }) => {\n  const user = await getUserFromToken(ctx.token);\n  const newTweet = await createTweet({\n    content: data.content,\n    userId: user.id,\n  });\n  return newTweet;\n});\n```\n\n## Implement authorization\n\ntRPC provides a built-in way to add authorization logic to your endpoints using the `.authorize` method. **By default all incoming requests are rejected!**\n\n`.authorize` accepts a _function that returns a function_, just like `trpc.endpoint`. It must return a boolean. You can use `ctx` or the endpoint's arguments to determine whether to allow the request.\n\n```ts\nconst getUsername = trpc\n  .endpoint((ctx: Ctx) => async () => {\n    const user = await getUserFromToken(ctx.token);\n    return user.username;\n  })\n  .authorize((ctx) => async (data) => {\n    if (!ctx.token) return false;\n    return true;\n  });\n```\n\n## Define your router(s)\n\n`trpc.router()=>TRPCRouter`\n\nRouters are collections of endpoints. Here's how to create a router and add the `getUsername` endpoint we created above.\n\n```ts\nconst userRouter = trpc.router().endpoint('getUsername', getUsername);\n```\n\nTo add multiple endpoints, you _must chain_ the calls to `.endpoint()`.\n\n```ts\nconst userRouter = trpc\n  .router()\n  .endpoint('getUsername', getUsername)\n  .endpoint('postTweet', postTweet);\n```\n\nIf you're used to Express you may be tempted to try this:\n\n```ts\n// DONT DO THIS\nconst stringRouter = trpc.router();\n\nstringRouter.endpoint('getById', getUserById);\nstringRouter.endpoint('otherEndpoint', otherEndpoint);\n```\n\nThis won't work. In `trpc` routers are _immutable_. The `.endpoint()` method returns an entirely new router, so you must chain the calls.\n\n## Compose multiple routers\n\nYou can compose routers into hierarchies. Below we create a `rootRouter` with one endpoint (`computeLength`, defined above) and one child router (`userRouter`, defined above, aliased to `user`). This will be important later.\n\n```ts\nconst rootRouter = trpc\n  .router()\n  .endpoint('computeLength', computeLength)\n  .compose('user', userRouter);\n```\n\n## Handle requests\n\n`router.handle(payload: Payload)=>any`\n\nThe `Payload` type is:\n\n```ts\ntype Payload = {\n  path: string[];\n  context: any;\n  args: any[];\n};\n```\n\nRouters can handle \"requests\" using the `.handle` method.\n\n```ts\nrootRouter.handle({\n  endpoint: ['computeLength'],\n  context: {},\n  args: ['this is a sample string'],\n}); // => Promise<23>\n\nrootRouter.handle({\n  endpoint: ['user', 'postTweet'],\n  context: { token: `SAMPLE_TOKEN` },\n  args: [{ content: 'just setting up my twttr' }],\n}); // => Promise<{ /* new Tweet object */ }>\n```\n\n### Express\n\nThere is a convenience function for generating an Express middleware from your router.\n\n```ts\nimport express from 'express';\nimport bodyParser from 'body-parser';\n\nexport const app = express();\napp.use(bodyParser.json());\n\n// serve requests\napp.post('/rpc', rootRouter.toExpress());\n```\n\nSimilar to GraphQL, your entire API is exposed over a single endpoint (in this case `/rpc`). All incoming requests should POST to this endpoint with a body of type `Payload` (defined above).\n\n## Creating a server SDK\n\ntRPC automatically tracks the structure of your router hierarchy and the input/output types of your endpoint. This means we can do some exciting things.\n\ntRPC can autogenerate an \"server SDK\" from any router like so:\n\n```ts\nconst serverSDK = rootRouter.toServerSDK();\n\n// synchronous\nconst asdfLength = serverSDK.computeLength({}, 'asdf'); // => 4\n\nconst username = await serverSDK.user.getUsername({ token: 'SAMPLE_TOKEN' });\n// Promise<\"username\">\n\nconst newTweet = await serverSDK.user.postTweet(\n  { token: 'SAMPLE_TOKEN' },\n  {\n    content: 'just setting up my twttr',\n  },\n);\n// Promise<\"username\">\n```\n\nThe first argument to _all_ server SDK calls is the context. Just pass an empty object if your endpoint doesn't use context.\n\nThis is useful for server environments. It provides a standard way to call your own APIs without any code duplication. Plus it **automatically bypasses all authorization checks**. Do not accidentally make this available to any client side code!\n\n## Creating a client SDK\n\n⚠️ Follow the instructions below very carefully! Otherwise you may accidentally expose your server code to the client.\n\nIt's easier than ever to share code between your client and server. The example code below assumes you have a way to do this, either using a tool like [Yarn Workspaces](https://classic.yarnpkg.com/en/docs/workspaces/)/[Lerna](https://github.com/lerna/lerna) or a framework like [Next.js](https://nextjs.org/).\n\n<!-- The days of auto-generating an SDK from OpenAPI specifications — and GraphQL definition files 🙄 — is over. -->\n\n```ts\n// server.ts\n\nexport const rootRouter = /* define router here */;\n```\n\n```ts\n// client.tsx\n\nimport { trpc } from 'trpc';\n\n// only import the TypeScript type of your router!\n// this uses dynamic imports\ntype RootRouter = typeof import('../path/to/server.ts').rootRouter;\n\n// pass in your router type\n// as a generic parameter to trpc.sdk\nconst clientSDK = trpc.sdk<RootRouter>({\n  url: 'http:localhost:3000',\n  getContext: async () => {\n    const token = await getTokenFromCookies();\n    return { token };\n  },\n});\n```\n\nAs you can see, `trpc.sdk()` accepts a params object with the following keys:\n\n- `url: string` — the URL of your tRPC endpoint, e.g. `http://localhost:3000/rpc`\n- `getContext: ()=>Promise<any>` — an async function for gathering/computing/fetching any `context` data for the request. This is where you should return the cookies/tokens you'd like to pass with the request. The returned value will be provided to your endpoints in the `ctx` argument.\n\n```ts\nawait clientSDK.computeLength('asdf'); // => Promise<4>\nawait clientSDK.user.getUsername(); // => Promise<\"username\">\nawait clientSDK.user.postTweet({ content: 'hello world' });\n```\n\nThe client SDK always returns a Promise, even if the server-side logic in synchronous, since the SDK is making a round-trip HTTP request under the hood.\n\nThere's no need to pass a context object as the first input (as with the server SDK) because the context object is produced by the `getContext` function you passed into `trpc.sdk`.\n\n### Custom request handler\n\nBy default tRPC uses Axios to send requests to the `url` you specify in the SDK params. Optionally you can provide an entirely custom HTTP request handler using with `handler`:\n\n```ts\nconst clientSDK = trpc.sdk<RootRouter>({\n  url: 'http:localhost:3000',\n  getContext: async () => {\n    const token = await getTokenFromCookies();\n    return { token };\n  },\n  handler: async (url, payload) => {\n    const result = await fetch(url, {\n      method: 'POST',\n      headers: {\n        'Content-Type': 'application/json',\n      },\n      body: payload,\n    });\n    return result.json();\n  },\n});\n```\n\n## Usage patterns\n\n- TODO: runtime validation with Zod\n- TODO: React Hook\n- TODO: Next.js/SWR\n","readmeFilename":"README.md","gitHead":"51a6cd89c08ba873d12bba716387081728eefa2a","_id":"trpc@0.8.1","_npmVersion":"6.4.1","_nodeVersion":"10.15.3","_npmUser":{"name":"vriad","email":"colin@vriad.com"},"dist":{"integrity":"sha512-tqsxQhLUAc+ChdxgSZVKhtmjuVZ0aZtXb+JD7QH5Uhc7wapjhQ5cYA3/Bs0a/YOoe8zqufUi9Pq0bEgXIYRwKA==","shasum":"ecb3343644bfac6c6be64a355b2e0c7635b6a7f0","tarball":"https://registry.npmjs.org/trpc/-/trpc-0.8.1.tgz","fileCount":34,"unpackedSize":60979,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfPxTCCRA9TVsSAnZWagAA4rkP/AjqmYokO95tsYlnc3Io\nnm5jyXBnnsEyoWaQ0u7GbGrC95NtIUBVv+pSDANZpppfUDHiTh5cS6+TDUSE\nIVeo0tQkdctgVi5Jo+qdRkbhfVNDNagX5rc5NH2H2W6dCcWfqWYGoDrgvEDq\nCOUgrRWDsfIw4FgKU3dPtKaYaJLJoEYpSDvMt5ASKg6r0r/Y8iSxMbpqANh7\nah2oDYR18385exKNPzkpC36huGAbMgBEK+StGr/d2PPHUw/tqL+L7kWbPdo0\ntpqqN5eROuxjdgBVPfsreA8AbePL8opA4eUGEfWeM3aHt1CYqafvxwmphsWE\nZycGp/qaBbaU+nBeK4/J/IRlH6GV2n7T2fwrEwlvDF83t3pGa1v0F8A4JTYs\n89remYAQJftuJEnVFKruP+r4j1glXM+UHTe667OApSDROhFkZw+ja5TqkCjX\n/4CaaQk8saiwKwXabI8GL7ZnUMkA21Yv45UyawQ1i0na9xSO2sY4lmdlKP0d\nxINRNrIVJXiNTFC4YMgtkAqC+Y1G91jYwGs/VTJccIKTskMUV9TirNp9ecCp\nDDMrFvNQHzboiHv7g1KZwMIMvAIn9+VxYbDxJmqhMtLcHV1nMXY6e51LQZ9z\nVHWSgVyb0CEEjMfCHzcOEvJkM+SUNxBSzBTah3g2lfyA3c2MKA5xjLPs0INf\nMaAo\r\n=JaTE\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHEyl5BsNIth0RFMAFL+oNPR5H3SO4KDBqQNE+S1Wl+PAiEA1nGUZVkR0p52x63ezGkmJd97dXQIhI/ZX/ErNjAuGa0="}]},"maintainers":[{"name":"vriad","email":"colin@vriad.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/trpc_0.8.1_1597969601977_0.09501288065855773"},"_hasShrinkwrap":false},"0.8.2":{"name":"trpc","version":"0.8.2","description":"TypeScript-first toolkit for building RPC APIs","main":"./lib/src/index.js","types":"./lib/src/index.d.ts","repository":{"type":"git","url":"git+https://github.com/vriad/trpc.git"},"author":{"name":"Colin McDonnell","email":"colin@vriad.com"},"license":"MIT","sideEffects":false,"bugs":{"url":"https://github.com/vriad/trpc/issues"},"homepage":"https://github.com/vriad/trpc","dependencies":{},"tags":[],"keywords":[],"include":["src"],"exclude":["node_modules","**/__tests__/*"],"scripts":{"clean":"rm -rf lib/*","build":"yarn run clean && tsc --p tsconfig.package.json","format":"prettier --write \"src/**/*.ts\" \"src/**/*.js\"","lint":"tslint -p tsconfig.json","test":"jest --config jestconfig.json --coverage","testone":"jest --config jestconfig.json","dryrun":"nodemon -e ts -w . -x ts-node src/dryrun.ts","prepublishOnly":"npm run build","play":"nodemon -e ts -w . -x ts-node src/playground.ts"},"devDependencies":{"@types/compression":"^1.7.0","@types/cors":"^2.8.7","@types/express":"^4.17.7","@types/jest":"^25.1.4","axios":"^0.19.2","compression":"^1.7.4","cors":"^2.8.5","express":"^4.17.1","jest":"^25.1.0","nodemon":"^2.0.2","prettier":"^2.0.5","ts-jest":"^25.2.1","typescript":"3.2","zod":"^1.10.1"},"readme":"<div align=\"center\">\n  <h1 align=\"center\">tRPC</h1>\n  <p>a toolkit for building end-to-end TypeScript data layers</p>\n</div>\n\n<br/>\n<br/>\n\n# Motivation\n\n⚠️ This library is undergoing rapid development and should be considered experimental. Not recommended for use in production. 🤙\n\ntRPC is a framework for building strongly typed RPC APIs with TypeScript. Alternatively, you can think of it as a way to avoid APIs altogether.\n\n# Usage\n\n### Installation\n\n`npm install trpc`\n\n`yarn add trpc`\n\n### Importing\n\n```ts\nimport { trpc } from 'trpc';\n```\n\n### Compatibility\n\ntRPC depends on the Proxy API and dynamic imports, both of which are [not supported in IE11 and earlier](https://caniuse.com/#feat=proxy).\n\nCompatible with TypeScript 3.2+.\n\n## Define your endpoints\n\n`trpc.endpoint(func: (ctx: any) => (...args: any[]) => any)=>TRPCEndpoint`\n\nInstantiate an endpoint with `trpc.endpoint()`. This function takes a _function that returns a function_.\n\n```ts\nconst computeLength = trpc.endpoint(() => (data: string) => {\n  return data.length;\n});\n```\n\nThe outer function can (optionally) accept a single `ctx` argument. This is how tRPC makes the `ctx` of your RPC calls avaiable to your endpoint logic.\n\n<!-- If you don't need context, you should include it. You'll see why later. Naming the variable `_ctx` will prevent TypeScript from complaining about unused variables. -->\n\n```ts\ntype Ctx = { token: string };\n\nconst getUsername = trpc.endpoint((ctx: Ctx) => () => {\n  const user = await getUserFromToken(ctx.token);\n  return user.username;\n});\n```\n\nThat is a simple endpoint that doesn't actually accept any inputs. Here's a more complex example that posts new \"tweets\" to the user's account.\n\n```ts\ntype Ctx = { token: string };\n\nconst postTweet = trpc.endpoint((ctx: Ctx) => (data: { content: string }) => {\n  const user = await getUserFromToken(ctx.token);\n  const newTweet = await createTweet({\n    content: data.content,\n    userId: user.id,\n  });\n  return newTweet;\n});\n```\n\n## Implement authorization\n\ntRPC provides a built-in way to add authorization logic to your endpoints using the `.authorize` method. **By default all incoming requests are rejected!**\n\n`.authorize` accepts a _function that returns a function_, just like `trpc.endpoint`. It must return a boolean. You can use `ctx` or the endpoint's arguments to determine whether to allow the request.\n\n```ts\nconst getUsername = trpc\n  .endpoint((ctx: Ctx) => async () => {\n    const user = await getUserFromToken(ctx.token);\n    return user.username;\n  })\n  .authorize((ctx) => async (data) => {\n    if (!ctx.token) return false;\n    return true;\n  });\n```\n\n## Define your router(s)\n\n`trpc.router()=>TRPCRouter`\n\nRouters are collections of endpoints. Here's how to create a router and add the `getUsername` endpoint we created above.\n\n```ts\nconst userRouter = trpc.router().endpoint('getUsername', getUsername);\n```\n\nTo add multiple endpoints, you _must chain_ the calls to `.endpoint()`.\n\n```ts\nconst userRouter = trpc\n  .router()\n  .endpoint('getUsername', getUsername)\n  .endpoint('postTweet', postTweet);\n```\n\nIf you're used to Express you may be tempted to try this:\n\n```ts\n// DONT DO THIS\nconst stringRouter = trpc.router();\n\nstringRouter.endpoint('getById', getUserById);\nstringRouter.endpoint('otherEndpoint', otherEndpoint);\n```\n\nThis won't work. In `trpc` routers are _immutable_. The `.endpoint()` method returns an entirely new router, so you must chain the calls.\n\n## Compose multiple routers\n\nYou can compose routers into hierarchies. Below we create a `rootRouter` with one endpoint (`computeLength`, defined above) and one child router (`userRouter`, defined above, aliased to `user`). This will be important later.\n\n```ts\nconst rootRouter = trpc\n  .router()\n  .endpoint('computeLength', computeLength)\n  .compose('user', userRouter);\n```\n\n## Handle requests\n\n`router.handle(payload: Payload)=>any`\n\nThe `Payload` type is:\n\n```ts\ntype Payload = {\n  path: string[];\n  context: any;\n  args: any[];\n};\n```\n\nRouters can handle \"requests\" using the `.handle` method.\n\n```ts\nrootRouter.handle({\n  endpoint: ['computeLength'],\n  context: {},\n  args: ['this is a sample string'],\n}); // => Promise<23>\n\nrootRouter.handle({\n  endpoint: ['user', 'postTweet'],\n  context: { token: `SAMPLE_TOKEN` },\n  args: [{ content: 'just setting up my twttr' }],\n}); // => Promise<{ /* new Tweet object */ }>\n```\n\n### Express\n\nThere is a convenience function for generating an Express middleware from your router.\n\n```ts\nimport express from 'express';\nimport bodyParser from 'body-parser';\n\nexport const app = express();\napp.use(bodyParser.json());\n\n// serve requests\napp.post('/rpc', rootRouter.toExpress());\n```\n\nSimilar to GraphQL, your entire API is exposed over a single endpoint (in this case `/rpc`). All incoming requests should POST to this endpoint with a body of type `Payload` (defined above).\n\n## Creating a server SDK\n\ntRPC automatically tracks the structure of your router hierarchy and the input/output types of your endpoint. This means we can do some exciting things.\n\ntRPC can autogenerate an \"server SDK\" from any router like so:\n\n```ts\nconst serverSDK = rootRouter.toServerSDK();\n\n// synchronous\nconst asdfLength = serverSDK.computeLength({}, 'asdf'); // => 4\n\nconst username = await serverSDK.user.getUsername({ token: 'SAMPLE_TOKEN' });\n// Promise<\"username\">\n\nconst newTweet = await serverSDK.user.postTweet(\n  { token: 'SAMPLE_TOKEN' },\n  {\n    content: 'just setting up my twttr',\n  },\n);\n// Promise<\"username\">\n```\n\nThe first argument to _all_ server SDK calls is the context. Just pass an empty object if your endpoint doesn't use context.\n\nThis is useful for server environments. It provides a standard way to call your own APIs without any code duplication. Plus it **automatically bypasses all authorization checks**. Do not accidentally make this available to any client side code!\n\n## Creating a client SDK\n\n⚠️ Follow the instructions below very carefully! Otherwise you may accidentally expose your server code to the client.\n\nIt's easier than ever to share code between your client and server. The example code below assumes you have a way to do this, either using a tool like [Yarn Workspaces](https://classic.yarnpkg.com/en/docs/workspaces/)/[Lerna](https://github.com/lerna/lerna) or a framework like [Next.js](https://nextjs.org/).\n\n<!-- The days of auto-generating an SDK from OpenAPI specifications — and GraphQL definition files 🙄 — is over. -->\n\n```ts\n// server.ts\n\nexport const rootRouter = /* define router here */;\n```\n\n```ts\n// client.tsx\n\nimport { trpc } from 'trpc';\n\n// only import the TypeScript type of your router!\n// this uses dynamic imports\ntype RootRouter = typeof import('../path/to/server.ts').rootRouter;\n\n// pass in your router type\n// as a generic parameter to trpc.sdk\nconst clientSDK = trpc.sdk<RootRouter>({\n  url: 'http:localhost:3000',\n  getContext: async () => {\n    const token = await getTokenFromCookies();\n    return { token };\n  },\n});\n```\n\nAs you can see, `trpc.sdk()` accepts a params object with the following keys:\n\n- `url: string` — the URL of your tRPC endpoint, e.g. `http://localhost:3000/rpc`\n- `getContext: ()=>Promise<any>` — an async function for gathering/computing/fetching any `context` data for the request. This is where you should return the cookies/tokens you'd like to pass with the request. The returned value will be provided to your endpoints in the `ctx` argument.\n\n```ts\nawait clientSDK.computeLength('asdf'); // => Promise<4>\nawait clientSDK.user.getUsername(); // => Promise<\"username\">\nawait clientSDK.user.postTweet({ content: 'hello world' });\n```\n\nThe client SDK always returns a Promise, even if the server-side logic in synchronous, since the SDK is making a round-trip HTTP request under the hood.\n\nThere's no need to pass a context object as the first input (as with the server SDK) because the context object is produced by the `getContext` function you passed into `trpc.sdk`.\n\n### Custom request handler\n\nBy default tRPC uses Axios to send requests to the `url` you specify in the SDK params. Optionally you can provide an entirely custom HTTP request handler using with `handler`:\n\n```ts\nconst clientSDK = trpc.sdk<RootRouter>({\n  url: 'http:localhost:3000',\n  getContext: async () => {\n    const token = await getTokenFromCookies();\n    return { token };\n  },\n  handler: async (url, payload) => {\n    const result = await fetch(url, {\n      method: 'POST',\n      headers: {\n        'Content-Type': 'application/json',\n      },\n      body: payload,\n    });\n    return result.json();\n  },\n});\n```\n\n## Usage patterns\n\n- TODO: runtime validation with Zod\n- TODO: React Hook\n- TODO: Next.js/SWR\n","readmeFilename":"README.md","gitHead":"26ca44f70074e33c13ea37d3d99f9cb700ca74fc","_id":"trpc@0.8.2","_npmVersion":"6.4.1","_nodeVersion":"10.15.3","_npmUser":{"name":"vriad","email":"colin@vriad.com"},"dist":{"integrity":"sha512-YVUABtsFOapHN8xOnuy5Kzzd+C8g1jlVqoXwq020CKd5ua9ItBax3SqSWmO1pw/DM3ObKSCZJpoNpxBAfFigSA==","shasum":"acf92f971fada79b27e7a2e623abdfbeadbe5475","tarball":"https://registry.npmjs.org/trpc/-/trpc-0.8.2.tgz","fileCount":34,"unpackedSize":60981,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfPxcPCRA9TVsSAnZWagAAMDwQAIIOlex+C923esFk8FC0\n1F2tbZRfXUi62qdA/JDaKmNoGSln46wj5A5uxLYiyGKkWxmZQwm2ERdyY8mS\nRyk5H8JKpU7iAlw7kMyyMevgqwJeeiTxpfQbmKCgM9vV+Yp5va8JaEKaF1AQ\nhLpkW2EwuRdGZY8zszX9XCDYG1hLX+OE/EHWLPiWKvYJmwI9F6/+OXYalKeo\nWv2m/9+541bhDKVmyCwsBOVe8vLUZIv0gI3dSgyMY4nbP6gf0tkEVH0a99Ca\nrajl20L3ZaXufWdWRuBGWy+n7ZhESzzCijvoNbyabkGbS9EYHunKezUXSI6g\niISuccp9Ufan2oqJYBhQ8MMKc23qyVXL6YECxZE6c36mgEQZuJVtVZ1pq/3M\nwMDPXO1DAB1DPi/zouoRfFYjrJJNXxicLTTLbkKf99/GD52QEMqGQTSD4P3h\n9PC0IlZBf9VBhhs+hVeFYIveNID28upWbCTUjcfAH33jvlPISJyJwsroPySp\nS5uXYflfXCoVv6lJ6ZFqlbnBcY2+/xODVCPVZJ7RMWGlTUYgGNMS9swiI4Vc\njvbow4+ZNX1wgPG/SjHwTMivcEUQVMTDziYCZrp40rto70nuVuxLTPejCp8e\nit4rXa2TgGe1R+bsZ5rVrnue+10x80oz672B+ifC4ssAvt0FPQX/iiF592SE\n3Ze9\r\n=u8ld\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBOMVuaefZ55wc6+eGTRt5GfLc5DoN/xnMqIcbKqF2/lAiEAqG2rzytK1lC106bOPAcqELE7ZwrwRTm1ED+J+YcwhWE="}]},"maintainers":[{"name":"vriad","email":"colin@vriad.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/trpc_0.8.2_1597970190682_0.691660834677021"},"_hasShrinkwrap":false},"0.8.3":{"name":"trpc","version":"0.8.3","description":"TypeScript-first toolkit for building RPC APIs","main":"./lib/src/index.js","types":"./lib/src/index.d.ts","repository":{"type":"git","url":"git+https://github.com/vriad/trpc.git"},"author":{"name":"Colin McDonnell","email":"colin@vriad.com"},"license":"MIT","sideEffects":false,"bugs":{"url":"https://github.com/vriad/trpc/issues"},"homepage":"https://github.com/vriad/trpc","dependencies":{"axios":"^0.19.2"},"tags":[],"keywords":[],"include":["src"],"exclude":["node_modules","**/__tests__/*"],"scripts":{"clean":"rm -rf lib/*","build":"yarn run clean && tsc --p tsconfig.package.json","format":"prettier --write \"src/**/*.ts\" \"src/**/*.js\"","lint":"tslint -p tsconfig.json","test":"jest --config jestconfig.json --coverage","testone":"jest --config jestconfig.json","dryrun":"nodemon -e ts -w . -x ts-node src/dryrun.ts","prepublishOnly":"npm run build","play":"nodemon -e ts -w . -x ts-node src/playground.ts"},"devDependencies":{"@types/compression":"^1.7.0","@types/cors":"^2.8.7","@types/express":"^4.17.7","@types/jest":"^25.1.4","compression":"^1.7.4","cors":"^2.8.5","express":"^4.17.1","jest":"^25.1.0","nodemon":"^2.0.2","prettier":"^2.0.5","ts-jest":"^25.2.1","typescript":"3.2","zod":"^1.10.1"},"gitHead":"4c16109b23cadec695f83e77194680be7cb7c26f","readme":"<div align=\"center\">\n  <h1 align=\"center\">tRPC</h1>\n  <p>a toolkit for building end-to-end TypeScript data layers</p>\n</div>\n\n<br/>\n<br/>\n\n# Motivation\n\n⚠️ This library is undergoing rapid development and should be considered experimental. Not recommended for use in production. 🤙\n\ntRPC is a framework for building strongly typed RPC APIs with TypeScript. Alternatively, you can think of it as a way to avoid APIs altogether.\n\n# Usage\n\n### Installation\n\n`npm install trpc`\n\n`yarn add trpc`\n\n### Importing\n\n```ts\nimport { trpc } from 'trpc';\n```\n\n### Compatibility\n\ntRPC depends on the Proxy API and dynamic imports, both of which are [not supported in IE11 and earlier](https://caniuse.com/#feat=proxy).\n\nCompatible with TypeScript 3.2+.\n\n## Define your endpoints\n\n`trpc.endpoint(func: (ctx: any) => (...args: any[]) => any)=>TRPCEndpoint`\n\nInstantiate an endpoint with `trpc.endpoint()`. This function takes a _function that returns a function_.\n\n```ts\nconst computeLength = trpc.endpoint(() => (data: string) => {\n  return data.length;\n});\n```\n\nThe outer function can (optionally) accept a single `ctx` argument. This is how tRPC makes the `ctx` of your RPC calls avaiable to your endpoint logic.\n\n<!-- If you don't need context, you should include it. You'll see why later. Naming the variable `_ctx` will prevent TypeScript from complaining about unused variables. -->\n\n```ts\ntype Ctx = { token: string };\n\nconst getUsername = trpc.endpoint((ctx: Ctx) => () => {\n  const user = await getUserFromToken(ctx.token);\n  return user.username;\n});\n```\n\nThat is a simple endpoint that doesn't actually accept any inputs. Here's a more complex example that posts new \"tweets\" to the user's account.\n\n```ts\ntype Ctx = { token: string };\n\nconst postTweet = trpc.endpoint((ctx: Ctx) => (data: { content: string }) => {\n  const user = await getUserFromToken(ctx.token);\n  const newTweet = await createTweet({\n    content: data.content,\n    userId: user.id,\n  });\n  return newTweet;\n});\n```\n\n## Implement authorization\n\ntRPC provides a built-in way to add authorization logic to your endpoints using the `.authorize` method. **By default all incoming requests are rejected!**\n\n`.authorize` accepts a _function that returns a function_, just like `trpc.endpoint`. It must return a boolean. You can use `ctx` or the endpoint's arguments to determine whether to allow the request.\n\n```ts\nconst getUsername = trpc\n  .endpoint((ctx: Ctx) => async () => {\n    const user = await getUserFromToken(ctx.token);\n    return user.username;\n  })\n  .authorize((ctx) => async (data) => {\n    if (!ctx.token) return false;\n    return true;\n  });\n```\n\n## Define your router(s)\n\n`trpc.router()=>TRPCRouter`\n\nRouters are collections of endpoints. Here's how to create a router and add the `getUsername` endpoint we created above.\n\n```ts\nconst userRouter = trpc.router().endpoint('getUsername', getUsername);\n```\n\nTo add multiple endpoints, you _must chain_ the calls to `.endpoint()`.\n\n```ts\nconst userRouter = trpc\n  .router()\n  .endpoint('getUsername', getUsername)\n  .endpoint('postTweet', postTweet);\n```\n\nIf you're used to Express you may be tempted to try this:\n\n```ts\n// DONT DO THIS\nconst stringRouter = trpc.router();\n\nstringRouter.endpoint('getById', getUserById);\nstringRouter.endpoint('otherEndpoint', otherEndpoint);\n```\n\nThis won't work. In `trpc` routers are _immutable_. The `.endpoint()` method returns an entirely new router, so you must chain the calls.\n\n## Compose multiple routers\n\nYou can compose routers into hierarchies. Below we create a `rootRouter` with one endpoint (`computeLength`, defined above) and one child router (`userRouter`, defined above, aliased to `user`). This will be important later.\n\n```ts\nconst rootRouter = trpc\n  .router()\n  .endpoint('computeLength', computeLength)\n  .compose('user', userRouter);\n```\n\n## Handle requests\n\n`router.handle(payload: Payload)=>any`\n\nThe `Payload` type is:\n\n```ts\ntype Payload = {\n  path: string[];\n  context: any;\n  args: any[];\n};\n```\n\nRouters can handle \"requests\" using the `.handle` method.\n\n```ts\nrootRouter.handle({\n  endpoint: ['computeLength'],\n  context: {},\n  args: ['this is a sample string'],\n}); // => Promise<23>\n\nrootRouter.handle({\n  endpoint: ['user', 'postTweet'],\n  context: { token: `SAMPLE_TOKEN` },\n  args: [{ content: 'just setting up my twttr' }],\n}); // => Promise<{ /* new Tweet object */ }>\n```\n\n### Express\n\nThere is a convenience function for generating an Express middleware from your router.\n\n```ts\nimport express from 'express';\nimport bodyParser from 'body-parser';\n\nexport const app = express();\napp.use(bodyParser.json());\n\n// serve requests\napp.post('/rpc', rootRouter.toExpress());\n```\n\nSimilar to GraphQL, your entire API is exposed over a single endpoint (in this case `/rpc`). All incoming requests should POST to this endpoint with a body of type `Payload` (defined above).\n\n## Creating a server SDK\n\ntRPC automatically tracks the structure of your router hierarchy and the input/output types of your endpoint. This means we can do some exciting things.\n\ntRPC can autogenerate an \"server SDK\" from any router like so:\n\n```ts\nconst serverSDK = rootRouter.toServerSDK();\n\n// synchronous\nconst asdfLength = serverSDK.computeLength({}, 'asdf'); // => 4\n\nconst username = await serverSDK.user.getUsername({ token: 'SAMPLE_TOKEN' });\n// Promise<\"username\">\n\nconst newTweet = await serverSDK.user.postTweet(\n  { token: 'SAMPLE_TOKEN' },\n  {\n    content: 'just setting up my twttr',\n  },\n);\n// Promise<\"username\">\n```\n\nThe first argument to _all_ server SDK calls is the context. Just pass an empty object if your endpoint doesn't use context.\n\nThis is useful for server environments. It provides a standard way to call your own APIs without any code duplication. Plus it **automatically bypasses all authorization checks**. Do not accidentally make this available to any client side code!\n\n## Creating a client SDK\n\n⚠️ Follow the instructions below very carefully! Otherwise you may accidentally expose your server code to the client.\n\nIt's easier than ever to share code between your client and server. The example code below assumes you have a way to do this, either using a tool like [Yarn Workspaces](https://classic.yarnpkg.com/en/docs/workspaces/)/[Lerna](https://github.com/lerna/lerna) or a framework like [Next.js](https://nextjs.org/).\n\n<!-- The days of auto-generating an SDK from OpenAPI specifications — and GraphQL definition files 🙄 — is over. -->\n\n```ts\n// server.ts\n\nexport const rootRouter = /* define router here */;\n```\n\n```ts\n// client.tsx\n\nimport { trpc } from 'trpc';\n\n// only import the TypeScript type of your router!\n// this uses dynamic imports\ntype RootRouter = typeof import('../path/to/server.ts').rootRouter;\n\n// pass in your router type\n// as a generic parameter to trpc.sdk\nconst clientSDK = trpc.sdk<RootRouter>({\n  url: 'http:localhost:3000',\n  getContext: async () => {\n    const token = await getTokenFromCookies();\n    return { token };\n  },\n});\n```\n\nAs you can see, `trpc.sdk()` accepts a params object with the following keys:\n\n- `url: string` — the URL of your tRPC endpoint, e.g. `http://localhost:3000/rpc`\n- `getContext: ()=>Promise<any>` — an async function for gathering/computing/fetching any `context` data for the request. This is where you should return the cookies/tokens you'd like to pass with the request. The returned value will be provided to your endpoints in the `ctx` argument.\n\n```ts\nawait clientSDK.computeLength('asdf'); // => Promise<4>\nawait clientSDK.user.getUsername(); // => Promise<\"username\">\nawait clientSDK.user.postTweet({ content: 'hello world' });\n```\n\nThe client SDK always returns a Promise, even if the server-side logic in synchronous, since the SDK is making a round-trip HTTP request under the hood.\n\nThere's no need to pass a context object as the first input (as with the server SDK) because the context object is produced by the `getContext` function you passed into `trpc.sdk`.\n\n### Custom request handler\n\nBy default tRPC uses Axios to send requests to the `url` you specify in the SDK params. Optionally you can provide an entirely custom HTTP request handler using with `handler`:\n\n```ts\nconst clientSDK = trpc.sdk<RootRouter>({\n  url: 'http:localhost:3000',\n  getContext: async () => {\n    const token = await getTokenFromCookies();\n    return { token };\n  },\n  handler: async (url, payload) => {\n    const result = await fetch(url, {\n      method: 'POST',\n      headers: {\n        'Content-Type': 'application/json',\n      },\n      body: payload,\n    });\n    return result.json();\n  },\n});\n```\n\n## Usage patterns\n\n- TODO: runtime validation with Zod\n- TODO: React Hook\n- TODO: Next.js/SWR\n","readmeFilename":"README.md","_id":"trpc@0.8.3","_npmVersion":"6.4.1","_nodeVersion":"10.15.3","_npmUser":{"name":"vriad","email":"colin@vriad.com"},"dist":{"integrity":"sha512-fDTmFd3yRAft20Bmw2P9seqIzd6+m57gAj6pp0XqpKpiAgw++f8Vk0z5BGnZntSg+31OxbKD7ZM6TzuyBJ5lvQ==","shasum":"9aa2b9abbb7238ca535fb1a320c2b32282606409","tarball":"https://registry.npmjs.org/trpc/-/trpc-0.8.3.tgz","fileCount":34,"unpackedSize":60983,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfPxk+CRA9TVsSAnZWagAAGQ0P/0xej8OwayrH08pEEZ41\nIp/rLAnTxJogXgU9wZZHueZCRJDL9oCO+ID2A1J4zBE9oF+iZmDuzwvVFShq\nQEAZYs435fyFmQ+wLpUOZFSQtBSkMD3ghdvvgma61/t607985VEebQza/jQR\nzGQzT1E8dOs1oy/1io1Bl5oUPNtKJbYtfDdRp/ceOQlRUV7rulyYrJTqHpcV\nyFSDA4GktHM5eM050OgUf17Leuv+kjQRpuZs3kgux6Rsegw3Xl76A1ixbgbq\nrE3+ovdCdkIyQOn4v5AW0DvPK2lkyYNvAErfUc5f8PFZydEIir8GC/8R3uzY\nBexZLuYrD6SuZGySPvkkZmrgWyr+EXPqfeiKp82alLeFDpurjWpqydHKr5C/\ntyBJ4hRfLEW1F02FUi6jedmH1xeLA00HlD+44qd+6awVpH4Wz1pq+lYUAMgd\ndmODxPC1DL/Z9ilW7T5/yndMjIj6rhxmlICa7ULO309xO6ehGOKyajwwr0EI\nlLeDAjE7+sov1WRa1ePmFaxwIL87KCdszSruDeoZp11HCw051LRpAGvy4BXk\niy184PHebrLOvITzSLOy8Wva1gg8aTsk6rPv4UqhJAT1COEHIxhKirYht9on\nYlapUyfnty0I/ayu8658dfy7tdD9UIx/iojmp7eDDwqMmmcuBA56I9leTqdU\n+bLO\r\n=Jdg9\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCYE1oVdls3fowmxKivaA/1dRZlttU0SXS3oVawmXUeBAIhAOuebgVzoFN6si8x1/ITowSBWA2NfiuWKbmJATUva+xV"}]},"maintainers":[{"name":"vriad","email":"colin@vriad.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/trpc_0.8.3_1597970749695_0.8162596927391412"},"_hasShrinkwrap":false},"0.8.4":{"name":"trpc","version":"0.8.4","description":"TypeScript-first toolkit for building RPC APIs","main":"./lib/src/index.js","types":"./lib/src/index.d.ts","repository":{"type":"git","url":"git+https://github.com/vriad/trpc.git"},"author":{"name":"Colin McDonnell","email":"colin@vriad.com"},"license":"MIT","sideEffects":false,"bugs":{"url":"https://github.com/vriad/trpc/issues"},"homepage":"https://github.com/vriad/trpc","dependencies":{"axios":"^0.19.2"},"tags":[],"keywords":[],"include":["src"],"exclude":["node_modules","**/__tests__/*"],"scripts":{"clean":"rm -rf lib/*","build":"yarn run clean && tsc --p tsconfig.package.json","format":"prettier --write \"src/**/*.ts\" \"src/**/*.js\"","lint":"tslint -p tsconfig.json","test":"jest --config jestconfig.json --coverage","testone":"jest --config jestconfig.json","dryrun":"nodemon -e ts -w . -x ts-node src/dryrun.ts","prepublishOnly":"npm run build","play":"nodemon -e ts -w . -x ts-node src/playground.ts"},"devDependencies":{"@types/compression":"^1.7.0","@types/cors":"^2.8.7","@types/express":"^4.17.7","@types/jest":"^25.1.4","compression":"^1.7.4","cors":"^2.8.5","express":"^4.17.1","jest":"^25.1.0","nodemon":"^2.0.2","prettier":"^2.0.5","ts-jest":"^25.2.1","typescript":"3.2","zod":"^1.10.1"},"readme":"<div align=\"center\">\n  <h1 align=\"center\">tRPC</h1>\n  <p>a toolkit for building end-to-end TypeScript data layers</p>\n</div>\n\n<br/>\n<br/>\n\n# Motivation\n\n⚠️ This library is undergoing rapid development and should be considered experimental. Not recommended for use in production. 🤙\n\ntRPC is a framework for building strongly typed RPC APIs with TypeScript. Alternatively, you can think of it as a way to avoid APIs altogether.\n\n# Usage\n\n### Installation\n\n`npm install trpc`\n\n`yarn add trpc`\n\n### Importing\n\n```ts\nimport { trpc } from 'trpc';\n```\n\n### Compatibility\n\ntRPC depends on the Proxy API and dynamic imports, both of which are [not supported in IE11 and earlier](https://caniuse.com/#feat=proxy).\n\nCompatible with TypeScript 3.2+.\n\n## Define your endpoints\n\n`trpc.endpoint(func: (ctx: any) => (...args: any[]) => any)=>TRPCEndpoint`\n\nInstantiate an endpoint with `trpc.endpoint()`. This function takes a _function that returns a function_.\n\n```ts\nconst computeLength = trpc.endpoint(() => (data: string) => {\n  return data.length;\n});\n```\n\nThe outer function can (optionally) accept a single `ctx` argument. This is how tRPC makes the `ctx` of your RPC calls avaiable to your endpoint logic.\n\n<!-- If you don't need context, you should include it. You'll see why later. Naming the variable `_ctx` will prevent TypeScript from complaining about unused variables. -->\n\n```ts\ntype Ctx = { token: string };\n\nconst getUsername = trpc.endpoint((ctx: Ctx) => () => {\n  const user = await getUserFromToken(ctx.token);\n  return user.username;\n});\n```\n\nThat is a simple endpoint that doesn't actually accept any inputs. Here's a more complex example that posts new \"tweets\" to the user's account.\n\n```ts\ntype Ctx = { token: string };\n\nconst postTweet = trpc.endpoint((ctx: Ctx) => (data: { content: string }) => {\n  const user = await getUserFromToken(ctx.token);\n  const newTweet = await createTweet({\n    content: data.content,\n    userId: user.id,\n  });\n  return newTweet;\n});\n```\n\n## Implement authorization\n\ntRPC provides a built-in way to add authorization logic to your endpoints using the `.authorize` method. **By default all incoming requests are rejected!**\n\n`.authorize` accepts a _function that returns a function_, just like `trpc.endpoint`. It must return a boolean. You can use `ctx` or the endpoint's arguments to determine whether to allow the request.\n\n```ts\nconst getUsername = trpc\n  .endpoint((ctx: Ctx) => async () => {\n    const user = await getUserFromToken(ctx.token);\n    return user.username;\n  })\n  .authorize((ctx) => async (data) => {\n    if (!ctx.token) return false;\n    return true;\n  });\n```\n\n## Define your router(s)\n\n`trpc.router()=>TRPCRouter`\n\nRouters are collections of endpoints. Here's how to create a router and add the `getUsername` endpoint we created above.\n\n```ts\nconst userRouter = trpc.router().endpoint('getUsername', getUsername);\n```\n\nTo add multiple endpoints, you _must chain_ the calls to `.endpoint()`.\n\n```ts\nconst userRouter = trpc\n  .router()\n  .endpoint('getUsername', getUsername)\n  .endpoint('postTweet', postTweet);\n```\n\nIf you're used to Express you may be tempted to try this:\n\n```ts\n// DONT DO THIS\nconst stringRouter = trpc.router();\n\nstringRouter.endpoint('getById', getUserById);\nstringRouter.endpoint('otherEndpoint', otherEndpoint);\n```\n\nThis won't work. In `trpc` routers are _immutable_. The `.endpoint()` method returns an entirely new router, so you must chain the calls.\n\n## Compose multiple routers\n\nYou can compose routers into hierarchies. Below we create a `rootRouter` with one endpoint (`computeLength`, defined above) and one child router (`userRouter`, defined above, aliased to `user`). This will be important later.\n\n```ts\nconst rootRouter = trpc\n  .router()\n  .endpoint('computeLength', computeLength)\n  .compose('user', userRouter);\n```\n\n## Handle requests\n\n`router.handle(payload: Payload)=>any`\n\nThe `Payload` type is:\n\n```ts\ntype Payload = {\n  path: string[];\n  context: any;\n  args: any[];\n};\n```\n\nRouters can handle \"requests\" using the `.handle` method.\n\n```ts\nrootRouter.handle({\n  endpoint: ['computeLength'],\n  context: {},\n  args: ['this is a sample string'],\n}); // => Promise<23>\n\nrootRouter.handle({\n  endpoint: ['user', 'postTweet'],\n  context: { token: `SAMPLE_TOKEN` },\n  args: [{ content: 'just setting up my twttr' }],\n}); // => Promise<{ /* new Tweet object */ }>\n```\n\n### Express\n\nThere is a convenience function for generating an Express middleware from your router.\n\n```ts\nimport express from 'express';\nimport bodyParser from 'body-parser';\n\nexport const app = express();\napp.use(bodyParser.json());\n\n// serve requests\napp.post('/rpc', rootRouter.toExpress());\n```\n\nSimilar to GraphQL, your entire API is exposed over a single endpoint (in this case `/rpc`). All incoming requests should POST to this endpoint with a body of type `Payload` (defined above).\n\n## Creating a server SDK\n\ntRPC automatically tracks the structure of your router hierarchy and the input/output types of your endpoint. This means we can do some exciting things.\n\ntRPC can autogenerate an \"server SDK\" from any router like so:\n\n```ts\nconst serverSDK = rootRouter.toServerSDK();\n\n// synchronous\nconst asdfLength = serverSDK.computeLength({}, 'asdf'); // => 4\n\nconst username = await serverSDK.user.getUsername({ token: 'SAMPLE_TOKEN' });\n// Promise<\"username\">\n\nconst newTweet = await serverSDK.user.postTweet(\n  { token: 'SAMPLE_TOKEN' },\n  {\n    content: 'just setting up my twttr',\n  },\n);\n// Promise<\"username\">\n```\n\nThe first argument to _all_ server SDK calls is the context. Just pass an empty object if your endpoint doesn't use context.\n\nThis is useful for server environments. It provides a standard way to call your own APIs without any code duplication. Plus it **automatically bypasses all authorization checks**. Do not accidentally make this available to any client side code!\n\n## Creating a client SDK\n\n⚠️ Follow the instructions below very carefully! Otherwise you may accidentally expose your server code to the client.\n\nIt's easier than ever to share code between your client and server. The example code below assumes you have a way to do this, either using a tool like [Yarn Workspaces](https://classic.yarnpkg.com/en/docs/workspaces/)/[Lerna](https://github.com/lerna/lerna) or a framework like [Next.js](https://nextjs.org/).\n\n<!-- The days of auto-generating an SDK from OpenAPI specifications — and GraphQL definition files 🙄 — is over. -->\n\n```ts\n// server.ts\n\nexport const rootRouter = /* define router here */;\n```\n\n```ts\n// client.tsx\n\nimport { trpc } from 'trpc';\n\n// only import the TypeScript type of your router!\n// this uses dynamic imports\ntype RootRouter = typeof import('../path/to/server.ts').rootRouter;\n\n// pass in your router type\n// as a generic parameter to trpc.sdk\nconst clientSDK = trpc.sdk<RootRouter>({\n  url: 'http:localhost:3000',\n  getContext: async () => {\n    const token = await getTokenFromCookies();\n    return { token };\n  },\n});\n```\n\nAs you can see, `trpc.sdk()` accepts a params object with the following keys:\n\n- `url: string` — the URL of your tRPC endpoint, e.g. `http://localhost:3000/rpc`\n- `getContext: ()=>Promise<any>` — an async function for gathering/computing/fetching any `context` data for the request. This is where you should return the cookies/tokens you'd like to pass with the request. The returned value will be provided to your endpoints in the `ctx` argument.\n\n```ts\nawait clientSDK.computeLength('asdf'); // => Promise<4>\nawait clientSDK.user.getUsername(); // => Promise<\"username\">\nawait clientSDK.user.postTweet({ content: 'hello world' });\n```\n\nThe client SDK always returns a Promise, even if the server-side logic in synchronous, since the SDK is making a round-trip HTTP request under the hood.\n\nThere's no need to pass a context object as the first input (as with the server SDK) because the context object is produced by the `getContext` function you passed into `trpc.sdk`.\n\n### Custom request handler\n\nBy default tRPC uses Axios to send requests to the `url` you specify in the SDK params. Optionally you can provide an entirely custom HTTP request handler using with `handler`:\n\n```ts\nconst clientSDK = trpc.sdk<RootRouter>({\n  url: 'http:localhost:3000',\n  getContext: async () => {\n    const token = await getTokenFromCookies();\n    return { token };\n  },\n  handler: async (url, payload) => {\n    const result = await fetch(url, {\n      method: 'POST',\n      headers: {\n        'Content-Type': 'application/json',\n      },\n      body: payload,\n    });\n    return result.json();\n  },\n});\n```\n\n## Usage patterns\n\n- TODO: runtime validation with Zod\n- TODO: React Hook\n- TODO: Next.js/SWR\n","readmeFilename":"README.md","gitHead":"b5e5f17898722217bb634e390caf78608cebef1a","_id":"trpc@0.8.4","_npmVersion":"6.4.1","_nodeVersion":"10.15.3","_npmUser":{"name":"vriad","email":"colin@vriad.com"},"dist":{"integrity":"sha512-uwzH2fN9ubBsUbwUilx0j6cLU70t8xK/o9axQr48TTGyu/Wl+NX249xmRJ+Cxtt3JgIm0ZRyWd6IOTmnEZXvwQ==","shasum":"12b2f2e0d4de98c8a464d46b61cf09bb146b8d49","tarball":"https://registry.npmjs.org/trpc/-/trpc-0.8.4.tgz","fileCount":34,"unpackedSize":60992,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfPx2/CRA9TVsSAnZWagAAJ0kP/3miZxLFTUdTHo5T3BxZ\n2x6mHMaU5o3x9yitWzse1mXTkyifCa2QrSSZxv3CHD+rQbKLx7UeA0ZVsQ7V\nQCtHDnbwVamUYzKzmNljzQuf8mar29Ag2E8zUKNH0ZYAwCuwXonSGBKRRt97\n9LaqNKGxenXAIq9KSG1kB4AUPx9ftKcOMEjveVOwJnM2MFNxjhh7QOlRNBp5\nqmrzj9O8E31orfd169u9+VYqE5tbJl7lE1/7rc1oVx5A4cq0gqrJf7oELRod\n11WjtQVFYckpDBjQPay/k0Co3y8b1l5CJPQdhr5QojtuxIVRpnoaPrux7njf\n8ylCsMDwtjSV6hZbiB0ViK83huz23S1f+AM/ZpKJXO8neXAIlwLxP1FNnu36\nbj+O2/3Gm5C9Com21K6VcP9xxaGpyGo1PbVEXcq8oLG8FooWxkBUGM3XHTx1\nhoAK0L8x8pQvjhhjL/fbApoSeh07KU5owyNp5bHoGk66dVbrJYEw4yMt6TJc\njnue/Ab2DwohLVBrpQxGEn9hJ6EA0Kps80sLf/8JmVUP7u0xRAR/waSxQWDa\n0aaSj8OLPHzOmOVjllSeTDFqWEvRQ41DS9d4fgSDaJ3Xg4W770XLU5O4mF+C\nmVi/bNxJ44RyI51eIv9YDv0MOz8TiO8SbXvowonFsf6jvUdzUtfCxu6bVvmu\nPtan\r\n=/pTp\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCID26HIVVywoY/00e7C5GEjyh4VsYQPaewrzz0cxUiVVsAiBEHH5bzJ7PU5TCnYPEzWolJf5ghU2kqrpRc9xrfdnk2Q=="}]},"maintainers":[{"name":"vriad","email":"colin@vriad.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/trpc_0.8.4_1597971902579_0.34723202664381025"},"_hasShrinkwrap":false},"0.8.5":{"name":"trpc","version":"0.8.5","description":"TypeScript-first toolkit for building RPC APIs","main":"./lib/src/index.js","types":"./lib/src/index.d.ts","repository":{"type":"git","url":"git+https://github.com/vriad/trpc.git"},"author":{"name":"Colin McDonnell","email":"colin@vriad.com"},"license":"MIT","sideEffects":false,"bugs":{"url":"https://github.com/vriad/trpc/issues"},"homepage":"https://github.com/vriad/trpc","dependencies":{"axios":"^0.19.2"},"tags":[],"keywords":[],"include":["src"],"exclude":["node_modules","**/__tests__/*"],"scripts":{"clean":"rm -rf lib/*","build":"yarn run clean && tsc --p tsconfig.package.json","format":"prettier --write \"src/**/*.ts\" \"src/**/*.js\"","lint":"tslint -p tsconfig.json","test":"jest --config jestconfig.json --coverage","testone":"jest --config jestconfig.json","dryrun":"nodemon -e ts -w . -x ts-node src/dryrun.ts","prepublishOnly":"npm run build","play":"nodemon -e ts -w . -x ts-node src/playground.ts"},"devDependencies":{"@types/compression":"^1.7.0","@types/cors":"^2.8.7","@types/express":"^4.17.7","@types/jest":"^25.1.4","compression":"^1.7.4","cors":"^2.8.5","express":"^4.17.1","jest":"^25.1.0","nodemon":"^2.0.2","prettier":"^2.0.5","ts-jest":"^25.2.1","typescript":"3.2","zod":"^1.10.1"},"readme":"<div align=\"center\">\n  <h1 align=\"center\">tRPC</h1>\n  <p>a toolkit for building end-to-end TypeScript data layers</p>\n</div>\n\n<br/>\n<br/>\n\n# Motivation\n\n⚠️ This library is undergoing rapid development and should be considered experimental. Not recommended for use in production. 🤙\n\ntRPC is a framework for building strongly typed RPC APIs with TypeScript. Alternatively, you can think of it as a way to avoid APIs altogether.\n\n# Usage\n\n### Installation\n\n`npm install trpc`\n\n`yarn add trpc`\n\n### Importing\n\n```ts\nimport { trpc } from 'trpc';\n```\n\n### Compatibility\n\ntRPC depends on the Proxy API and dynamic imports, both of which are [not supported in IE11 and earlier](https://caniuse.com/#feat=proxy).\n\nCompatible with TypeScript 3.2+.\n\n## Define your endpoints\n\n`trpc.endpoint(func: (ctx: any) => (...args: any[]) => any)=>TRPCEndpoint`\n\nInstantiate an endpoint with `trpc.endpoint()`. This function takes a _function that returns a function_.\n\n```ts\nconst computeLength = trpc.endpoint(() => (data: string) => {\n  return data.length;\n});\n```\n\nThe outer function can (optionally) accept a single `ctx` argument. This is how tRPC makes the `ctx` of your RPC calls avaiable to your endpoint logic.\n\n<!-- If you don't need context, you should include it. You'll see why later. Naming the variable `_ctx` will prevent TypeScript from complaining about unused variables. -->\n\n```ts\ntype Ctx = { token: string };\n\nconst getUsername = trpc.endpoint((ctx: Ctx) => () => {\n  const user = await getUserFromToken(ctx.token);\n  return user.username;\n});\n```\n\nThat is a simple endpoint that doesn't actually accept any inputs. Here's a more complex example that posts new \"tweets\" to the user's account.\n\n```ts\ntype Ctx = { token: string };\n\nconst postTweet = trpc.endpoint((ctx: Ctx) => (data: { content: string }) => {\n  const user = await getUserFromToken(ctx.token);\n  const newTweet = await createTweet({\n    content: data.content,\n    userId: user.id,\n  });\n  return newTweet;\n});\n```\n\n## Implement authorization\n\ntRPC provides a built-in way to add authorization logic to your endpoints using the `.authorize` method. **By default all incoming requests are rejected!**\n\n`.authorize` accepts a _function that returns a function_, just like `trpc.endpoint`. It must return a boolean. You can use `ctx` or the endpoint's arguments to determine whether to allow the request.\n\n```ts\nconst getUsername = trpc\n  .endpoint((ctx: Ctx) => async () => {\n    const user = await getUserFromToken(ctx.token);\n    return user.username;\n  })\n  .authorize((ctx) => async (data) => {\n    if (!ctx.token) return false;\n    return true;\n  });\n```\n\n## Define your router(s)\n\n`trpc.router()=>TRPCRouter`\n\nRouters are collections of endpoints. Here's how to create a router and add the `getUsername` endpoint we created above.\n\n```ts\nconst userRouter = trpc.router().endpoint('getUsername', getUsername);\n```\n\nTo add multiple endpoints, you _must chain_ the calls to `.endpoint()`.\n\n```ts\nconst userRouter = trpc\n  .router()\n  .endpoint('getUsername', getUsername)\n  .endpoint('postTweet', postTweet);\n```\n\nIf you're used to Express you may be tempted to try this:\n\n```ts\n// DONT DO THIS\nconst stringRouter = trpc.router();\n\nstringRouter.endpoint('getById', getUserById);\nstringRouter.endpoint('otherEndpoint', otherEndpoint);\n```\n\nThis won't work. In `trpc` routers are _immutable_. The `.endpoint()` method returns an entirely new router, so you must chain the calls.\n\n## Compose multiple routers\n\nYou can compose routers into hierarchies. Below we create a `rootRouter` with one endpoint (`computeLength`, defined above) and one child router (`userRouter`, defined above, aliased to `user`). This will be important later.\n\n```ts\nconst rootRouter = trpc\n  .router()\n  .endpoint('computeLength', computeLength)\n  .compose('user', userRouter);\n```\n\n## Handle requests\n\n`router.handle(payload: Payload)=>any`\n\nThe `Payload` type is:\n\n```ts\ntype Payload = {\n  path: string[];\n  context: any;\n  args: any[];\n};\n```\n\nRouters can handle \"requests\" using the `.handle` method.\n\n```ts\nrootRouter.handle({\n  endpoint: ['computeLength'],\n  context: {},\n  args: ['this is a sample string'],\n}); // => Promise<23>\n\nrootRouter.handle({\n  endpoint: ['user', 'postTweet'],\n  context: { token: `SAMPLE_TOKEN` },\n  args: [{ content: 'just setting up my twttr' }],\n}); // => Promise<{ /* new Tweet object */ }>\n```\n\n### Express\n\nThere is a convenience function for generating an Express middleware from your router.\n\n```ts\nimport express from 'express';\nimport bodyParser from 'body-parser';\n\nexport const app = express();\napp.use(bodyParser.json());\n\n// serve requests\napp.post('/rpc', rootRouter.toExpress());\n```\n\nSimilar to GraphQL, your entire API is exposed over a single endpoint (in this case `/rpc`). All incoming requests should POST to this endpoint with a body of type `Payload` (defined above).\n\n## Creating a server SDK\n\ntRPC automatically tracks the structure of your router hierarchy and the input/output types of your endpoint. This means we can do some exciting things.\n\ntRPC can autogenerate an \"server SDK\" from any router like so:\n\n```ts\nconst serverSDK = rootRouter.toServerSDK();\n\n// synchronous\nconst asdfLength = serverSDK.computeLength({}, 'asdf'); // => 4\n\nconst username = await serverSDK.user.getUsername({ token: 'SAMPLE_TOKEN' });\n// Promise<\"username\">\n\nconst newTweet = await serverSDK.user.postTweet(\n  { token: 'SAMPLE_TOKEN' },\n  {\n    content: 'just setting up my twttr',\n  },\n);\n// Promise<\"username\">\n```\n\nThe first argument to _all_ server SDK calls is the context. Just pass an empty object if your endpoint doesn't use context.\n\nThis is useful for server environments. It provides a standard way to call your own APIs without any code duplication. Plus it **automatically bypasses all authorization checks**. Do not accidentally make this available to any client side code!\n\n## Creating a client SDK\n\n⚠️ Follow the instructions below very carefully! Otherwise you may accidentally expose your server code to the client.\n\nIt's easier than ever to share code between your client and server. The example code below assumes you have a way to do this, either using a tool like [Yarn Workspaces](https://classic.yarnpkg.com/en/docs/workspaces/)/[Lerna](https://github.com/lerna/lerna) or a framework like [Next.js](https://nextjs.org/).\n\n<!-- The days of auto-generating an SDK from OpenAPI specifications — and GraphQL definition files 🙄 — is over. -->\n\n```ts\n// server.ts\n\nexport const rootRouter = /* define router here */;\n```\n\n```ts\n// client.tsx\n\nimport { trpc } from 'trpc';\n\n// only import the TypeScript type of your router!\n// this uses dynamic imports\ntype RootRouter = typeof import('../path/to/server.ts').rootRouter;\n\n// pass in your router type\n// as a generic parameter to trpc.sdk\nconst clientSDK = trpc.sdk<RootRouter>({\n  url: 'http:localhost:3000',\n  getContext: async () => {\n    const token = await getTokenFromCookies();\n    return { token };\n  },\n});\n```\n\nAs you can see, `trpc.sdk()` accepts a params object with the following keys:\n\n- `url: string` — the URL of your tRPC endpoint, e.g. `http://localhost:3000/rpc`\n- `getContext: ()=>Promise<any>` — an async function for gathering/computing/fetching any `context` data for the request. This is where you should return the cookies/tokens you'd like to pass with the request. The returned value will be provided to your endpoints in the `ctx` argument.\n\n```ts\nawait clientSDK.computeLength('asdf'); // => Promise<4>\nawait clientSDK.user.getUsername(); // => Promise<\"username\">\nawait clientSDK.user.postTweet({ content: 'hello world' });\n```\n\nThe client SDK always returns a Promise, even if the server-side logic in synchronous, since the SDK is making a round-trip HTTP request under the hood.\n\nThere's no need to pass a context object as the first input (as with the server SDK) because the context object is produced by the `getContext` function you passed into `trpc.sdk`.\n\n### Custom request handler\n\nBy default tRPC uses Axios to send requests to the `url` you specify in the SDK params. Optionally you can provide an entirely custom HTTP request handler using with `handler`:\n\n```ts\nconst clientSDK = trpc.sdk<RootRouter>({\n  url: 'http:localhost:3000',\n  getContext: async () => {\n    const token = await getTokenFromCookies();\n    return { token };\n  },\n  handler: async (url, payload) => {\n    const result = await fetch(url, {\n      method: 'POST',\n      headers: {\n        'Content-Type': 'application/json',\n      },\n      body: payload,\n    });\n    return result.json();\n  },\n});\n```\n\n## Usage patterns\n\n- TODO: runtime validation with Zod\n- TODO: React Hook\n- TODO: Next.js/SWR\n","readmeFilename":"README.md","gitHead":"8e8eea7bab0425eec55bcd4a49ccb096c1ea7174","_id":"trpc@0.8.5","_npmVersion":"6.4.1","_nodeVersion":"10.15.3","_npmUser":{"name":"vriad","email":"colin@vriad.com"},"dist":{"integrity":"sha512-F1xPidBoooRwShBQM/jr5BvUGj1cctDv0eXp8mVxhdvGuBglG7Cqkkgv1dM/uxxoUpxmQrV1Q1lak/FvXdvxFw==","shasum":"ae699e52277bfc4d73adeb24d09fa4106df7cd94","tarball":"https://registry.npmjs.org/trpc/-/trpc-0.8.5.tgz","fileCount":34,"unpackedSize":61011,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfQFWMCRA9TVsSAnZWagAA144P/RbUQb8ifJWjgBRLBRp/\ns0VtlteKxyIv0dEWw1zOXpU8XuHuokVOrUgz1cEf+L+Jj3uvY13CWnn0W0vo\nUVTIl2k9AfGBvuHE7YtbXzcmv4lZknr6GzGgLXoha+uqGE8ceTKv/JZ000o6\nOTcFx7gWF75ehpChopwy8bbRHRqFKuQE/RQT7qTq1CTYxjf8f58ElmdYUahk\nePOplJkpvqjYz6xT5qjDGRoSNzsAMi6CR0fWMKKWmsMkQPoh/2dSlqSE1F2l\ndmcoWt1kesH0Fe2ABNzMgeXjc/FgkWoMp6cWmq0n7St7y2R65WUQ3Tmoaqmf\nWZdWgdEjoIn3GrbMZeTrUwJkZoB9phlCok6Wxt9x3ccrIaroLNpiU5d3Rf42\n+IuMsDhoWDnfznRSiWBj1jPqihubgNrS64TUkknemrr7g3tIx0EIl1DG6zkl\nVgLc6lNJeiGUky9ZbF3C0Q/qT4yA41P3NromH1ykih8qLD+nLTHncEtkRTjK\n/jQgioDmkgsVsG+ge+V9DAPAmFgT4RXNoINKQXHhjbLoJr8CJ15ofXujmIbJ\nUWU1Sl5FffLzudheZxHQ84zqmO8n5q40oc723XcTs3yykvU6ejAgNvjBSmdx\nQobWFWL5qADYYei039SN1kXSx2DpuPCtzA7AR2kHzPspBrJYW0ivdmvFa0Na\n+7PH\r\n=prWA\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEZ3Z5mJsuu349EjWzxVrDfVAjEC5bhmlWgqx26nvDGEAiBYz/Qvhi7wCifruP41SWcBxubhzimIo0rSCjMA6WXuOw=="}]},"maintainers":[{"name":"vriad","email":"colin@vriad.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/trpc_0.8.5_1598051724095_0.48411679288837184"},"_hasShrinkwrap":false},"0.8.6":{"name":"trpc","version":"0.8.6","description":"TypeScript-first toolkit for building RPC APIs","main":"./lib/src/index.js","types":"./lib/src/index.d.ts","repository":{"type":"git","url":"git+https://github.com/vriad/trpc.git"},"author":{"name":"Colin McDonnell","email":"colin@vriad.com"},"license":"MIT","sideEffects":false,"bugs":{"url":"https://github.com/vriad/trpc/issues"},"homepage":"https://github.com/vriad/trpc","dependencies":{"axios":"^0.19.2"},"tags":[],"keywords":[],"include":["src"],"exclude":["node_modules","**/__tests__/*"],"scripts":{"clean":"rm -rf lib/*","build":"yarn run clean && tsc --p tsconfig.package.json","format":"prettier --write \"src/**/*.ts\" \"src/**/*.js\"","lint":"tslint -p tsconfig.json","test":"jest --config jestconfig.json --coverage","testone":"jest --config jestconfig.json","dryrun":"nodemon -e ts -w . -x ts-node src/dryrun.ts","prepublishOnly":"npm run build","play":"nodemon -e ts -w . -x ts-node src/playground.ts"},"devDependencies":{"@types/compression":"^1.7.0","@types/cors":"^2.8.7","@types/express":"^4.17.7","@types/jest":"^25.1.4","compression":"^1.7.4","cors":"^2.8.5","express":"^4.17.1","jest":"^25.1.0","nodemon":"^2.0.2","prettier":"^2.0.5","ts-jest":"^25.2.1","typescript":"3.2","zod":"^1.10.1"},"gitHead":"0198cfc809ee8f20b5430ac9a90a95bd699aae37","_id":"trpc@0.8.6","_npmVersion":"6.4.1","_nodeVersion":"10.15.3","_npmUser":{"name":"vriad","email":"colin@vriad.com"},"dist":{"integrity":"sha512-eJ0nNb+AhFMVLpUnkiDgjU/NEh55x3ZHuOSoqtEA7UkddzbO+B5+q9xwoLYsbWycuVAbI7nzIWI8yZ8vLfnmLw==","shasum":"9344a76d5c6c9e0684a8be56a7421ad5d66439b2","tarball":"https://registry.npmjs.org/trpc/-/trpc-0.8.6.tgz","fileCount":34,"unpackedSize":60553,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfRJVuCRA9TVsSAnZWagAATGYP/RMDns5sOeUGR0ooAt3r\nKRlFz+YWUyCSbXucXcZZwqoW5a4ZHA80ezgXtLbham3RoIRIxjjkivwO3g3C\nMNiT/vBuhhGKqTis40Nv2eCEgeiWTMiQB4dj8ski57iS2+ohMHogmDZRCtcR\nfGhiEpFbjym8OHk29DZCdAjuwe9zGpatXPvMp/JbUeMREtgzwNd4nZQY8UkJ\na7ZLSGSCXsPsMcx2sflEvmbXttE7M9+lIVZl7MZ6rhXIlvHqrOJg6r3bRqTv\nbKEYZG3hBYyKkp+tBVgi+ZF73N+Ar/DZ1PodYIRt09/Lw3c4H8um6sYSKDsa\nG+fIywKCLDNI4+Tcb/dqfhioMk/iMmLgVhpcwtKRcD1N0aUqdFw1+wnnLqe4\njxCbBTPdEmXzYOy2oSbZxPrZgcs/hPTRHKCu0g70yo7oLb/YHrJH6EKEl3+j\nHdtCwXzmIC9WmKuomLxv12iCasB+DvqU1JsIEHYVPb2TmwSz2+mLOIzH6Hmi\nWlJ19BizdEXQkVynXUR1Vs+uznKiD8OAnzaWFeJBfnUyFNx1PoU25BJp3Hbp\nxUXDCuzegRb9RinVeEwkTeoDQoUTFKt1+b24IPy7M30cNDwLWW9NDiSUzQlR\nt+Gl+/xaLp2G3I+WWCPUyapXGwrqjO2V62CPvCOz/pYhUR8N+xgBEsfr6iia\nEOvO\r\n=GnyA\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGuB8uuz54adC/yHO++iBejfhsKL6jaj0rJNGp9bVBW1AiAeMbwVVm0kuaATQN0RTv9gsgA6osQkkEFpvWNTkkSd6Q=="}]},"maintainers":[{"name":"vriad","email":"colin@vriad.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/trpc_0.8.6_1598330222015_0.3051905425660688"},"_hasShrinkwrap":false},"0.8.7":{"name":"trpc","version":"0.8.7","description":"TypeScript-first toolkit for building RPC APIs","main":"./lib/src/index.js","types":"./lib/src/index.d.ts","repository":{"type":"git","url":"git+https://github.com/vriad/trpc.git"},"author":{"name":"Colin McDonnell","email":"colin@vriad.com"},"license":"MIT","sideEffects":false,"bugs":{"url":"https://github.com/vriad/trpc/issues"},"homepage":"https://github.com/vriad/trpc","dependencies":{"axios":"^0.19.2"},"tags":[],"keywords":[],"include":["src"],"exclude":["node_modules","**/__tests__/*"],"scripts":{"clean":"rm -rf lib/*","build":"yarn run clean && tsc --p tsconfig.package.json","format":"prettier --write \"src/**/*.ts\" \"src/**/*.js\"","lint":"tslint -p tsconfig.json","test":"jest --config jestconfig.json --coverage","testone":"jest --config jestconfig.json","dryrun":"nodemon -e ts -w . -x ts-node src/dryrun.ts","serve":"nodemon -e ts -w . -x ts-node src/serve.ts","prepublishOnly":"npm run build","play":"nodemon -e ts -w . -x ts-node src/playground.ts"},"devDependencies":{"@types/compression":"^1.7.0","@types/cors":"^2.8.7","@types/express":"^4.17.7","@types/jest":"^25.1.4","compression":"^1.7.4","cors":"^2.8.5","express":"^4.17.1","jest":"^25.1.0","nodemon":"^2.0.2","prettier":"^2.0.5","ts-jest":"^25.2.1","typescript":"3.2","zod":"^1.10.1"},"gitHead":"0abd0cf9a89c1f89af639786f6dd8d8b992b09b9","_id":"trpc@0.8.7","_npmVersion":"6.4.1","_nodeVersion":"10.15.3","_npmUser":{"name":"vriad","email":"colin@vriad.com"},"dist":{"integrity":"sha512-zExDxX0v/DJT0QblHGoEvM3g9EAxOhO53c53MNioSRJkHeLDYrlbkS1zMzS/I2quMfJBWD/ExCBMtxAP758a9w==","shasum":"748b0dceb72b3e6ceff5c89af71cf48d5f69cc7a","tarball":"https://registry.npmjs.org/trpc/-/trpc-0.8.7.tgz","fileCount":37,"unpackedSize":67819,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfSdvlCRA9TVsSAnZWagAApUcQAKPr0l6YX6hOEFz3qJRu\nZCcRWvw4t8niLxWhp4oF+SgdJxtCCks+FzG3hDz5APzTTJsvlHnKH0YIk1Jo\ndZSwNvZU58GxBTaZ7bcvX3B3zQdyaCrmT6hepXU924MjjgTYIVauPp695rPz\nHWNLFiWa55GucvLMlpRBbCyqZc7YyJl2TCY8RaZIR2+6iNH5eohia2dFZNsy\n+DXzLV/ENq/3v57uYEng21INP2l7TCKuLfizCyQ2Fy9h2MCcMG0sbpUC/SiE\ngbmrZtjmwJV+UbcIkZGC4KrZpLcgBkfod26HizO8/6M/U+gIPS8isc12jXZV\nmmaNVJ2KmQiewYwhrEsz1jdOaih8pEP5kK7e6p4VAR93M4rgeR2/OGel0ovg\nrMnW46Biog1EIIk6j7fP8Pymbz4DlyVRKEbw2ASf7Zlcb0OsOEVjVPJctdCc\n/TcWB6xjfX0FW8M6EHaw9djGXWRipOLZYpRbq5dH2D8n6/fofdT2Akyp+Jvm\n+jAHBPhWIZdttPhsQ9BTW2Xv0paiae5fEKgqeeUGrrdZrz11veVqtivFqvxs\niaghXOjp7C941LXfRApH0eU7T3QGzwrPUSV9Nsf78dgMiAqttxA5xrop/9SE\nSwNUQ9+NWJXq+RCzOdlA/i3PvTzLRtE90B1uVXoy88l3jhrgdFxSR+Ue/nNs\ncvNT\r\n=jqLF\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDV53dS+qq3Gv2JHupJkc+1XFEIzcytqt6fvn44KYO/pgIgSCIOdXv82yUFO1k5/rzF7lJdeXDkAwmcHjebcUP5C08="}]},"maintainers":[{"name":"vriad","email":"colin@vriad.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/trpc_0.8.7_1598675940781_0.5068097126528579"},"_hasShrinkwrap":false},"0.9.0":{"name":"trpc","version":"0.9.0","description":"TypeScript-first toolkit for building RPC APIs","main":"./lib/src/index.js","types":"./lib/src/index.d.ts","repository":{"type":"git","url":"git+https://github.com/vriad/trpc.git"},"author":{"name":"Colin McDonnell","email":"colin@vriad.com"},"license":"MIT","sideEffects":false,"bugs":{"url":"https://github.com/vriad/trpc/issues"},"homepage":"https://github.com/vriad/trpc","dependencies":{"axios":"^0.19.2"},"tags":[],"keywords":[],"include":["src"],"exclude":["node_modules","**/__tests__/*"],"scripts":{"clean":"rm -rf lib/*","build":"yarn run clean && tsc --p tsconfig.package.json","format":"prettier --write \"src/**/*.ts\" \"src/**/*.js\"","lint":"tslint -p tsconfig.json","test":"jest --config jestconfig.json --coverage","testone":"jest --config jestconfig.json","dryrun":"nodemon -e ts -w . -x ts-node src/dryrun.ts","serve":"nodemon -e ts -w . -x ts-node src/serve.ts","prepublishOnly":"npm run build","play":"nodemon -e ts -w . -x ts-node src/playground.ts"},"devDependencies":{"@types/compression":"^1.7.0","@types/cors":"^2.8.7","@types/express":"^4.17.7","@types/jest":"^25.1.4","compression":"^1.7.4","cors":"^2.8.5","express":"^4.17.1","jest":"^25.1.0","nodemon":"^2.0.2","prettier":"^2.0.5","ts-jest":"^25.2.1","typescript":"3.2","zod":"^1.10.1"},"gitHead":"81ad5b187fe43f4bcf758b194d8d11350d26a8ab","_id":"trpc@0.9.0","_npmVersion":"6.4.1","_nodeVersion":"10.15.3","_npmUser":{"name":"vriad","email":"colin@vriad.com"},"dist":{"integrity":"sha512-Pelwt1aFaPkEHa0SRVAopDvYZJxxyTOeYfAiulf/EvpX/WNq1iLoptH4RIN3ICUJdlPrN3Xi27Gm4wGvGwZWDg==","shasum":"b3851bd9327a5f07ce65983d243f1f2aee098526","tarball":"https://registry.npmjs.org/trpc/-/trpc-0.9.0.tgz","fileCount":37,"unpackedSize":68525,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfSd4GCRA9TVsSAnZWagAALl0P/AlEJeh5lTjQN6Lb54ck\nx0Soe9PW/ECeOJb05cwMR+RmC6pij0qxIQiSQKEt6sBvhq1Js2A1VlrGKJ2R\nw4HtW56OgorndS4yYCLE4TkTSS38hXwEkg/3/sPk+wljpQ+LkcNT03WG32Fa\n32s9wPR10Za5BQjsueiINvbPaSBfwzH6pu7AYXIWDX1scTYM1kW3keYiA6cg\nHnX0+As0j88nXNeLtf+flexZ9uDqamBixFo5lg6VsWdXIqMWbG45rw9rP6sW\n2uPPEJ1ePmmdLKYwqPM4oFyGabf5egfo9X+3o7xuDHi/+ogyCOl6Xui5yI3X\noNrIUQxvmaTM+3DmB0moYztoZBIcOFLcB4Dci7ytmH5QATFR4E6EguKns013\nuwl3NC5mKDenYoo3uCdn4QYcaEIAwcJX1R5ChhGJf82goWyGnDQZIwW0ibSU\no04AbDc61aJr1gUec8C8OtFCrIihIah9TiVgWyO9gkc17Avb7piP1twVDBqW\nsbiT6NA/MXbro4ICHkb3Sqs/IBDfmD4cG4lCiySM69bH0QH8lkQ4oubwIiW7\n0iX2mMLrP9wDRQYSJ3NjOYU0rKeHQZBMURS0GX3ddm1TB+sQ83LP2FCtWamp\ntoO20MrqilL4ezL7QPuEvLm83MdPrEERetZD2O1fzfyo7CALhXuWrpIkvyru\nN+lI\r\n=bl45\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCFSz4fOvWKfBtOpK8lEVhds6qCH6snGO0ofngIq9NFUwIgcoWwa/BAHCC+5meGC+Tf/5zLZFCq3c0rif7j3vrVpZM="}]},"maintainers":[{"name":"vriad","email":"colin@vriad.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/trpc_0.9.0_1598676485628_0.6380105913495744"},"_hasShrinkwrap":false},"0.9.1":{"name":"trpc","version":"0.9.1","description":"TypeScript-first toolkit for building RPC APIs","main":"./lib/src/index.js","types":"./lib/src/index.d.ts","repository":{"type":"git","url":"git+https://github.com/vriad/trpc.git"},"author":{"name":"Colin McDonnell","email":"colin@vriad.com"},"license":"MIT","sideEffects":false,"bugs":{"url":"https://github.com/vriad/trpc/issues"},"homepage":"https://github.com/vriad/trpc","dependencies":{"axios":"^0.19.2"},"tags":[],"keywords":[],"include":["src"],"exclude":["node_modules","**/__tests__/*"],"scripts":{"clean":"rm -rf lib/*","build":"yarn run clean && tsc --p tsconfig.package.json","format":"prettier --write \"src/**/*.ts\" \"src/**/*.js\"","lint":"tslint -p tsconfig.json","test":"jest --config jestconfig.json --coverage","testone":"jest --config jestconfig.json","dryrun":"nodemon -e ts -w . -x ts-node src/dryrun.ts","serve":"nodemon -e ts -w . -x ts-node src/serve.ts","prepublishOnly":"npm run build","play":"nodemon -e ts -w . -x ts-node src/playground.ts"},"devDependencies":{"@types/compression":"^1.7.0","@types/cors":"^2.8.7","@types/express":"^4.17.7","@types/jest":"^25.1.4","compression":"^1.7.4","cors":"^2.8.5","express":"^4.17.1","jest":"^25.1.0","nodemon":"^2.0.2","prettier":"^2.0.5","ts-jest":"^25.2.1","typescript":"3.2","zod":"^1.10.1"},"gitHead":"00cd547c5ac6b504436ce2444f5820af184cb829","_id":"trpc@0.9.1","_npmVersion":"6.4.1","_nodeVersion":"10.15.3","_npmUser":{"name":"vriad","email":"colin@vriad.com"},"dist":{"integrity":"sha512-AcKjcsOlajsfGFD2NB5DgMo4taZ/HYEZJUbg94QyQRRLzCjznxqIJeSHavYeaFUEfbRZYNfRgh/a7jUL7BT/DQ==","shasum":"a4eb5259db99538530fb6550665403d41360eb34","tarball":"https://registry.npmjs.org/trpc/-/trpc-0.9.1.tgz","fileCount":37,"unpackedSize":68901,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfSeFZCRA9TVsSAnZWagAAbr0P/16plD5F9VJgnvMF1Foc\n7zvu2Dv6gwO8mE9M8ynO7C76CfIm7r5s7RoZs+mwwKUpSBeD3v2xAxryx6VZ\nMLwgBN7KtCuAB/Yzevet19d+/WgGhb3KhGHi9ndTyKFTU7ZLvY07zXPKk1pB\nRVfcNr/FyoP4KknAgHWMhZw60S+j1xJWK85xVa6RM7JWp0VwYiJb/COLA9CE\n1vWLNDH6/4yB1y7CM81Mjz9MoJRuSXZevUL0aZ8aEtsYXsvsmnbQ6+UaD5IL\nd7XaqMFGJ+oTBq6AcsASwJWtLDFklmD3jzK7FAPQmYmEUJ73RcocGLeaSjmw\nmWFNt/RIkmWdlgPjMkdqPI4k9hWXqDBlUexRAgJ2ir6WYf4NRrT/H2QHc97i\nqfHlNt32zU9JXVEPlJm9fo20r79O/eWLap/3GREG+04Qo+zGkevKdqEQXuJf\nWALq2KDYxOaixFmZy80qVnF8s/jdfafI1QGeZD1TXDiI1o5R/v6r2yqFog5x\nDy8XoJV0bShsPIenscDLG0L9pehc7j+hivubKlM9rqWdMLGDhay3pKKe2D8L\nGUlEo4ov+7I62+L4d3URncdZPysjNxzBnI909GGmlx+hH+5UxWnAWD5c4zZt\nzl+JPD0ZpBgWn+IAgMmox3U3i7mfFd3vqrzdcftsi7PN9PQaY4ku4/4t14uW\nRbpu\r\n=CG1p\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBBrBH58AFYblDuOPBKr4z7qfJ3EiSqbaSFoxI8RnyVmAiBBEaV9UC4mttLZsWIyLjX0G5ob/HFxxOja0vXnF5YifQ=="}]},"maintainers":[{"name":"vriad","email":"colin@vriad.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/trpc_0.9.1_1598677337228_0.14862739748536935"},"_hasShrinkwrap":false},"0.10.0":{"name":"trpc","version":"0.10.0","description":"TypeScript-first toolkit for building RPC APIs","main":"./lib/src/index.js","types":"./lib/src/index.d.ts","repository":{"type":"git","url":"git+https://github.com/vriad/trpc.git"},"author":{"name":"Colin McDonnell","email":"colin@vriad.com"},"license":"MIT","sideEffects":false,"bugs":{"url":"https://github.com/vriad/trpc/issues"},"homepage":"https://github.com/vriad/trpc","dependencies":{"axios":"^0.19.2"},"tags":[],"keywords":[],"include":["src"],"exclude":["node_modules","**/__tests__/*"],"scripts":{"clean":"rm -rf lib/*","build":"yarn run clean && tsc --p tsconfig.package.json","format":"prettier --write \"src/**/*.ts\" \"src/**/*.js\"","lint":"tslint -p tsconfig.json","test":"jest --config jestconfig.json --coverage","testone":"jest --config jestconfig.json","dryrun":"nodemon -e ts -w . -x ts-node src/dryrun.ts","serve":"nodemon -e ts -w . -x ts-node src/serve.ts","prepublishOnly":"npm run build","play":"nodemon -e ts -w . -x ts-node src/playground.ts"},"devDependencies":{"@types/compression":"^1.7.0","@types/cors":"^2.8.7","@types/express":"^4.17.7","@types/jest":"^25.1.4","compression":"^1.7.4","cors":"^2.8.5","express":"^4.17.1","jest":"^25.1.0","nodemon":"^2.0.2","prettier":"^2.0.5","ts-jest":"^25.2.1","typescript":"^4.1.0-beta","zod":"^1.10.1"},"gitHead":"71c5a56dfaf5c92eed928a5ece4a9320b54800ba","_id":"trpc@0.10.0","_npmVersion":"6.4.1","_nodeVersion":"10.15.3","_npmUser":{"name":"vriad","email":"colin@vriad.com"},"dist":{"integrity":"sha512-gktaSNFzNUN5U2+l+0VYKuICGz9WEO9RliKsdS24PqFCHWjUgn3q89LzVYnHXR4WEJZyml3077XasEWUVvu7ug==","shasum":"3899d7ebcefd3eeb755cefa493bf1d88e590d31a","tarball":"https://registry.npmjs.org/trpc/-/trpc-0.10.0.tgz","fileCount":37,"unpackedSize":72457,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfkIsbCRA9TVsSAnZWagAAQ9UP/js5U7fc7Lc1q0OPOxqA\ndBYR3PIJG1rLIiRoY9M1ARvQI1g2fBcfVzWxixQdv6c87z2NnPpbyj1Xnckp\nQiN9YypvDCSnSgfQCozmvsv8g53UgwlCjONFPpcz3nxHzJi+gHte6k1omtiO\nFai2VCBUewDGKN/UbYoKJwn7thoHcTvyNXdc8oB/pVDQ+MDaWqfcvkuqfgIn\n0Sa9tRx1F7LyCURqaNMi6x7w/xhmZ7NHRb7dWbbWqFnCTq9eOs3Trx08pb2G\nhsvfYTHhesavapsgtOxFeiMxAj5hSz3SV9bt0D5SbEEnceMcRC2LnGlIRkBJ\n/XET4rdgzejqq5LabG2qxDkx85YIEOIYSs4s1XIXYAk1KnQs+C7Vue6GjBLX\nMiTbh+crOVhbI+pMjcqOfDfI/WEdSFtuUJ0aDq2x85xA4yyLEXIuEHARJmNd\ndTizVMiJiE/YwKiWi02/OT306eLDMw6FygTtdCRqywBc8mfLE5RX8XDoHpfD\nAPTgt9PVe0HCZNYPYdYipUEV4gUj7gyZJF9cGpzUdOH3He7kbV+NEJ+OtIWY\ndzC6omQEEviuUiM3tnqtjKMT6V/oGGr9vqG0nL8zPYfIGlnECntPiyMBMKC/\nUjVPy03cNkJb8cHGwfQWzxsNsbp1UNEa5vHCc4owVtXr3lNxAjhyS4KRvl6l\nh03k\r\n=pKEY\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCkFqrEGSWGxNUZqksMj96l8X3GWt2crMGRv15ug8+dEAIhAP2CWjoB2RqMwrAtu/i4eR8kw7pUpjoCmzQg8lpXKTw+"}]},"maintainers":[{"name":"vriad","email":"colin@vriad.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/trpc_0.10.0_1603308314412_0.2601127327288588"},"_hasShrinkwrap":false},"0.10.1":{"name":"trpc","version":"0.10.1","description":"TypeScript-first toolkit for building RPC APIs","main":"./lib/src/index.js","types":"./lib/src/index.d.ts","repository":{"type":"git","url":"git+https://github.com/vriad/trpc.git"},"author":{"name":"Colin McDonnell","email":"colin@vriad.com"},"license":"MIT","sideEffects":false,"bugs":{"url":"https://github.com/vriad/trpc/issues"},"homepage":"https://github.com/vriad/trpc","dependencies":{"axios":"^0.19.2"},"tags":[],"keywords":[],"include":["src"],"exclude":["node_modules","**/__tests__/*"],"scripts":{"clean":"rm -rf lib/*","build":"yarn run clean && tsc --p tsconfig.package.json","format":"prettier --write \"src/**/*.ts\" \"src/**/*.js\"","lint":"tslint -p tsconfig.json","test":"jest --config jestconfig.json --coverage","testone":"jest --config jestconfig.json","dryrun":"nodemon -e ts -w . -x ts-node src/dryrun.ts","serve":"nodemon -e ts -w . -x ts-node src/serve.ts","prepublishOnly":"npm run build","play":"nodemon -e ts -w . -x ts-node src/playground.ts"},"devDependencies":{"@types/compression":"^1.7.0","@types/cors":"^2.8.7","@types/express":"^4.17.7","@types/jest":"^25.1.4","compression":"^1.7.4","cors":"^2.8.5","express":"^4.17.1","jest":"^25.1.0","nodemon":"^2.0.2","prettier":"^2.0.5","ts-jest":"^25.2.1","typescript":"^4.1.0-beta","zod":"^1.10.1"},"gitHead":"f52dc8f14f1fde69c06b2bb042538a1ff285cefd","_id":"trpc@0.10.1","_npmVersion":"6.4.1","_nodeVersion":"10.15.3","_npmUser":{"name":"vriad","email":"colin@vriad.com"},"dist":{"integrity":"sha512-xnGNtpxGLNgPNIAQfVcfOzeKamXdKm7VksLsSO9go7wMZx+e38+biEbpTTMMZr04XmyAV3w869UXFw8wo4/+Gg==","shasum":"1d79dcc0938ef306556183ff80ea116cfacba4fd","tarball":"https://registry.npmjs.org/trpc/-/trpc-0.10.1.tgz","fileCount":37,"unpackedSize":74106,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfmI4YCRA9TVsSAnZWagAACwMP/iaefaSGxQD3qey/dTfe\nWpTHLXjmBL0NNJTbAwvUQxi6GrmFw2JgyiRORHV2aNSgfzgQsF4/6BEvwr4D\ngRikZqZ/M9OzlU6FiT/4y0C3OqUWRIqjlWI3wTCYBpWWszJrXCvbqDvURB3l\n0zQ7p6u4b64mud2fjBh2dermjOK81Ow6yHBJdpOoSG/xlLrFSP3/vi7nqQcd\n1DJJUzt5FJ0DLooP+W/e6WzRPIOPt0uhEaDaIuDIg0UlFP1xl3yKl6VDo32J\na0OTdjO8AQ9OnjacfWobbEAlnde31FeV9E0ebph5/ki3mwUgbxr2UYraW6Kl\no90Ex3LZkxVJfz90v7uw8mTjivYtDiSdc3+GDsy3cDsgZUXi8Iu7Q0uKB3EB\nbbtZ/L66Oc5A3NLZTmncWYAUkoEcrzV7heJrVf5PYx1yfa7xFqE1Sz00s89b\nZD07IhSIDg6MsOHdcjSb+OZP54t3QworkRhk0GFRW3GjnFexGvTohnzQWdh9\nEWOIE9+LwDatMQ/L1EDzYScfh+OoNzfsz1dHBJkIq7W71DApma7NDilHQa6a\nHxvoBXNWzdb/4EYolfsTGxIsYDad0GAeXwq49PLvJozT+7r1KPI7QSvTF90D\niyCU1x+FgmhDid0rO8uJVZF0F4GwMtR6Of/NDbDEdTEPKvv+GZyefxV6tTUd\nJpmn\r\n=injC\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCgZf++2AAttJb/p5FdgRQ+2ffxIE0x3cqEVZSZZrfSiwIhALdYFdfFagk+lrlkS9sZkBtSYwYgbW8UWMivfCXEh66U"}]},"maintainers":[{"name":"vriad","email":"colin@vriad.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/trpc_0.10.1_1603833367604_0.7929914117176102"},"_hasShrinkwrap":false},"0.10.2":{"name":"trpc","version":"0.10.2","description":"TypeScript-first toolkit for building RPC APIs","main":"./lib/src/index.js","types":"./lib/src/index.d.ts","repository":{"type":"git","url":"git+https://github.com/vriad/trpc.git"},"author":{"name":"Colin McDonnell","email":"colin@vriad.com"},"license":"MIT","sideEffects":false,"bugs":{"url":"https://github.com/vriad/trpc/issues"},"homepage":"https://github.com/vriad/trpc","dependencies":{"axios":"^0.19.2"},"tags":[],"keywords":[],"include":["src"],"exclude":["node_modules","**/__tests__/*"],"scripts":{"clean":"rm -rf lib/*","build":"yarn run clean && tsc --p tsconfig.package.json","format":"prettier --write \"src/**/*.ts\" \"src/**/*.js\"","lint":"tslint -p tsconfig.json","test":"jest --config jestconfig.json --coverage","testone":"jest --config jestconfig.json","dryrun":"nodemon -e ts -w . -x ts-node src/dryrun.ts","serve":"nodemon -e ts -w . -x ts-node src/serve.ts","prepublishOnly":"npm run build","play":"nodemon -e ts -w . -x ts-node src/playground.ts"},"devDependencies":{"@types/compression":"^1.7.0","@types/cors":"^2.8.7","@types/express":"^4.17.7","@types/jest":"^25.1.4","compression":"^1.7.4","cors":"^2.8.5","express":"^4.17.1","jest":"^25.1.0","nodemon":"^2.0.2","prettier":"^2.0.5","ts-jest":"^25.2.1","typescript":"^4.1.0-beta","zod":"^1.10.1"},"gitHead":"cc5112d1cacf4c4db88dc2a4f5ab5de300bc8d6b","_id":"trpc@0.10.2","_npmVersion":"6.4.1","_nodeVersion":"10.15.3","_npmUser":{"name":"vriad","email":"colin@vriad.com"},"dist":{"integrity":"sha512-ZDbVtbSvhdNwiFBlF8ZZqQqEoLpG+mnROjdbfdAkaIB7sbTVrjJTylOIITtpfxAkUitZtIQAJyv8y2GAxi9I1g==","shasum":"9f6e4ec6aebe56c295bafd58f20258f6e3116291","tarball":"https://registry.npmjs.org/trpc/-/trpc-0.10.2.tgz","fileCount":37,"unpackedSize":74156,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfmI6ACRA9TVsSAnZWagAAl64P/jOYZ2gr6G6024zLCBb0\n43xqecKgsuEcpM1OOmvFZQqGQ0kBnb955JKtaI1j2A1c/FxUAvRs7tWgIitB\n/C8p6bBQ19/dieg2FVcDT8mS2NLatR2fFQ/7dDiN2qEOJ3KQiHgOgUEjA801\n0GQ8V+wyvdBRDvTDqQtjbb2q6vfMMq4i45C3jzIYOT2s30gxkdjUUWK+hAWG\noLZtJSKTKMKd4cgLx6lHwn955Rh/Rz+MVwZuqftprm7kQe+qWPIiYXUqKJzu\nVOOcJ+HsJWYIqZ5ialNlkSYCaLzgheWT8sHESWwxFXTXKd4PZZKYxZeIZh0z\ni18LTrgpeOOjVW3Qe5fYxrOzxhk6jBlzVyLr2kQRhx1ipNayiWpUzWXgjjbz\naHIzF0znr/HjbxFaFTdWLq8GC8yv8esc9ki/TQC0HyVaq8CGJgUv7AaPiIYG\nvwZSZR6RxNubp53CaFFlrzalnfVpSoecB4r95tFFxphxzdnIHFKs9dfco/9T\ncWnTwubG9gd22GwWBenehcG9EhFu9sGOdu+c3opUZ0eVRQuqPd0R1OQbzJzb\npEI1de+ApuX9YIa5QffLWpIJJFFcVD0K02YWsKBX0XJuRXJ6ppJZwamXVbtM\nJDqFu10JN3DAapT+glnUoq7MhaIdJzYJYlOnT1UYsFTzFc6hBpzvsOdRcctm\nAt3h\r\n=MBpN\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDSby74O9mc0LHoM617sKpJEmo1/q8XJdKqsc40ydTpVwIhALW50HH79ocuWiGchzQaLap9e+ikppXOxSNug8B3jPq3"}]},"maintainers":[{"name":"vriad","email":"colin@vriad.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/trpc_0.10.2_1603833471759_0.36450965817304093"},"_hasShrinkwrap":false},"0.10.3":{"name":"trpc","version":"0.10.3","description":"TypeScript-first toolkit for building RPC APIs","main":"./lib/src/index.js","types":"./lib/src/index.d.ts","repository":{"type":"git","url":"git+https://github.com/vriad/trpc.git"},"author":{"name":"Colin McDonnell","email":"colin@vriad.com"},"license":"MIT","sideEffects":false,"bugs":{"url":"https://github.com/vriad/trpc/issues"},"homepage":"https://github.com/vriad/trpc","dependencies":{"axios":"^0.19.2"},"tags":[],"keywords":[],"include":["src"],"exclude":["node_modules","**/__tests__/*"],"scripts":{"clean":"rm -rf lib/*","build":"yarn run clean && tsc --p tsconfig.package.json","format":"prettier --write \"src/**/*.ts\" \"src/**/*.js\"","lint":"tslint -p tsconfig.json","test":"jest --config jestconfig.json --coverage","testone":"jest --config jestconfig.json","dryrun":"nodemon -e ts -w . -x ts-node src/dryrun.ts","serve":"nodemon -e ts -w . -x ts-node src/serve.ts","prepublishOnly":"npm run build","play":"nodemon -e ts -w . -x ts-node src/playground.ts"},"devDependencies":{"@types/compression":"^1.7.0","@types/cors":"^2.8.7","@types/express":"^4.17.7","@types/jest":"^25.1.4","compression":"^1.7.4","cors":"^2.8.5","express":"^4.17.1","jest":"^25.1.0","nodemon":"^2.0.2","prettier":"^2.0.5","ts-jest":"^25.2.1","typescript":"^4.1.0-beta","zod":"^1.10.1"},"gitHead":"2eda19b137ac9514431edf1ade324baa6f2bf8a4","_id":"trpc@0.10.3","_npmVersion":"6.4.1","_nodeVersion":"10.15.3","_npmUser":{"name":"vriad","email":"colin@vriad.com"},"dist":{"integrity":"sha512-3EagsRLzxoIZxwInz39HqfrZvZSxmN+TCHq3+5pwP/QBlxpiQO8Phmb5DhdfEAfyFTxGUz2WoAGDIKYLb/ZbXA==","shasum":"26811488f65526c2954bb0eda6c17d7d64829d39","tarball":"https://registry.npmjs.org/trpc/-/trpc-0.10.3.tgz","fileCount":37,"unpackedSize":75539,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfmI/NCRA9TVsSAnZWagAAhq8P/1rATJQ1uLTopuYc1Td/\nEzngtSAJ7C5DdQvBoJqkg+4pXp0dV9WEoLfnUx0fRvIHWuKXngr6xaU7ifVy\n34CZm0QhjQpiBF+QKePmJ4HrCvY9s/Um/+ZNNDOqW6Fs3nHMGOJLbQY4nuYn\nzomnFkhGYu99/iQH/zs6lUx7acXv/l8Y7WcXsmAqFm+9OQxlzR8IoBk4JKC9\nuZfFcv49o4QKoF4NSv2WvABSjxAmx7SLcXT3HNctFhTrD4igUdNZX7E3MYu+\nSOFSGHaH0I3J66oPuexETSHebYt5QkrH1i1a0LxR+1NS0FP8Vrt/EL1Qfte7\nO8aHh522ezTNJbVUEov0REmW+BdSaRfojbcqMZN7ftqp4BTpcRp10BiYxuXe\nzan21Lf/3hfxpvj9n63GnB95XqKoytNc7MmtAKTMgyxMd+MmwQwKhAUjLSrr\nqimHC5/lJk3eNxNg4G7Gz6lgZwfW++v5P5H5rt1d03svDi4p88F0HOlk5RMk\nU1wXGRZjR796ltgQXh6m0DSXa2QyQzzWEkf1+XUJbso6vuYWAChsUc0PGhmW\n9xk9N1LD5MjZ4Vej8HwK9j6oqGSCz/jJJvGaAq8Yuc+/7egTlVhPdLkjW7vT\nAh7BA6PEzT075daQ7pdSvQ0jnMjoNqKAk6oPeJG7BeY+o9wGXrQLTjY8N61K\nEAnY\r\n=AhGa\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGUu+rg5A3BxL5z2ccwxZgj3JYnV7HLEcStMbbOhcagJAiB8MKoIsj8epD8fM4CY2emA4ockdqXIUCrzfMkPaguikQ=="}]},"maintainers":[{"name":"vriad","email":"colin@vriad.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/trpc_0.10.3_1603833804521_0.6068489369526688"},"_hasShrinkwrap":false},"0.10.4":{"name":"trpc","version":"0.10.4","description":"TypeScript-first toolkit for building RPC APIs","main":"./lib/src/index.js","types":"./lib/src/index.d.ts","repository":{"type":"git","url":"git+https://github.com/vriad/trpc.git"},"author":{"name":"Colin McDonnell","email":"colin@vriad.com"},"license":"MIT","sideEffects":false,"bugs":{"url":"https://github.com/vriad/trpc/issues"},"homepage":"https://github.com/vriad/trpc","dependencies":{"axios":"^0.19.2"},"tags":[],"keywords":[],"include":["src"],"exclude":["node_modules","**/__tests__/*"],"scripts":{"clean":"rm -rf lib/*","build":"yarn run clean && tsc --p tsconfig.package.json","format":"prettier --write \"src/**/*.ts\" \"src/**/*.js\"","lint":"tslint -p tsconfig.json","test":"jest --config jestconfig.json --coverage","testone":"jest --config jestconfig.json","dryrun":"nodemon -e ts -w . -x ts-node src/dryrun.ts","serve":"nodemon -e ts -w . -x ts-node src/serve.ts","prepublishOnly":"npm run build","play":"nodemon -e ts -w . -x ts-node src/playground.ts"},"devDependencies":{"@types/compression":"^1.7.0","@types/cors":"^2.8.7","@types/express":"^4.17.7","@types/jest":"^25.1.4","compression":"^1.7.4","cors":"^2.8.5","express":"^4.17.1","jest":"^25.1.0","nodemon":"^2.0.2","prettier":"^2.0.5","ts-jest":"^25.2.1","typescript":"^4.1.0-beta","zod":"^1.10.1"},"gitHead":"343de082adab2e24022b19e14bd4535b72a29a2e","_id":"trpc@0.10.4","_npmVersion":"6.4.1","_nodeVersion":"10.15.3","_npmUser":{"name":"vriad","email":"colin@vriad.com"},"dist":{"integrity":"sha512-vVkppPeA3feP6CRrQJDb2xaNRjbX3fLo072Q40ruRdagRKjWrF7OJx3s1QbuDfhDNhM4DaeMBLmdvLYV2W5bEw==","shasum":"6dcf136eee06dbbd22a27795916208131fcd207d","tarball":"https://registry.npmjs.org/trpc/-/trpc-0.10.4.tgz","fileCount":37,"unpackedSize":75547,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfmJByCRA9TVsSAnZWagAAr0EP/1SAnDa1G7NMj1sE33OI\nzHr0xx9TaDue9MUwy8BeRAvjUBQRFqhYaRWR3vGM1pJSmjnNYWCOiH6NbpZu\nucJJC6dHFSnzcqsLRrYHxJYLk+iSs2qVooovXPU/TiRjJLzp9XoNcS0AKKot\nWT4ytiW1et/ae7JLXWMC3xzS0rem+7v/ftDDND7khPnAK7b7eGP+JIjhb3Zw\nabF2tEAjTiyfnpRzNnPt5/lXFGxJDrIYwPp7Gd0jOlPlCg9fqXdX5GPtjNvK\n70hLhLZb/PdxjnTFdR3R5rzWB/e7fqvt4VXnIfd5n52L6A1cEwzrHp7WQ2vk\no6pXDSHY4tm5D2XGP7N7a6oCXJ1HJaNOIsusGOFEeJEfBY5pdj9k2HtIqJCJ\nqIzDB1U2V3LvS76K75JPLW9Ppcg0Ke7b8lrjLp7XIegMrpEe8GCNxCHHeRYO\nAPu/PmmeWigxslhfmevhgw9veBTXye6oCr5YVwkYAkSGA/tvIrgMB2Jmc5FH\nnTKiSw4475JnOuqiAzbX2r+/+WzOLCh8D4PG71h4UlbupZCFXcTsSoHVPxzc\nA/LVPv62KY2Gl+PTScH/6NfLWDnsuiXR2fEc5pzOQyyPDaMsYpcoSdyNKy23\nSGXlgy5xe+gPLG/Uf7he1WYxz33u+YtgIbXIGS4gTq66ZasiD6oiYcXbbHgY\nMc7F\r\n=ERU0\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGGR83KKcORWV2Mgl5AzXkvqwgf1yCs1dttq75u80Vp5AiBpqJwehnpmGCBa93WDd/sb+ZoGLfbJ4oWPfifZQg726A=="}]},"maintainers":[{"name":"vriad","email":"colin@vriad.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/trpc_0.10.4_1603833969556_0.35780487834942964"},"_hasShrinkwrap":false},"0.11.0":{"name":"trpc","version":"0.11.0","description":"TypeScript-first toolkit for building RPC APIs","main":"./lib/src/index.js","types":"./lib/src/index.d.ts","repository":{"type":"git","url":"git+https://github.com/vriad/trpc.git"},"author":{"name":"Colin McDonnell","email":"colin@vriad.com"},"license":"MIT","sideEffects":false,"bugs":{"url":"https://github.com/vriad/trpc/issues"},"homepage":"https://github.com/vriad/trpc","dependencies":{"axios":"^0.19.2"},"tags":[],"keywords":[],"include":["src"],"exclude":["node_modules","**/__tests__/*"],"scripts":{"clean":"rm -rf lib/*","build":"yarn run clean && tsc --p tsconfig.package.json","format":"prettier --write \"src/**/*.ts\" \"src/**/*.js\"","lint":"tslint -p tsconfig.json","test":"jest --config jestconfig.json --coverage","testone":"jest --config jestconfig.json","dryrun":"nodemon -e ts -w . -x ts-node src/dryrun.ts","serve":"nodemon -e ts -w . -x ts-node src/serve.ts","prepublishOnly":"npm run build","play":"nodemon -e ts -w . -x ts-node src/playground.ts"},"devDependencies":{"@types/compression":"^1.7.0","@types/cors":"^2.8.7","@types/express":"^4.17.7","@types/jest":"^25.1.4","compression":"^1.7.4","cors":"^2.8.5","express":"^4.17.1","jest":"^25.1.0","nodemon":"^2.0.2","prettier":"^2.0.5","ts-jest":"^25.2.1","typescript":"^4.1.0-beta","zod":"^1.10.1"},"readme":"<div align=\"center\">\n  <h1 align=\"center\">tRPC</h1>\n  <p>a toolkit for building end-to-end TypeScript data layers</p>\n</div>\n\n<br/>\n<br/>\n\n# Motivation\n\n> This library is undergoing rapid development and should be considered experimental. 🤙\n\ntRPC is a framework for building strongly typed RPC APIs with TypeScript. Alternatively, you can think of it as a way to avoid APIs altogether.\n\n# Usage\n\n### Installation\n\n`npm install trpc`\n\n`yarn add trpc`\n\n### Importing\n\n```ts\nimport { trpc } from 'trpc';\n```\n\n### Compatibility\n\ntRPC depends on the Proxy API and dynamic imports, both of which are [not supported in IE11 and earlier](https://caniuse.com/#feat=proxy).\n\nCompatible with TypeScript 3.2+.\n\n## Define your endpoints\n\n`trpc.endpoint(func: (ctx: any) => (...args: any[]) => any)=>TRPCEndpoint`\n\nInstantiate an endpoint with `trpc.endpoint()`. This function takes a _function that returns a function_.\n\n```ts\nconst computeLength = trpc.endpoint(() => (data: string) => {\n  return data.length;\n});\n```\n\nThe outer function can (optionally) accept a single `ctx` argument. This is how tRPC makes the `ctx` of your RPC calls avaiable to your endpoint logic.\n\n<!-- If you don't need context, you should include it. You'll see why later. Naming the variable `_ctx` will prevent TypeScript from complaining about unused variables. -->\n\n```ts\ntype Ctx = { token: string };\n\nconst getUsername = trpc.endpoint((ctx: Ctx) => () => {\n  const user = await getUserFromToken(ctx.token);\n  return user.username;\n});\n```\n\nThat is a simple endpoint that doesn't actually accept any inputs. Here's a more complex example that posts new \"tweets\" to the user's account.\n\n```ts\ntype Ctx = { token: string };\n\nconst postTweet = trpc.endpoint((ctx: Ctx) => (data: { content: string }) => {\n  const user = await getUserFromToken(ctx.token);\n  const newTweet = await createTweet({\n    content: data.content,\n    userId: user.id,\n  });\n  return newTweet;\n});\n```\n\n## Implement authorization\n\ntRPC provides a built-in way to add authorization logic to your endpoints using the `.authorize` method. **By default all incoming requests are rejected!**\n\n`.authorize` accepts a _function that returns a function_, just like `trpc.endpoint`. It must return a boolean. You can use `ctx` or the endpoint's arguments to determine whether to allow the request.\n\n```ts\nconst getUsername = trpc\n  .endpoint((ctx: Ctx) => async () => {\n    const user = await getUserFromToken(ctx.token);\n    return user.username;\n  })\n  .authorize((ctx) => async (data) => {\n    if (!ctx.token) return false;\n    return true;\n  });\n```\n\n## Define your router(s)\n\n`trpc.router()=>TRPCRouter`\n\nRouters are collections of endpoints. Here's how to create a router and add the `getUsername` endpoint we created above.\n\n```ts\nconst userRouter = trpc.router().endpoint('getUsername', getUsername);\n```\n\nTo add multiple endpoints, you _must chain_ the calls to `.endpoint()`.\n\n```ts\nconst userRouter = trpc\n  .router()\n  .endpoint('getUsername', getUsername)\n  .endpoint('postTweet', postTweet);\n```\n\nIf you're used to Express you may be tempted to try this:\n\n```ts\n// DONT DO THIS\nconst stringRouter = trpc.router();\n\nstringRouter.endpoint('getById', getUserById);\nstringRouter.endpoint('otherEndpoint', otherEndpoint);\n```\n\nThis won't work. In `trpc` routers are _immutable_. The `.endpoint()` method returns an entirely new router, so you must chain the calls.\n\n## Compose multiple routers\n\nYou can compose routers into hierarchies. Below we create a `rootRouter` with one endpoint (`computeLength`, defined above) and one child router (`userRouter`, defined above, aliased to `user`). This will be important later.\n\n```ts\nconst rootRouter = trpc\n  .router()\n  .endpoint('computeLength', computeLength)\n  .compose('user', userRouter);\n```\n\n## Handle requests\n\n`router.handle(payload: Payload)=>any`\n\nThe `Payload` type is:\n\n```ts\ntype Payload = {\n  path: string[];\n  context: any;\n  args: any[];\n};\n```\n\nRouters can handle \"requests\" using the `.handle` method.\n\n```ts\nrootRouter.handle({\n  endpoint: ['computeLength'],\n  context: {},\n  args: ['this is a sample string'],\n}); // => Promise<23>\n\nrootRouter.handle({\n  endpoint: ['user', 'postTweet'],\n  context: { token: `SAMPLE_TOKEN` },\n  args: [{ content: 'just setting up my twttr' }],\n}); // => Promise<{ /* new Tweet object */ }>\n```\n\n### Express\n\nThere is a convenience function for generating an Express middleware from your router.\n\n```ts\nimport express from 'express';\nimport bodyParser from 'body-parser';\n\nexport const app = express();\napp.use(bodyParser.json());\n\n// serve requests\napp.post('/rpc', rootRouter.toExpress());\n```\n\nSimilar to GraphQL, your entire API is exposed over a single endpoint (in this case `/rpc`). All incoming requests should POST to this endpoint with a body of type `Payload` (defined above).\n\n## Creating a server SDK\n\ntRPC automatically tracks the structure of your router hierarchy and the input/output types of your endpoint. This means we can do some exciting things.\n\ntRPC can autogenerate an \"server SDK\" from any router like so:\n\n```ts\nconst serverSDK = rootRouter.toServerSDK();\n\n// synchronous\n// first argument is context\nconst asdfLength = serverSDK.computeLength({}, 'asdf'); // => 4\n\nconst username = await serverSDK.user.getUsername({ token: 'SAMPLE_TOKEN' });\n// Promise<\"username\">\n\nconst newTweet = await serverSDK.user.postTweet(\n  { token: 'SAMPLE_TOKEN' },\n  {\n    content: 'just setting up my twttr',\n  },\n);\n// Promise<\"username\">\n```\n\nThe first argument to _all_ server SDK calls is the context. Just pass an empty object if your endpoint doesn't use context.\n\nThis is useful for server environments. It provides a standard way to call your own APIs without any code duplication. Plus it **automatically bypasses all authorization checks**. Do not accidentally make this available to any client side code!\n\n## Creating a client SDK\n\n⚠️ Follow the instructions below very carefully! Otherwise you may accidentally expose your server code to the client.\n\nIt's easier than ever to share code between your client and server. The example code below assumes you have a way to do this, either using a tool like [Yarn Workspaces](https://classic.yarnpkg.com/en/docs/workspaces/)/[Lerna](https://github.com/lerna/lerna) or a framework like [Next.js](https://nextjs.org/).\n\n<!-- The days of auto-generating an SDK from OpenAPI specifications — and GraphQL definition files 🙄 — is over. -->\n\n```ts\n// server.ts\n\nexport const rootRouter = /* define router here */;\n```\n\n```ts\n// client.tsx\n\nimport { trpc } from 'trpc';\n\n// only import the TypeScript type of your router!\n// this uses dynamic imports\ntype RootRouter = typeof import('../path/to/server.ts').rootRouter;\n\n// pass in your router type\n// as a generic parameter to trpc.sdk\nconst clientSDK = trpc.sdk<RootRouter>({\n  url: 'http:localhost:3000',\n  getContext: () => {\n    const token = getTokenFromCookies();\n    return { token };\n  },\n});\n```\n\nAs you can see, `trpc.sdk()` accepts a params object with the following keys:\n\n- `url: string` — the URL of your tRPC endpoint, e.g. `http://localhost:3000/rpc`\n- `getContext: ()=>any` — a _synchronous_ function for gathering/computing/fetching any `context` data for the request. This is where you should return the cookies/tokens you'd like to pass with the request. The returned value will be provided to your endpoints in the `ctx` argument.\n\n### Using the SDK\n\n```ts\nconst trySDK = async () => {\n  const query = clientSDK.computeLength('asdf');\n};\n```\n\nThe above SDK call _synchronously_ returns a result of type `TRPCResult<number>`. `TRPCResult<T>` is defined here:\n\n```ts\ntype TRPCResult<T> = {\n  run: () => Promise<T>;\n  payload: {\n    path: string[];\n    args: unknown[];\n    context: unknown;\n  };\n};\n```\n\nHere is how to retreive data from the server:\n\n```ts\nconst trySDK = async () => {\n  const query = clientSDK.computeLength('asdf');\n  const result = await query.run();\n};\n```\n\nThis may seem redundant; why bother including the extra step of calling `.run()`?\n\nAnswer: to make it easier to implement a caching layer on top of TRPC. When you create a new \"query\" (e.g. `const query = clientSDK.computeLength('asdf');`) you immediately have access to a _serializable_ representation of that query in the `payload` parameter. This object _uniquely identifies_ the query you are making! So you can take `query.payload`, serialize it however you like (`JSON.stringify` would work fine), and use it to cache the request!\n\nThis also makes it much easier to integrate with tools like [SWR](https://swr.vercel.app/) which require a unique \"key\" for each request.\n\n```ts\nawait clientSDK.computeLength('asdf'); // => Promise<4>\nawait clientSDK.user.getUsername(); // => Promise<\"username\">\nawait clientSDK.user.postTweet({ content: 'hello world' });\n```\n\nThe client SDK always returns a Promise, even if the server-side logic in synchronous, since the SDK is making a round-trip HTTP request under the hood.\n\nThere's no need to pass a context object as the first input (as with the server SDK) because the context object is produced by the `getContext` function you passed into `trpc.sdk`.\n\n### Custom request handler\n\nBy default tRPC uses Axios to send requests to the `url` you specify in the SDK params. Optionally you can provide an entirely custom HTTP request handler using with `handler`:\n\n```ts\nconst clientSDK = trpc.sdk<RootRouter>({\n  url: 'http:localhost:3000',\n  getContext: () => {\n    const token = getTokenFromCookies();\n    return { token };\n  },\n  handler: async (url, payload) => {\n    const result = await fetch(url, {\n      method: 'POST',\n      headers: {\n        'Content-Type': 'application/json',\n      },\n      body: payload,\n    });\n    return result.json();\n  },\n});\n```\n\n## Recipes\n\n### Usage with Hooks\n\n`tRPC` is designed to be as minimal as possible, so it doesn't ship with any React hooks out of the box. Instead you are encouraged to build your own, using tRPC as a building block, or use a hook built by the community. As a starting point, here is a fully functional example of a `useSDK` hook built with tRPC:\n\n```ts\nimport { useState, useEffect } from 'react';\nimport { trpc, TRPCRequest } from 'trpc';\n\ntype RootRouter = typeof import('../api/api').rootRouter;\n\nconst SDK = trpc.sdk<RootRouter>({\n  url: 'http://localhost:3000/api/rpc',\n  getContext: () => {\n    const token = getTokenFromCookies();\n    if (!token) return null;\n    return { token };\n  },\n});\n\nexport type SDK = typeof SDK;\n\nexport type UseSDKResult<T> = {\n  loading: boolean;\n  error: string | null;\n  data: T | null;\n};\n\nexport const useSDK = <T>(\n  fetcher: (sdk: SDK) => TRPCRequest<T>,\n): UseSDKResult<T> => {\n  const [loading, setLoading] = useState<boolean>(true);\n  const [error, setError] = useState<string | null>(null);\n  const [data, setData] = useState<T | null>(null);\n\n  useEffect(() => {\n    const fetchData = async () => {\n      try {\n        const data = await fetcher(SDK).run();\n        setData(data);\n      } catch (err) {\n        console.log(err);\n        setError(err.message);\n      }\n      setLoading(false);\n      return;\n    };\n    setLoading(true);\n    fetchData();\n  }, []);\n\n  return { data, loading, error };\n};\n```\n\nIt is possible to build other hooks that integrate with popular data fetching libraries like [`react-query`](https://github.com/tannerlinsley/react-query) or [`swr`](https://swr.vercel.app/). If you do so, submit a PR and we'll include that code in the README!\n\n©2020 Colin McDonnell [@vriad](https://twitter.com/vriad)\n","readmeFilename":"README.md","gitHead":"3d85a38383585e3fd574d5e00b24dd3a8c4eea0f","_id":"trpc@0.11.0","_npmVersion":"6.4.1","_nodeVersion":"10.15.3","_npmUser":{"name":"vriad","email":"colin@vriad.com"},"dist":{"integrity":"sha512-M5ZzT1JQeTQEUcUuQH6pGhemGj49KHF+TBxAhAh2rhPHC/Nbk58Qlh2yyw4QJ72gDhiqqNNx1McQslvYnp0l1A==","shasum":"b8df57fffc753c59ef8f07acffed9bd19fdf7068","tarball":"https://registry.npmjs.org/trpc/-/trpc-0.11.0.tgz","fileCount":37,"unpackedSize":75052,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf0ThwCRA9TVsSAnZWagAAaAMQAIoORzSF4bJEkZwRj7y9\nENynnsMKenmO9RAdkRPogEDA2sla5C67WSRTBjJGExPWda7XMjgAofBYvfgm\nmD3vF2Swug2prnaM3NOazxIb/alNDbWvmZlha+2/87NC8seqk9frvNv5vJID\nbi5KhJ+ipTYEShfsF2/jqYs+3WrowUrsKF2TUfyUPbfX/NfWWI5eZ8vN5jXC\ndUosULV2+usb/qPkX2QlNMWEd28NjxX2mJAMAHUhdp1m/geKHaoFeWv1DffH\nXCwnoF8WKSMZGGMylVFAflGCjz7t9gtBMpN3NojYi/xuwCEnVynGtI8vnRdX\n9yLP+t5m5eu3kEnF9MaPrs23Q0XAaplnOblp2K7I/AiJaN9j+gF9SuzbL9mO\nsr9wIY/EVUy7AeTi1AZLLBrFgEiGvRKwTHUcnrRWg9fznEc1nzOApKU5c9cP\nQsamMiu8yTWCHtA9uPZIWk0OS7Mo3hBTDxvHAOI5SoYmItV8Uu5xcgrkeZKx\nJvvjUqiVLapjvkyFOofSbHp81eOqYQiuC5PhrBVYjZoM21jTJZ4uhY/RtJFH\nJsnioBggpQJQBHPQaA+3pqhxGDdXluMJ/VEYJFLvSx6D0YSiISsy/Szy15xR\n3Jlr2AUl5qXwsmcKFYUOcEIObOC8lLWoxd3MbrkRSlDAWOyzL0UtlfAsCUrl\npujU\r\n=mGa3\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDFTLn97N38+/GIBgsq2Eli4t2OvhFhbmaGVey/JmiPuwIhANYVLxhThwe0ctLZ45MkBnw8ysxx1HHi0s2tMWMQ4DML"}]},"directories":{},"maintainers":[{"name":"vriad","email":"colin@vriad.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/trpc_0.11.0_1607546991626_0.5797971621313138"},"_hasShrinkwrap":false,"deprecated":"superseded by @trpc/*-packages - see tRPC.io"},"0.11.1":{"name":"trpc","version":"0.11.1","description":"TypeScript-first toolkit for building RPC APIs","main":"./lib/src/index.js","types":"./lib/src/index.d.ts","repository":{"type":"git","url":"git+https://github.com/vriad/trpc.git"},"author":{"name":"Colin McDonnell","email":"colin@vriad.com"},"license":"MIT","sideEffects":false,"bugs":{"url":"https://github.com/vriad/trpc/issues"},"homepage":"https://github.com/vriad/trpc","dependencies":{"axios":"^0.19.2"},"tags":[],"keywords":[],"include":["src"],"exclude":["node_modules","**/__tests__/*"],"scripts":{"clean":"rm -rf lib/*","build":"yarn run clean && tsc --p tsconfig.package.json","format":"prettier --write \"src/**/*.ts\" \"src/**/*.js\"","lint":"tslint -p tsconfig.json","test":"jest --config jestconfig.json --coverage","testone":"jest --config jestconfig.json","dryrun":"nodemon -e ts -w . -x ts-node src/dryrun.ts","serve":"nodemon -e ts -w . -x ts-node src/serve.ts","prepublishOnly":"npm run build","play":"nodemon -e ts -w . -x ts-node src/playground.ts"},"devDependencies":{"@types/compression":"^1.7.0","@types/cors":"^2.8.7","@types/express":"^4.17.7","@types/jest":"^25.1.4","compression":"^1.7.4","cors":"^2.8.5","express":"^4.17.1","jest":"^25.1.0","nodemon":"^2.0.2","prettier":"^2.0.5","ts-jest":"^25.2.1","typescript":"^4.1.0-beta","zod":"^1.10.1"},"readme":"<div align=\"center\">\n  <h1 align=\"center\">tRPC</h1>\n  <p>a toolkit for building end-to-end TypeScript data layers</p>\n</div>\n\n<br/>\n<br/>\n\n# Motivation\n\n> This library is undergoing rapid development and should be considered experimental. 🤙\n\ntRPC is a framework for building strongly typed RPC APIs with TypeScript. Alternatively, you can think of it as a way to avoid APIs altogether.\n\n# Usage\n\n### Installation\n\n`npm install trpc`\n\n`yarn add trpc`\n\n### Importing\n\n```ts\nimport { trpc } from 'trpc';\n```\n\n### Compatibility\n\ntRPC depends on the Proxy API and dynamic imports, both of which are [not supported in IE11 and earlier](https://caniuse.com/#feat=proxy).\n\nCompatible with TypeScript 3.2+.\n\n## Define your endpoints\n\n`trpc.endpoint(func: (ctx: any) => (...args: any[]) => any)=>TRPCEndpoint`\n\nInstantiate an endpoint with `trpc.endpoint()`. This function takes a _function that returns a function_.\n\n```ts\nconst computeLength = trpc.endpoint(() => (data: string) => {\n  return data.length;\n});\n```\n\nThe outer function can (optionally) accept a single `ctx` argument. This is how tRPC makes the `ctx` of your RPC calls avaiable to your endpoint logic.\n\n<!-- If you don't need context, you should include it. You'll see why later. Naming the variable `_ctx` will prevent TypeScript from complaining about unused variables. -->\n\n```ts\ntype Ctx = { token: string };\n\nconst getUsername = trpc.endpoint((ctx: Ctx) => () => {\n  const user = await getUserFromToken(ctx.token);\n  return user.username;\n});\n```\n\nThat is a simple endpoint that doesn't actually accept any inputs. Here's a more complex example that posts new \"tweets\" to the user's account.\n\n```ts\ntype Ctx = { token: string };\n\nconst postTweet = trpc.endpoint((ctx: Ctx) => (data: { content: string }) => {\n  const user = await getUserFromToken(ctx.token);\n  const newTweet = await createTweet({\n    content: data.content,\n    userId: user.id,\n  });\n  return newTweet;\n});\n```\n\n## Implement authorization\n\ntRPC provides a built-in way to add authorization logic to your endpoints using the `.authorize` method. **By default all incoming requests are rejected!**\n\n`.authorize` accepts a _function that returns a function_, just like `trpc.endpoint`. It must return a boolean. You can use `ctx` or the endpoint's arguments to determine whether to allow the request.\n\n```ts\nconst getUsername = trpc\n  .endpoint((ctx: Ctx) => async () => {\n    const user = await getUserFromToken(ctx.token);\n    return user.username;\n  })\n  .authorize((ctx) => async (data) => {\n    if (!ctx.token) return false;\n    return true;\n  });\n```\n\n## Define your router(s)\n\n`trpc.router()=>TRPCRouter`\n\nRouters are collections of endpoints. Here's how to create a router and add the `getUsername` endpoint we created above.\n\n```ts\nconst userRouter = trpc.router().endpoint('getUsername', getUsername);\n```\n\nTo add multiple endpoints, you _must chain_ the calls to `.endpoint()`.\n\n```ts\nconst userRouter = trpc\n  .router()\n  .endpoint('getUsername', getUsername)\n  .endpoint('postTweet', postTweet);\n```\n\nIf you're used to Express you may be tempted to try this:\n\n```ts\n// DONT DO THIS\nconst stringRouter = trpc.router();\n\nstringRouter.endpoint('getById', getUserById);\nstringRouter.endpoint('otherEndpoint', otherEndpoint);\n```\n\nThis won't work. In `trpc` routers are _immutable_. The `.endpoint()` method returns an entirely new router, so you must chain the calls.\n\n## Compose multiple routers\n\nYou can compose routers into hierarchies. Below we create a `rootRouter` with one endpoint (`computeLength`, defined above) and one child router (`userRouter`, defined above, aliased to `user`). This will be important later.\n\n```ts\nconst rootRouter = trpc\n  .router()\n  .endpoint('computeLength', computeLength)\n  .compose('user', userRouter);\n```\n\n## Handle requests\n\n`router.handle(payload: Payload)=>any`\n\nThe `Payload` type is:\n\n```ts\ntype Payload = {\n  path: string[];\n  context: any;\n  args: any[];\n};\n```\n\nRouters can handle \"requests\" using the `.handle` method.\n\n```ts\nrootRouter.handle({\n  endpoint: ['computeLength'],\n  context: {},\n  args: ['this is a sample string'],\n}); // => Promise<23>\n\nrootRouter.handle({\n  endpoint: ['user', 'postTweet'],\n  context: { token: `SAMPLE_TOKEN` },\n  args: [{ content: 'just setting up my twttr' }],\n}); // => Promise<{ /* new Tweet object */ }>\n```\n\n### Express\n\nThere is a convenience function for generating an Express middleware from your router.\n\n```ts\nimport express from 'express';\nimport bodyParser from 'body-parser';\n\nexport const app = express();\napp.use(bodyParser.json());\n\n// serve requests\napp.post('/rpc', rootRouter.toExpress());\n```\n\nSimilar to GraphQL, your entire API is exposed over a single endpoint (in this case `/rpc`). All incoming requests should POST to this endpoint with a body of type `Payload` (defined above).\n\n## Creating a server SDK\n\ntRPC automatically tracks the structure of your router hierarchy and the input/output types of your endpoint. This means we can do some exciting things.\n\ntRPC can autogenerate an \"server SDK\" from any router like so:\n\n```ts\nconst serverSDK = rootRouter.toServerSDK();\n\n// synchronous\n// first argument is context\nconst asdfLength = serverSDK.computeLength({}, 'asdf'); // => 4\n\nconst username = await serverSDK.user.getUsername({ token: 'SAMPLE_TOKEN' });\n// Promise<\"username\">\n\nconst newTweet = await serverSDK.user.postTweet(\n  { token: 'SAMPLE_TOKEN' },\n  {\n    content: 'just setting up my twttr',\n  },\n);\n// Promise<\"username\">\n```\n\nThe first argument to _all_ server SDK calls is the context. Just pass an empty object if your endpoint doesn't use context.\n\nThis is useful for server environments. It provides a standard way to call your own APIs without any code duplication. Plus it **automatically bypasses all authorization checks**. Do not accidentally make this available to any client side code!\n\n## Creating a client SDK\n\n⚠️ Follow the instructions below very carefully! Otherwise you may accidentally expose your server code to the client.\n\nIt's easier than ever to share code between your client and server. The example code below assumes you have a way to do this, either using a tool like [Yarn Workspaces](https://classic.yarnpkg.com/en/docs/workspaces/)/[Lerna](https://github.com/lerna/lerna) or a framework like [Next.js](https://nextjs.org/).\n\n<!-- The days of auto-generating an SDK from OpenAPI specifications — and GraphQL definition files 🙄 — is over. -->\n\n```ts\n// server.ts\n\nexport const rootRouter = /* define router here */;\n```\n\n```ts\n// client.tsx\n\nimport { trpc } from 'trpc';\n\n// only import the TypeScript type of your router!\n// this uses dynamic imports\ntype RootRouter = typeof import('../path/to/server.ts').rootRouter;\n\n// pass in your router type\n// as a generic parameter to trpc.sdk\nconst clientSDK = trpc.sdk<RootRouter>({\n  url: 'http:localhost:3000',\n  getContext: () => {\n    const token = getTokenFromCookies();\n    return { token };\n  },\n});\n```\n\nAs you can see, `trpc.sdk()` accepts a params object with the following keys:\n\n- `url: string` — the URL of your tRPC endpoint, e.g. `http://localhost:3000/rpc`\n- `getContext: ()=>any` — a _synchronous_ function for gathering/computing/fetching any `context` data for the request. This is where you should return the cookies/tokens you'd like to pass with the request. The returned value will be provided to your endpoints in the `ctx` argument.\n\n### Using the SDK\n\n```ts\nconst trySDK = async () => {\n  const query = clientSDK.computeLength('asdf');\n};\n```\n\nThe above SDK call _synchronously_ returns a result of type `TRPCResult<number>`. `TRPCResult<T>` is defined here:\n\n```ts\ntype TRPCResult<T> = {\n  run: () => Promise<T>;\n  payload: {\n    path: string[];\n    args: unknown[];\n    context: unknown;\n  };\n};\n```\n\nHere is how to retreive data from the server:\n\n```ts\nconst trySDK = async () => {\n  const query = clientSDK.computeLength('asdf');\n  const result = await query.run();\n};\n```\n\nThis may seem redundant; why bother including the extra step of calling `.run()`?\n\nAnswer: to make it easier to implement a caching layer on top of TRPC. When you create a new \"query\" (e.g. `const query = clientSDK.computeLength('asdf');`) you immediately have access to a _serializable_ representation of that query in the `payload` parameter. This object _uniquely identifies_ the query you are making! So you can take `query.payload`, serialize it however you like (`JSON.stringify` would work fine), and use it to cache the request!\n\nThis also makes it much easier to integrate with tools like [SWR](https://swr.vercel.app/) which require a unique \"key\" for each request.\n\n```ts\nawait clientSDK.computeLength('asdf'); // => Promise<4>\nawait clientSDK.user.getUsername(); // => Promise<\"username\">\nawait clientSDK.user.postTweet({ content: 'hello world' });\n```\n\nThe client SDK always returns a Promise, even if the server-side logic in synchronous, since the SDK is making a round-trip HTTP request under the hood.\n\nThere's no need to pass a context object as the first input (as with the server SDK) because the context object is produced by the `getContext` function you passed into `trpc.sdk`.\n\n### Custom request handler\n\nBy default tRPC uses Axios to send requests to the `url` you specify in the SDK params. Optionally you can provide an entirely custom HTTP request handler using with `handler`:\n\n```ts\nconst clientSDK = trpc.sdk<RootRouter>({\n  url: 'http:localhost:3000',\n  getContext: () => {\n    const token = getTokenFromCookies();\n    return { token };\n  },\n  handler: async (url, payload) => {\n    const result = await fetch(url, {\n      method: 'POST',\n      headers: {\n        'Content-Type': 'application/json',\n      },\n      body: payload,\n    });\n    return result.json();\n  },\n});\n```\n\n## Recipes\n\n### Usage with Hooks\n\n`tRPC` is designed to be as minimal as possible, so it doesn't ship with any React hooks out of the box. Instead you are encouraged to build your own, using tRPC as a building block, or use a hook built by the community. As a starting point, here is a fully functional example of a `useSDK` hook built with tRPC:\n\n```ts\nimport { useState, useEffect } from 'react';\nimport { trpc, TRPCRequest } from 'trpc';\n\ntype RootRouter = typeof import('../api/api').rootRouter;\n\nconst SDK = trpc.sdk<RootRouter>({\n  url: 'http://localhost:3000/api/rpc',\n  getContext: () => {\n    const token = getTokenFromCookies();\n    if (!token) return null;\n    return { token };\n  },\n});\n\nexport type SDK = typeof SDK;\n\nexport type UseSDKResult<T> = {\n  loading: boolean;\n  error: string | null;\n  data: T | null;\n};\n\nexport const useSDK = <T>(\n  fetcher: (sdk: SDK) => TRPCRequest<T>,\n): UseSDKResult<T> => {\n  const [loading, setLoading] = useState<boolean>(true);\n  const [error, setError] = useState<string | null>(null);\n  const [data, setData] = useState<T | null>(null);\n\n  useEffect(() => {\n    const fetchData = async () => {\n      try {\n        const data = await fetcher(SDK).run();\n        setData(data);\n      } catch (err) {\n        console.log(err);\n        setError(err.message);\n      }\n      setLoading(false);\n      return;\n    };\n    setLoading(true);\n    fetchData();\n  }, []);\n\n  return { data, loading, error };\n};\n```\n\nIt is possible to build other hooks that integrate with popular data fetching libraries like [`react-query`](https://github.com/tannerlinsley/react-query) or [`swr`](https://swr.vercel.app/). If you do so, submit a PR and we'll include that code in the README!\n\n©2020 Colin McDonnell [@vriad](https://twitter.com/vriad)\n","readmeFilename":"README.md","gitHead":"033a380f27e1496959e8849c8f250921be3b96a2","_id":"trpc@0.11.1","_npmVersion":"6.4.1","_nodeVersion":"10.15.3","_npmUser":{"name":"vriad","email":"colin@vriad.com"},"dist":{"integrity":"sha512-W7K7EEvoe9nEx16izQYm9xbkMZLSjCpXHowmAlYd6kpcpdDl/5OFLPUcJvszFuXf4z1p7Xi8zyWQYhhlhQKpfw==","shasum":"ea283f98d2904f4f513a3112e97235769d8358eb","tarball":"https://registry.npmjs.org/trpc/-/trpc-0.11.1.tgz","fileCount":37,"unpackedSize":75064,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf0VmdCRA9TVsSAnZWagAA/KAP/0VQKRQnIebtHrty3wPc\npYEpnN2PTNxgj8GDzGmYIccIL7z0HGP0Ojf3TKRtl/lLHyAfJzKZ24xzV0iH\nz4O1SHL05bA/P0UB60krhL69dLCvN5i7w8Kvq9PBhhR9l3YTqAaW8C49aR4F\nqgKQdryiZ5SPs3uxv3x8wavgKdrNkpd6xy3zD7XiuxMQC+0NN0vhaHTFHDfT\nNR/gWKgDZ0f7lITc8NHEO+bmVjAhvAX0DRfWxYx5WsrtGN06xabwawhxBLTF\n+urpbTdyuhgAnolEPby6Uh4zpx1rax6YRL3R3oOIgX46rEZ3mj585wP8HKWY\nyXugV9yTgedJDzWQZHXjVcOemq+IxW3nYZlatJUiDvXlf6CFIuj7An252fuX\njSJQx3JgY6i0d+oXLlxL6RktmlvMDwln1LYGmednA3WIGL0g5kvnx3EwurSi\ngusasDM8p6nmMza03Eyou292osu0EYdCAS0AwG3HMXar0xSfjCpb+t9xlPSJ\nPXLeXgbRJMugSHBPu41Z5m+x5QYRhb4aZ+MtBCGSbgPa0j+M2AvrPRlQL+0G\nKR+h7T/6G4OSPmTbjoAjXyNzFcnwwWgMudoUW8p4TSBpBKQyn/Fgm47VKoKM\nXXUQ/zW3ZjthYKUlAO3JJyCqYNzbEQsqOew+8ITxGbcaQioY1WXcf3ZFBCX2\nxe6V\r\n=D16z\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFvBL60JzLCsrjJQ2ef6o2iD2SpQjGLTSTJ3GgoVs09lAiB3hPSglPT4WLbAsvWR1ZoSigELPY6ADfO5+2sRn8XV4w=="}]},"directories":{},"maintainers":[{"name":"vriad","email":"colin@vriad.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/trpc_0.11.1_1607555484647_0.05395462559982467"},"_hasShrinkwrap":false,"deprecated":"superseded by @trpc/*-packages - see tRPC.io"},"0.11.2":{"name":"trpc","version":"0.11.2","description":"TypeScript-first toolkit for building RPC APIs","main":"./lib/src/index.js","types":"./lib/src/index.d.ts","repository":{"type":"git","url":"git+https://github.com/vriad/trpc.git"},"author":{"name":"Colin McDonnell","email":"colin@vriad.com"},"license":"MIT","sideEffects":false,"bugs":{"url":"https://github.com/vriad/trpc/issues"},"homepage":"https://github.com/vriad/trpc","dependencies":{"axios":"^0.19.2"},"tags":[],"keywords":[],"include":["src"],"exclude":["node_modules","**/__tests__/*"],"scripts":{"clean":"rm -rf lib/*","build":"yarn run clean && tsc --p tsconfig.package.json","format":"prettier --write \"src/**/*.ts\" \"src/**/*.js\"","lint":"tslint -p tsconfig.json","test":"jest --config jestconfig.json --coverage","testone":"jest --config jestconfig.json","dryrun":"nodemon -e ts -w . -x ts-node src/dryrun.ts","serve":"nodemon -e ts -w . -x ts-node src/serve.ts","prepublishOnly":"npm run build","play":"nodemon -e ts -w . -x ts-node src/playground.ts"},"devDependencies":{"@types/compression":"^1.7.0","@types/cors":"^2.8.7","@types/express":"^4.17.7","@types/jest":"^25.1.4","compression":"^1.7.4","cors":"^2.8.5","express":"^4.17.1","jest":"^25.1.0","nodemon":"^2.0.2","prettier":"^2.0.5","ts-jest":"^25.2.1","typescript":"^4.1.0-beta","zod":"^1.10.1"},"readme":"<div align=\"center\">\n  <h1 align=\"center\">tRPC</h1>\n  <p>a toolkit for building end-to-end TypeScript data layers</p>\n</div>\n\n<br/>\n<br/>\n\n# Motivation\n\n> This library is undergoing rapid development and should be considered experimental. 🤙\n\ntRPC is a framework for building strongly typed RPC APIs with TypeScript. Alternatively, you can think of it as a way to avoid APIs altogether.\n\n# Usage\n\n### Installation\n\n`npm install trpc`\n\n`yarn add trpc`\n\n### Importing\n\n```ts\nimport { trpc } from 'trpc';\n```\n\n### Compatibility\n\ntRPC depends on the Proxy API and dynamic imports, both of which are [not supported in IE11 and earlier](https://caniuse.com/#feat=proxy).\n\nCompatible with TypeScript 3.2+.\n\n## Define your endpoints\n\n`trpc.endpoint(func: (ctx: any) => (...args: any[]) => any)=>TRPCEndpoint`\n\nInstantiate an endpoint with `trpc.endpoint()`. This function takes a _function that returns a function_.\n\n```ts\nconst computeLength = trpc.endpoint(() => (data: string) => {\n  return data.length;\n});\n```\n\nThe outer function can (optionally) accept a single `ctx` argument. This is how tRPC makes the `ctx` of your RPC calls avaiable to your endpoint logic.\n\n<!-- If you don't need context, you should include it. You'll see why later. Naming the variable `_ctx` will prevent TypeScript from complaining about unused variables. -->\n\n```ts\ntype Ctx = { token: string };\n\nconst getUsername = trpc.endpoint((ctx: Ctx) => () => {\n  const user = await getUserFromToken(ctx.token);\n  return user.username;\n});\n```\n\nThat is a simple endpoint that doesn't actually accept any inputs. Here's a more complex example that posts new \"tweets\" to the user's account.\n\n```ts\ntype Ctx = { token: string };\n\nconst postTweet = trpc.endpoint((ctx: Ctx) => (data: { content: string }) => {\n  const user = await getUserFromToken(ctx.token);\n  const newTweet = await createTweet({\n    content: data.content,\n    userId: user.id,\n  });\n  return newTweet;\n});\n```\n\n## Implement authorization\n\ntRPC provides a built-in way to add authorization logic to your endpoints using the `.authorize` method. **By default all incoming requests are rejected!**\n\n`.authorize` accepts a _function that returns a function_, just like `trpc.endpoint`. It must return a boolean. You can use `ctx` or the endpoint's arguments to determine whether to allow the request.\n\n```ts\nconst getUsername = trpc\n  .endpoint((ctx: Ctx) => async () => {\n    const user = await getUserFromToken(ctx.token);\n    return user.username;\n  })\n  .authorize((ctx) => async (data) => {\n    if (!ctx.token) return false;\n    return true;\n  });\n```\n\n## Define your router(s)\n\n`trpc.router()=>TRPCRouter`\n\nRouters are collections of endpoints. Here's how to create a router and add the `getUsername` endpoint we created above.\n\n```ts\nconst userRouter = trpc.router().endpoint('getUsername', getUsername);\n```\n\nTo add multiple endpoints, you _must chain_ the calls to `.endpoint()`.\n\n```ts\nconst userRouter = trpc\n  .router()\n  .endpoint('getUsername', getUsername)\n  .endpoint('postTweet', postTweet);\n```\n\nIf you're used to Express you may be tempted to try this:\n\n```ts\n// DONT DO THIS\nconst stringRouter = trpc.router();\n\nstringRouter.endpoint('getById', getUserById);\nstringRouter.endpoint('otherEndpoint', otherEndpoint);\n```\n\nThis won't work. In `trpc` routers are _immutable_. The `.endpoint()` method returns an entirely new router, so you must chain the calls.\n\n## Compose multiple routers\n\nYou can compose routers into hierarchies. Below we create a `rootRouter` with one endpoint (`computeLength`, defined above) and one child router (`userRouter`, defined above, aliased to `user`). This will be important later.\n\n```ts\nconst rootRouter = trpc\n  .router()\n  .endpoint('computeLength', computeLength)\n  .compose('user', userRouter);\n```\n\n## Handle requests\n\n`router.handle(payload: Payload)=>any`\n\nThe `Payload` type is:\n\n```ts\ntype Payload = {\n  path: string[];\n  context: any;\n  args: any[];\n};\n```\n\nRouters can handle \"requests\" using the `.handle` method.\n\n```ts\nrootRouter.handle({\n  endpoint: ['computeLength'],\n  context: {},\n  args: ['this is a sample string'],\n}); // => Promise<23>\n\nrootRouter.handle({\n  endpoint: ['user', 'postTweet'],\n  context: { token: `SAMPLE_TOKEN` },\n  args: [{ content: 'just setting up my twttr' }],\n}); // => Promise<{ /* new Tweet object */ }>\n```\n\n### Express\n\nThere is a convenience function for generating an Express middleware from your router.\n\n```ts\nimport express from 'express';\nimport bodyParser from 'body-parser';\n\nexport const app = express();\napp.use(bodyParser.json());\n\n// serve requests\napp.post('/rpc', rootRouter.toExpress());\n```\n\nSimilar to GraphQL, your entire API is exposed over a single endpoint (in this case `/rpc`). All incoming requests should POST to this endpoint with a body of type `Payload` (defined above).\n\n## Creating a server SDK\n\ntRPC automatically tracks the structure of your router hierarchy and the input/output types of your endpoint. This means we can do some exciting things.\n\ntRPC can autogenerate an \"server SDK\" from any router like so:\n\n```ts\nconst serverSDK = rootRouter.toServerSDK();\n\n// synchronous\n// first argument is context\nconst asdfLength = serverSDK.computeLength({}, 'asdf'); // => 4\n\nconst username = await serverSDK.user.getUsername({ token: 'SAMPLE_TOKEN' });\n// Promise<\"username\">\n\nconst newTweet = await serverSDK.user.postTweet(\n  { token: 'SAMPLE_TOKEN' },\n  {\n    content: 'just setting up my twttr',\n  },\n);\n// Promise<\"username\">\n```\n\nThe first argument to _all_ server SDK calls is the context. Just pass an empty object if your endpoint doesn't use context.\n\nThis is useful for server environments. It provides a standard way to call your own APIs without any code duplication. Plus it **automatically bypasses all authorization checks**. Do not accidentally make this available to any client side code!\n\n## Creating a client SDK\n\n⚠️ Follow the instructions below very carefully! Otherwise you may accidentally expose your server code to the client.\n\nIt's easier than ever to share code between your client and server. The example code below assumes you have a way to do this, either using a tool like [Yarn Workspaces](https://classic.yarnpkg.com/en/docs/workspaces/)/[Lerna](https://github.com/lerna/lerna) or a framework like [Next.js](https://nextjs.org/).\n\n<!-- The days of auto-generating an SDK from OpenAPI specifications — and GraphQL definition files 🙄 — is over. -->\n\n```ts\n// server.ts\n\nexport const rootRouter = /* define router here */;\n```\n\n```ts\n// client.tsx\n\nimport { trpc } from 'trpc';\n\n// only import the TypeScript type of your router!\n// this uses dynamic imports\ntype RootRouter = typeof import('../path/to/server.ts').rootRouter;\n\n// pass in your router type\n// as a generic parameter to trpc.sdk\nconst clientSDK = trpc.sdk<RootRouter>({\n  url: 'http:localhost:3000',\n  getContext: () => {\n    const token = getTokenFromCookies();\n    return { token };\n  },\n});\n```\n\nAs you can see, `trpc.sdk()` accepts a params object with the following keys:\n\n- `url: string` — the URL of your tRPC endpoint, e.g. `http://localhost:3000/rpc`\n- `getContext: ()=>any` — a _synchronous_ function for gathering/computing/fetching any `context` data for the request. This is where you should return the cookies/tokens you'd like to pass with the request. The returned value will be provided to your endpoints in the `ctx` argument.\n\n### Using the SDK\n\n```ts\nconst trySDK = async () => {\n  const query = clientSDK.computeLength('asdf');\n};\n```\n\nThe above SDK call _synchronously_ returns a result of type `TRPCResult<number>`. `TRPCResult<T>` is defined here:\n\n```ts\ntype TRPCResult<T> = {\n  run: () => Promise<T>;\n  payload: {\n    path: string[];\n    args: unknown[];\n    context: unknown;\n  };\n};\n```\n\nHere is how to retreive data from the server:\n\n```ts\nconst trySDK = async () => {\n  const query = clientSDK.computeLength('asdf');\n  const result = await query.run();\n};\n```\n\nThis may seem redundant; why bother including the extra step of calling `.run()`?\n\nAnswer: to make it easier to implement a caching layer on top of TRPC. When you create a new \"query\" (e.g. `const query = clientSDK.computeLength('asdf');`) you immediately have access to a _serializable_ representation of that query in the `payload` parameter. This object _uniquely identifies_ the query you are making! So you can take `query.payload`, serialize it however you like (`JSON.stringify` would work fine), and use it to cache the request!\n\nThis also makes it much easier to integrate with tools like [SWR](https://swr.vercel.app/) which require a unique \"key\" for each request.\n\n```ts\nawait clientSDK.computeLength('asdf'); // => Promise<4>\nawait clientSDK.user.getUsername(); // => Promise<\"username\">\nawait clientSDK.user.postTweet({ content: 'hello world' });\n```\n\nThe client SDK always returns a Promise, even if the server-side logic in synchronous, since the SDK is making a round-trip HTTP request under the hood.\n\nThere's no need to pass a context object as the first input (as with the server SDK) because the context object is produced by the `getContext` function you passed into `trpc.sdk`.\n\n### Custom request handler\n\nBy default tRPC uses Axios to send requests to the `url` you specify in the SDK params. Optionally you can provide an entirely custom HTTP request handler using with `handler`:\n\n```ts\nconst clientSDK = trpc.sdk<RootRouter>({\n  url: 'http:localhost:3000',\n  getContext: () => {\n    const token = getTokenFromCookies();\n    return { token };\n  },\n  handler: async (url, payload) => {\n    const result = await fetch(url, {\n      method: 'POST',\n      headers: {\n        'Content-Type': 'application/json',\n      },\n      body: payload,\n    });\n    return result.json();\n  },\n});\n```\n\n## Recipes\n\n### Usage with Hooks\n\n`tRPC` is designed to be as minimal as possible, so it doesn't ship with any React hooks out of the box. Instead you are encouraged to build your own, using tRPC as a building block, or use a hook built by the community. As a starting point, here is a fully functional example of a `useSDK` hook built with tRPC:\n\n```ts\nimport { useState, useEffect } from 'react';\nimport { trpc, TRPCRequest } from 'trpc';\n\ntype RootRouter = typeof import('../api/api').rootRouter;\n\nconst SDK = trpc.sdk<RootRouter>({\n  url: 'http://localhost:3000/api/rpc',\n  getContext: () => {\n    const token = getTokenFromCookies();\n    if (!token) return null;\n    return { token };\n  },\n});\n\nexport type SDK = typeof SDK;\n\nexport type UseSDKResult<T> = {\n  loading: boolean;\n  error: string | null;\n  data: T | null;\n};\n\nexport const useSDK = <T>(\n  fetcher: (sdk: SDK) => TRPCRequest<T>,\n): UseSDKResult<T> => {\n  const [loading, setLoading] = useState<boolean>(true);\n  const [error, setError] = useState<string | null>(null);\n  const [data, setData] = useState<T | null>(null);\n\n  useEffect(() => {\n    const fetchData = async () => {\n      try {\n        const data = await fetcher(SDK).run();\n        setData(data);\n      } catch (err) {\n        console.log(err);\n        setError(err.message);\n      }\n      setLoading(false);\n      return;\n    };\n    setLoading(true);\n    fetchData();\n  }, []);\n\n  return { data, loading, error };\n};\n```\n\nIt is possible to build other hooks that integrate with popular data fetching libraries like [`react-query`](https://github.com/tannerlinsley/react-query) or [`swr`](https://swr.vercel.app/). If you do so, submit a PR and we'll include that code in the README!\n\n©2020 Colin McDonnell [@vriad](https://twitter.com/vriad)\n","readmeFilename":"README.md","gitHead":"1d1354bb42958285e9a661b5c7c1f0b96d7f0ba2","_id":"trpc@0.11.2","_npmVersion":"6.4.1","_nodeVersion":"10.15.3","_npmUser":{"name":"vriad","email":"colin@vriad.com"},"dist":{"integrity":"sha512-Q4sEXXhj4uh343DKMLXgxsj6ujgcRPhEO9UQsXvbM9p85Av9Px/yNm+FGCuyBPoKAdy/iWMbcy4MkbAehlYMKw==","shasum":"8bfaf2275dfa9f634a4d45b4295914f91413de38","tarball":"https://registry.npmjs.org/trpc/-/trpc-0.11.2.tgz","fileCount":37,"unpackedSize":75064,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf0a8TCRA9TVsSAnZWagAAQN4P/R2T9opbV1iFutjb1cFJ\nxqatuCQ5TmxVqyUThqh7GixKQ8lo6cegJrMd/EWADVnR9cP5bhO/50hXqPys\n+ccZS298/a32OXQtSDPX6dx/7zr9v/Na5fwVwX2HqEPC2NqUCMs+RNrCEsPs\nLkCL/u8q0khcIxOlOCNwpq3kBw0VJYjO0Wfn1Q67rUpCJT6EAzftYym6087s\nr+mhoEsZLR/GRTG7Ds+eGtjOHL7aOwDZ3uhKiDZeXDQZF3/XFo7vK8kGM5gi\ngfh3vioyPmvjWxyWpWe/Eh6TpKTpKB5oRCtAYl02av5r0mK64jLUn/7MLdK7\nIKrYmEcq+I284B+jnhEwiyxIrV2C8izPniGloJJGqKXFPRIpPUc+mJxdwu75\nEi+mT+h7PEgERBXaWM+KQyeVVoToi70KNUcht5x3GIKn6hCAMsF/75S3/LG5\niJ7WzSPqpRdeH9VGIKiroTUguAqWg4upU6tDaTqRNYbS/uAmgzPViCsM4LWe\nLTe1nU/uWe5lVmfnM8LTBoXhlovXk8NRU0+Ned9AI62O9+LlvFwuIFPQPUl+\nrCWABbIBeEL8I4KFhGEE2yICknNbj9wB3qzAdNV/Ugex35w1SgYHNA/8dwei\ndQ7whGib03KgScEZhWLNzsoVNm61tkpmTFel4jD9ShqQIEYEfm6m2NHf0WFE\njJzt\r\n=dmlw\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDwK1cwFilkew51PUEOOYzBO/YOcLHWJpdaSFL1zyKYbwIhAMG0WR5Z2MkoiXVTAGHtem7XhbwlBC/0soH2U1OMG/B8"}]},"directories":{},"maintainers":[{"name":"vriad","email":"colin@vriad.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/trpc_0.11.2_1607577363085_0.502033474220902"},"_hasShrinkwrap":false,"deprecated":"superseded by @trpc/*-packages - see tRPC.io"},"0.11.3-beta.1":{"name":"trpc","version":"0.11.3-beta.1","description":"TypeScript-first toolkit for building RPC APIs","main":"./lib/src/index.js","types":"./lib/src/index.d.ts","repository":{"type":"git","url":"git+https://github.com/vriad/trpc.git"},"author":{"name":"Colin McDonnell","email":"colin@vriad.com"},"license":"MIT","sideEffects":false,"bugs":{"url":"https://github.com/vriad/trpc/issues"},"homepage":"https://github.com/vriad/trpc","dependencies":{"axios":"^0.19.2"},"tags":[],"keywords":[],"include":["src"],"exclude":["node_modules","**/__tests__/*"],"scripts":{"clean":"rm -rf lib/*","build":"yarn run clean && tsc --p tsconfig.package.json","format":"prettier --write \"src/**/*.ts\" \"src/**/*.js\"","lint":"tslint -p tsconfig.json","test":"jest --config jestconfig.json --coverage","testone":"jest --config jestconfig.json","dryrun":"nodemon -e ts -w . -x ts-node src/dryrun.ts","serve":"nodemon -e ts -w . -x ts-node src/serve.ts","prepublishOnly":"npm run build","play":"nodemon -e ts -w . -x ts-node src/playground.ts"},"devDependencies":{"@types/compression":"^1.7.0","@types/cors":"^2.8.7","@types/express":"^4.17.7","@types/jest":"^25.1.4","compression":"^1.7.4","cors":"^2.8.5","express":"^4.17.1","jest":"^25.1.0","nodemon":"^2.0.2","prettier":"^2.0.5","ts-jest":"^25.2.1","typescript":"^4.1.0-beta","zod":"^1.10.1"},"readme":"<div align=\"center\">\n  <h1 align=\"center\">tRPC</h1>\n  <p>a toolkit for building end-to-end TypeScript data layers</p>\n</div>\n\n<br/>\n<br/>\n\n# Motivation\n\n> This library is undergoing rapid development and should be considered experimental. 🤙\n\ntRPC is a framework for building strongly typed RPC APIs with TypeScript. Alternatively, you can think of it as a way to avoid APIs altogether.\n\n# Usage\n\n### Installation\n\n`npm install trpc`\n\n`yarn add trpc`\n\n### Importing\n\n```ts\nimport { trpc } from 'trpc';\n```\n\n### Compatibility\n\ntRPC depends on the Proxy API and dynamic imports, both of which are [not supported in IE11 and earlier](https://caniuse.com/#feat=proxy).\n\nCompatible with TypeScript 3.2+.\n\n## Define your endpoints\n\n`trpc.endpoint(func: (ctx: any) => (...args: any[]) => any)=>TRPCEndpoint`\n\nInstantiate an endpoint with `trpc.endpoint()`. This function takes a _function that returns a function_.\n\n```ts\nconst computeLength = trpc.endpoint(() => (data: string) => {\n  return data.length;\n});\n```\n\nThe outer function can (optionally) accept a single `ctx` argument. This is how tRPC makes the `ctx` of your RPC calls avaiable to your endpoint logic.\n\n<!-- If you don't need context, you should include it. You'll see why later. Naming the variable `_ctx` will prevent TypeScript from complaining about unused variables. -->\n\n```ts\ntype Ctx = { token: string };\n\nconst getUsername = trpc.endpoint((ctx: Ctx) => () => {\n  const user = await getUserFromToken(ctx.token);\n  return user.username;\n});\n```\n\nThat is a simple endpoint that doesn't actually accept any inputs. Here's a more complex example that posts new \"tweets\" to the user's account.\n\n```ts\ntype Ctx = { token: string };\n\nconst postTweet = trpc.endpoint((ctx: Ctx) => (data: { content: string }) => {\n  const user = await getUserFromToken(ctx.token);\n  const newTweet = await createTweet({\n    content: data.content,\n    userId: user.id,\n  });\n  return newTweet;\n});\n```\n\n## Implement authorization\n\ntRPC provides a built-in way to add authorization logic to your endpoints using the `.authorize` method. **By default all incoming requests are rejected!**\n\n`.authorize` accepts a _function that returns a function_, just like `trpc.endpoint`. It must return a boolean. You can use `ctx` or the endpoint's arguments to determine whether to allow the request.\n\n```ts\nconst getUsername = trpc\n  .endpoint((ctx: Ctx) => async () => {\n    const user = await getUserFromToken(ctx.token);\n    return user.username;\n  })\n  .authorize((ctx) => async (data) => {\n    if (!ctx.token) return false;\n    return true;\n  });\n```\n\n## Define your router(s)\n\n`trpc.router()=>TRPCRouter`\n\nRouters are collections of endpoints. Here's how to create a router and add the `getUsername` endpoint we created above.\n\n```ts\nconst userRouter = trpc.router().endpoint('getUsername', getUsername);\n```\n\nTo add multiple endpoints, you _must chain_ the calls to `.endpoint()`.\n\n```ts\nconst userRouter = trpc\n  .router()\n  .endpoint('getUsername', getUsername)\n  .endpoint('postTweet', postTweet);\n```\n\nIf you're used to Express you may be tempted to try this:\n\n```ts\n// DONT DO THIS\nconst stringRouter = trpc.router();\n\nstringRouter.endpoint('getById', getUserById);\nstringRouter.endpoint('otherEndpoint', otherEndpoint);\n```\n\nThis won't work. In `trpc` routers are _immutable_. The `.endpoint()` method returns an entirely new router, so you must chain the calls.\n\n## Compose multiple routers\n\nYou can compose routers into hierarchies. Below we create a `rootRouter` with one endpoint (`computeLength`, defined above) and one child router (`userRouter`, defined above, aliased to `user`). This will be important later.\n\n```ts\nconst rootRouter = trpc\n  .router()\n  .endpoint('computeLength', computeLength)\n  .compose('user', userRouter);\n```\n\n## Handle requests\n\n`router.handle(payload: Payload)=>any`\n\nThe `Payload` type is:\n\n```ts\ntype Payload = {\n  path: string[];\n  context: any;\n  args: any[];\n};\n```\n\nRouters can handle \"requests\" using the `.handle` method.\n\n```ts\nrootRouter.handle({\n  endpoint: ['computeLength'],\n  context: {},\n  args: ['this is a sample string'],\n}); // => Promise<23>\n\nrootRouter.handle({\n  endpoint: ['user', 'postTweet'],\n  context: { token: `SAMPLE_TOKEN` },\n  args: [{ content: 'just setting up my twttr' }],\n}); // => Promise<{ /* new Tweet object */ }>\n```\n\n### Express\n\nThere is a convenience function for generating an Express middleware from your router.\n\n```ts\nimport express from 'express';\nimport bodyParser from 'body-parser';\n\nexport const app = express();\napp.use(bodyParser.json());\n\n// serve requests\napp.post('/rpc', rootRouter.toExpress());\n```\n\nSimilar to GraphQL, your entire API is exposed over a single endpoint (in this case `/rpc`). All incoming requests should POST to this endpoint with a body of type `Payload` (defined above).\n\n## Creating a server SDK\n\ntRPC automatically tracks the structure of your router hierarchy and the input/output types of your endpoint. This means we can do some exciting things.\n\ntRPC can autogenerate an \"server SDK\" from any router like so:\n\n```ts\nconst serverSDK = rootRouter.toServerSDK();\n\n// synchronous\n// first argument is context\nconst asdfLength = serverSDK.computeLength({}, 'asdf'); // => 4\n\nconst username = await serverSDK.user.getUsername({ token: 'SAMPLE_TOKEN' });\n// Promise<\"username\">\n\nconst newTweet = await serverSDK.user.postTweet(\n  { token: 'SAMPLE_TOKEN' },\n  {\n    content: 'just setting up my twttr',\n  },\n);\n// Promise<\"username\">\n```\n\nThe first argument to _all_ server SDK calls is the context. Just pass an empty object if your endpoint doesn't use context.\n\nThis is useful for server environments. It provides a standard way to call your own APIs without any code duplication. Plus it **automatically bypasses all authorization checks**. Do not accidentally make this available to any client side code!\n\n## Creating a client SDK\n\n⚠️ Follow the instructions below very carefully! Otherwise you may accidentally expose your server code to the client.\n\nIt's easier than ever to share code between your client and server. The example code below assumes you have a way to do this, either using a tool like [Yarn Workspaces](https://classic.yarnpkg.com/en/docs/workspaces/)/[Lerna](https://github.com/lerna/lerna) or a framework like [Next.js](https://nextjs.org/).\n\n<!-- The days of auto-generating an SDK from OpenAPI specifications — and GraphQL definition files 🙄 — is over. -->\n\n```ts\n// server.ts\n\nexport const rootRouter = /* define router here */;\n```\n\n```ts\n// client.tsx\n\nimport { trpc } from 'trpc';\n\n// only import the TypeScript type of your router!\n// this uses dynamic imports\ntype RootRouter = typeof import('../path/to/server.ts').rootRouter;\n\n// pass in your router type\n// as a generic parameter to trpc.sdk\nconst clientSDK = trpc.sdk<RootRouter>({\n  url: 'http:localhost:3000',\n  getContext: () => {\n    const token = getTokenFromCookies();\n    return { token };\n  },\n});\n```\n\nAs you can see, `trpc.sdk()` accepts a params object with the following keys:\n\n- `url: string` — the URL of your tRPC endpoint, e.g. `http://localhost:3000/rpc`\n- `getContext: ()=>any` — a _synchronous_ function for gathering/computing/fetching any `context` data for the request. This is where you should return the cookies/tokens you'd like to pass with the request. The returned value will be provided to your endpoints in the `ctx` argument.\n\n### Using the SDK\n\n```ts\nconst trySDK = async () => {\n  const query = clientSDK.computeLength('asdf');\n};\n```\n\nThe above SDK call _synchronously_ returns a result of type `TRPCResult<number>`. `TRPCResult<T>` is defined here:\n\n```ts\ntype TRPCResult<T> = {\n  run: () => Promise<T>;\n  payload: {\n    path: string[];\n    args: unknown[];\n    context: unknown;\n  };\n};\n```\n\nHere is how to retreive data from the server:\n\n```ts\nconst trySDK = async () => {\n  const query = clientSDK.computeLength('asdf');\n  const result = await query.run();\n};\n```\n\nThis may seem redundant; why bother including the extra step of calling `.run()`?\n\nAnswer: to make it easier to implement a caching layer on top of TRPC. When you create a new \"query\" (e.g. `const query = clientSDK.computeLength('asdf');`) you immediately have access to a _serializable_ representation of that query in the `payload` parameter. This object _uniquely identifies_ the query you are making! So you can take `query.payload`, serialize it however you like (`JSON.stringify` would work fine), and use it to cache the request!\n\nThis also makes it much easier to integrate with tools like [SWR](https://swr.vercel.app/) which require a unique \"key\" for each request.\n\n```ts\nawait clientSDK.computeLength('asdf'); // => Promise<4>\nawait clientSDK.user.getUsername(); // => Promise<\"username\">\nawait clientSDK.user.postTweet({ content: 'hello world' });\n```\n\nThe client SDK always returns a Promise, even if the server-side logic in synchronous, since the SDK is making a round-trip HTTP request under the hood.\n\nThere's no need to pass a context object as the first input (as with the server SDK) because the context object is produced by the `getContext` function you passed into `trpc.sdk`.\n\n### Custom request handler\n\nBy default tRPC uses Axios to send requests to the `url` you specify in the SDK params. Optionally you can provide an entirely custom HTTP request handler using with `handler`:\n\n```ts\nconst clientSDK = trpc.sdk<RootRouter>({\n  url: 'http:localhost:3000',\n  getContext: () => {\n    const token = getTokenFromCookies();\n    return { token };\n  },\n  handler: async (url, payload) => {\n    const result = await fetch(url, {\n      method: 'POST',\n      headers: {\n        'Content-Type': 'application/json',\n      },\n      body: payload,\n    });\n    return result.json();\n  },\n});\n```\n\n## Recipes\n\n### Usage with Hooks\n\n`tRPC` is designed to be as minimal as possible, so it doesn't ship with any React hooks out of the box. Instead you are encouraged to build your own, using tRPC as a building block, or use a hook built by the community. As a starting point, here is a fully functional example of a `useSDK` hook built with tRPC:\n\n```ts\nimport { useState, useEffect } from 'react';\nimport { trpc, TRPCRequest } from 'trpc';\n\ntype RootRouter = typeof import('../api/api').rootRouter;\n\nconst SDK = trpc.sdk<RootRouter>({\n  url: 'http://localhost:3000/api/rpc',\n  getContext: () => {\n    const token = getTokenFromCookies();\n    if (!token) return null;\n    return { token };\n  },\n});\n\nexport type SDK = typeof SDK;\n\nexport type UseSDKResult<T> = {\n  loading: boolean;\n  error: string | null;\n  data: T | null;\n};\n\nexport const useSDK = <T>(\n  fetcher: (sdk: SDK) => TRPCRequest<T>,\n): UseSDKResult<T> => {\n  const [loading, setLoading] = useState<boolean>(true);\n  const [error, setError] = useState<string | null>(null);\n  const [data, setData] = useState<T | null>(null);\n\n  useEffect(() => {\n    const fetchData = async () => {\n      try {\n        const data = await fetcher(SDK).run();\n        setData(data);\n      } catch (err) {\n        console.log(err);\n        setError(err.message);\n      }\n      setLoading(false);\n      return;\n    };\n    setLoading(true);\n    fetchData();\n  }, []);\n\n  return { data, loading, error };\n};\n```\n\nIt is possible to build other hooks that integrate with popular data fetching libraries like [`react-query`](https://github.com/tannerlinsley/react-query) or [`swr`](https://swr.vercel.app/). If you do so, submit a PR and we'll include that code in the README!\n\n©2020 Colin McDonnell [@vriad](https://twitter.com/vriad)\n","readmeFilename":"README.md","gitHead":"05a895186db67d72a625dc088e022f02f8453d3b","_id":"trpc@0.11.3-beta.1","_npmVersion":"6.4.1","_nodeVersion":"10.15.3","_npmUser":{"name":"vriad","email":"colin@vriad.com"},"dist":{"integrity":"sha512-jvYkM7ZETDN1pMVFl1aiFs1x+EJ1+uXhtRgdrTs54X0vjrEirm4iKQJ0lmdvLRm9Tx6H1hQ31JtCagaHnv82Ag==","shasum":"871a53ec0aa2cf88aead61f3c10a7482e5103846","tarball":"https://registry.npmjs.org/trpc/-/trpc-0.11.3-beta.1.tgz","fileCount":37,"unpackedSize":75632,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf2SFeCRA9TVsSAnZWagAAKisP/2HPIBceIdC5y2tLOC63\nvgy2nuQHRpYKeZDs1hcjJ2dR9h8+HcB1b283d2P8LR+DARkPL41JzCbh5Ni7\nDuiuRDwHlvRb82Im/fPHzS+J2NCjPXjTfjrW3aL4AnhGYBqyQLsqg5dPtwlb\nq0oBsskdZYedi1mIZB/DB3uq18ZyxxnLEhTqdC4ln9FG+qm8CowymhZdobvh\nIDS8xwxkxNuW6tklvGRFYgdmUfp+PHL78G1Nla4PMN9watqVibR9XbQyw9aI\nevNe/NhA7NMbkLG6ZwG0aF7yJsxS0DtfB7Doeiq4nuEqmgHJWiRYLivzkLeU\nDZB8wdm8O5FfOLjCpf6iwZkVl/MRGalXuI4nw0RbczjP9juI7bQqlMAv+QFm\nuQdn3Nlgb03yZ2aVe6mh+MkhDc7smnBazYX+4ZQLraUyJkXoGIiAPOyPJBUU\n3YbO9/rOJD6EJnMEK2byCUVVccQHAJFrrb72D5/B1NkUZGI1KDg0eTR2ktrP\n6ogUJuo0HiQZDOm3cjdnlpOP2ZaNqzubmElxqBn2a1Q7mB8jYZtCZyAoOGHj\nn7odk5IX/6d8BQfZcsn8hMvQ0gdHUrJ06YXLpO9a6Yc11romsVTaBxWCkQUr\nTlFP7RJzxFI4b9Hdi+lz6niimuAO5uEI1IoesNppqhmEsLjUtD7ZHYV6ZvoY\nSrhJ\r\n=GMG/\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIALd4Vs+/krgxM3i1kblwamjLm1/++qlsp/a6qZmM/dLAiB5DivRp13pDrxwGwgq84u4gZXlberwIhkrw22LRb5u+Q=="}]},"directories":{},"maintainers":[{"name":"vriad","email":"colin@vriad.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/trpc_0.11.3-beta.1_1608065374372_0.7391295188436604"},"_hasShrinkwrap":false},"0.11.3-beta.2":{"name":"trpc","version":"0.11.3-beta.2","description":"TypeScript-first toolkit for building RPC APIs","main":"./lib/src/index.js","types":"./lib/src/index.d.ts","repository":{"type":"git","url":"git+https://github.com/vriad/trpc.git"},"author":{"name":"Colin McDonnell","email":"colin@vriad.com"},"license":"MIT","sideEffects":false,"bugs":{"url":"https://github.com/vriad/trpc/issues"},"homepage":"https://github.com/vriad/trpc","dependencies":{"axios":"^0.19.2"},"tags":[],"keywords":[],"include":["src"],"exclude":["node_modules","**/__tests__/*"],"scripts":{"clean":"rm -rf lib/*","build":"yarn run clean && tsc --p tsconfig.package.json","format":"prettier --write \"src/**/*.ts\" \"src/**/*.js\"","lint":"tslint -p tsconfig.json","test":"jest --config jestconfig.json --coverage","testone":"jest --config jestconfig.json","dryrun":"nodemon -e ts -w . -x ts-node src/dryrun.ts","serve":"nodemon -e ts -w . -x ts-node src/serve.ts","prepublishOnly":"npm run build","play":"nodemon -e ts -w . -x ts-node src/playground.ts"},"devDependencies":{"@types/compression":"^1.7.0","@types/cors":"^2.8.7","@types/express":"^4.17.7","@types/jest":"^25.1.4","compression":"^1.7.4","cors":"^2.8.5","express":"^4.17.1","jest":"^25.1.0","nodemon":"^2.0.2","prettier":"^2.0.5","ts-jest":"^25.2.1","typescript":"^4.1.0-beta","zod":"^1.10.1"},"readme":"<div align=\"center\">\n  <h1 align=\"center\">tRPC</h1>\n  <p>a toolkit for building end-to-end TypeScript data layers</p>\n</div>\n\n<br/>\n<br/>\n\n# Motivation\n\n> This library is undergoing rapid development and should be considered experimental. 🤙\n\ntRPC is a framework for building strongly typed RPC APIs with TypeScript. Alternatively, you can think of it as a way to avoid APIs altogether.\n\n# Usage\n\n### Installation\n\n`npm install trpc`\n\n`yarn add trpc`\n\n### Importing\n\n```ts\nimport { trpc } from 'trpc';\n```\n\n### Compatibility\n\ntRPC depends on the Proxy API and dynamic imports, both of which are [not supported in IE11 and earlier](https://caniuse.com/#feat=proxy).\n\nCompatible with TypeScript 3.2+.\n\n## Define your endpoints\n\n`trpc.endpoint(func: (ctx: any) => (...args: any[]) => any)=>TRPCEndpoint`\n\nInstantiate an endpoint with `trpc.endpoint()`. This function takes a _function that returns a function_.\n\n```ts\nconst computeLength = trpc.endpoint(() => (data: string) => {\n  return data.length;\n});\n```\n\nThe outer function can (optionally) accept a single `ctx` argument. This is how tRPC makes the `ctx` of your RPC calls avaiable to your endpoint logic.\n\n<!-- If you don't need context, you should include it. You'll see why later. Naming the variable `_ctx` will prevent TypeScript from complaining about unused variables. -->\n\n```ts\ntype Ctx = { token: string };\n\nconst getUsername = trpc.endpoint((ctx: Ctx) => () => {\n  const user = await getUserFromToken(ctx.token);\n  return user.username;\n});\n```\n\nThat is a simple endpoint that doesn't actually accept any inputs. Here's a more complex example that posts new \"tweets\" to the user's account.\n\n```ts\ntype Ctx = { token: string };\n\nconst postTweet = trpc.endpoint((ctx: Ctx) => (data: { content: string }) => {\n  const user = await getUserFromToken(ctx.token);\n  const newTweet = await createTweet({\n    content: data.content,\n    userId: user.id,\n  });\n  return newTweet;\n});\n```\n\n## Implement authorization\n\ntRPC provides a built-in way to add authorization logic to your endpoints using the `.authorize` method. **By default all incoming requests are rejected!**\n\n`.authorize` accepts a _function that returns a function_, just like `trpc.endpoint`. It must return a boolean. You can use `ctx` or the endpoint's arguments to determine whether to allow the request.\n\n```ts\nconst getUsername = trpc\n  .endpoint((ctx: Ctx) => async () => {\n    const user = await getUserFromToken(ctx.token);\n    return user.username;\n  })\n  .authorize((ctx) => async (data) => {\n    if (!ctx.token) return false;\n    return true;\n  });\n```\n\n## Define your router(s)\n\n`trpc.router()=>TRPCRouter`\n\nRouters are collections of endpoints. Here's how to create a router and add the `getUsername` endpoint we created above.\n\n```ts\nconst userRouter = trpc.router().endpoint('getUsername', getUsername);\n```\n\nTo add multiple endpoints, you _must chain_ the calls to `.endpoint()`.\n\n```ts\nconst userRouter = trpc\n  .router()\n  .endpoint('getUsername', getUsername)\n  .endpoint('postTweet', postTweet);\n```\n\nIf you're used to Express you may be tempted to try this:\n\n```ts\n// DONT DO THIS\nconst stringRouter = trpc.router();\n\nstringRouter.endpoint('getById', getUserById);\nstringRouter.endpoint('otherEndpoint', otherEndpoint);\n```\n\nThis won't work. In `trpc` routers are _immutable_. The `.endpoint()` method returns an entirely new router, so you must chain the calls.\n\n## Compose multiple routers\n\nYou can compose routers into hierarchies. Below we create a `rootRouter` with one endpoint (`computeLength`, defined above) and one child router (`userRouter`, defined above, aliased to `user`). This will be important later.\n\n```ts\nconst rootRouter = trpc\n  .router()\n  .endpoint('computeLength', computeLength)\n  .compose('user', userRouter);\n```\n\n## Handle requests\n\n`router.handle(payload: Payload)=>any`\n\nThe `Payload` type is:\n\n```ts\ntype Payload = {\n  path: string[];\n  context: any;\n  args: any[];\n};\n```\n\nRouters can handle \"requests\" using the `.handle` method.\n\n```ts\nrootRouter.handle({\n  endpoint: ['computeLength'],\n  context: {},\n  args: ['this is a sample string'],\n}); // => Promise<23>\n\nrootRouter.handle({\n  endpoint: ['user', 'postTweet'],\n  context: { token: `SAMPLE_TOKEN` },\n  args: [{ content: 'just setting up my twttr' }],\n}); // => Promise<{ /* new Tweet object */ }>\n```\n\n### Express\n\nThere is a convenience function for generating an Express middleware from your router.\n\n```ts\nimport express from 'express';\nimport bodyParser from 'body-parser';\n\nexport const app = express();\napp.use(bodyParser.json());\n\n// serve requests\napp.post('/rpc', rootRouter.toExpress());\n```\n\nSimilar to GraphQL, your entire API is exposed over a single endpoint (in this case `/rpc`). All incoming requests should POST to this endpoint with a body of type `Payload` (defined above).\n\n## Creating a server SDK\n\ntRPC automatically tracks the structure of your router hierarchy and the input/output types of your endpoint. This means we can do some exciting things.\n\ntRPC can autogenerate an \"server SDK\" from any router like so:\n\n```ts\nconst serverSDK = rootRouter.toServerSDK();\n\n// synchronous\n// first argument is context\nconst asdfLength = serverSDK.computeLength({}, 'asdf'); // => 4\n\nconst username = await serverSDK.user.getUsername({ token: 'SAMPLE_TOKEN' });\n// Promise<\"username\">\n\nconst newTweet = await serverSDK.user.postTweet(\n  { token: 'SAMPLE_TOKEN' },\n  {\n    content: 'just setting up my twttr',\n  },\n);\n// Promise<\"username\">\n```\n\nThe first argument to _all_ server SDK calls is the context. Just pass an empty object if your endpoint doesn't use context.\n\nThis is useful for server environments. It provides a standard way to call your own APIs without any code duplication. Plus it **automatically bypasses all authorization checks**. Do not accidentally make this available to any client side code!\n\n## Creating a client SDK\n\n⚠️ Follow the instructions below very carefully! Otherwise you may accidentally expose your server code to the client.\n\nIt's easier than ever to share code between your client and server. The example code below assumes you have a way to do this, either using a tool like [Yarn Workspaces](https://classic.yarnpkg.com/en/docs/workspaces/)/[Lerna](https://github.com/lerna/lerna) or a framework like [Next.js](https://nextjs.org/).\n\n<!-- The days of auto-generating an SDK from OpenAPI specifications — and GraphQL definition files 🙄 — is over. -->\n\n```ts\n// server.ts\n\nexport const rootRouter = /* define router here */;\n```\n\n```ts\n// client.tsx\n\nimport { trpc } from 'trpc';\n\n// only import the TypeScript type of your router!\n// this uses dynamic imports\ntype RootRouter = typeof import('../path/to/server.ts').rootRouter;\n\n// pass in your router type\n// as a generic parameter to trpc.sdk\nconst clientSDK = trpc.sdk<RootRouter>({\n  url: 'http:localhost:3000',\n  getContext: () => {\n    const token = getTokenFromCookies();\n    return { token };\n  },\n});\n```\n\nAs you can see, `trpc.sdk()` accepts a params object with the following keys:\n\n- `url: string` — the URL of your tRPC endpoint, e.g. `http://localhost:3000/rpc`\n- `getContext: ()=>any` — a _synchronous_ function for gathering/computing/fetching any `context` data for the request. This is where you should return the cookies/tokens you'd like to pass with the request. The returned value will be provided to your endpoints in the `ctx` argument.\n\n### Using the SDK\n\n```ts\nconst trySDK = async () => {\n  const query = clientSDK.computeLength('asdf');\n};\n```\n\nThe above SDK call _synchronously_ returns a result of type `TRPCResult<number>`. `TRPCResult<T>` is defined here:\n\n```ts\ntype TRPCResult<T> = {\n  run: () => Promise<T>;\n  payload: {\n    path: string[];\n    args: unknown[];\n    context: unknown;\n  };\n};\n```\n\nHere is how to retreive data from the server:\n\n```ts\nconst trySDK = async () => {\n  const query = clientSDK.computeLength('asdf');\n  const result = await query.run();\n};\n```\n\nThis may seem redundant; why bother including the extra step of calling `.run()`?\n\nAnswer: to make it easier to implement a caching layer on top of TRPC. When you create a new \"query\" (e.g. `const query = clientSDK.computeLength('asdf');`) you immediately have access to a _serializable_ representation of that query in the `payload` parameter. This object _uniquely identifies_ the query you are making! So you can take `query.payload`, serialize it however you like (`JSON.stringify` would work fine), and use it to cache the request!\n\nThis also makes it much easier to integrate with tools like [SWR](https://swr.vercel.app/) which require a unique \"key\" for each request.\n\n```ts\nawait clientSDK.computeLength('asdf'); // => Promise<4>\nawait clientSDK.user.getUsername(); // => Promise<\"username\">\nawait clientSDK.user.postTweet({ content: 'hello world' });\n```\n\nThe client SDK always returns a Promise, even if the server-side logic in synchronous, since the SDK is making a round-trip HTTP request under the hood.\n\nThere's no need to pass a context object as the first input (as with the server SDK) because the context object is produced by the `getContext` function you passed into `trpc.sdk`.\n\n### Custom request handler\n\nBy default tRPC uses Axios to send requests to the `url` you specify in the SDK params. Optionally you can provide an entirely custom HTTP request handler using with `handler`:\n\n```ts\nconst clientSDK = trpc.sdk<RootRouter>({\n  url: 'http:localhost:3000',\n  getContext: () => {\n    const token = getTokenFromCookies();\n    return { token };\n  },\n  handler: async (url, payload) => {\n    const result = await fetch(url, {\n      method: 'POST',\n      headers: {\n        'Content-Type': 'application/json',\n      },\n      body: payload,\n    });\n    return result.json();\n  },\n});\n```\n\n## Recipes\n\n### Usage with Hooks\n\n`tRPC` is designed to be as minimal as possible, so it doesn't ship with any React hooks out of the box. Instead you are encouraged to build your own, using tRPC as a building block, or use a hook built by the community. As a starting point, here is a fully functional example of a `useSDK` hook built with tRPC:\n\n```ts\nimport { useState, useEffect } from 'react';\nimport { trpc, TRPCRequest } from 'trpc';\n\ntype RootRouter = typeof import('../api/api').rootRouter;\n\nconst SDK = trpc.sdk<RootRouter>({\n  url: 'http://localhost:3000/api/rpc',\n  getContext: () => {\n    const token = getTokenFromCookies();\n    if (!token) return null;\n    return { token };\n  },\n});\n\nexport type SDK = typeof SDK;\n\nexport type UseSDKResult<T> = {\n  loading: boolean;\n  error: string | null;\n  data: T | null;\n};\n\nexport const useSDK = <T>(\n  fetcher: (sdk: SDK) => TRPCRequest<T>,\n): UseSDKResult<T> => {\n  const [loading, setLoading] = useState<boolean>(true);\n  const [error, setError] = useState<string | null>(null);\n  const [data, setData] = useState<T | null>(null);\n\n  useEffect(() => {\n    const fetchData = async () => {\n      try {\n        const data = await fetcher(SDK).run();\n        setData(data);\n      } catch (err) {\n        console.log(err);\n        setError(err.message);\n      }\n      setLoading(false);\n      return;\n    };\n    setLoading(true);\n    fetchData();\n  }, []);\n\n  return { data, loading, error };\n};\n```\n\nIt is possible to build other hooks that integrate with popular data fetching libraries like [`react-query`](https://github.com/tannerlinsley/react-query) or [`swr`](https://swr.vercel.app/). If you do so, submit a PR and we'll include that code in the README!\n\n©2020 Colin McDonnell [@vriad](https://twitter.com/vriad)\n","readmeFilename":"README.md","gitHead":"05a895186db67d72a625dc088e022f02f8453d3b","_id":"trpc@0.11.3-beta.2","_npmVersion":"6.4.1","_nodeVersion":"10.15.3","_npmUser":{"name":"vriad","email":"colin@vriad.com"},"dist":{"integrity":"sha512-sW66xWqZ4tU3iAS56MGocxhG+77/cRiGrH8fuxkGs8izhXW2yQfzERHq787mx1pNHR8Q5+WVE6DUyQ4NGTeORw==","shasum":"05b5184393c13dff60deb757a5e8e68a46cacebf","tarball":"https://registry.npmjs.org/trpc/-/trpc-0.11.3-beta.2.tgz","fileCount":37,"unpackedSize":75686,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf2SNpCRA9TVsSAnZWagAAo1AP/jxHK+CGU8Z8oSGlnzX9\nyytEniXYJsOwaqssc22jnsfhQccO43j+gB0/+fftN/Bxp59Ej864uaWb95cJ\nQWnLuTxX6ci/yz7RvLRKys4pXRDtkeIDdm/2Q6l0r3Z0Dbq8w9nd/ThWfEnT\nbzra7nUMPVSsCsmY7NLM8DeuMFE6jsib15IIAjNYzMrm72hFTXkXPVtUZrhb\n0th/Zc5/bFePxegSeECvuazWflv61sZlRmzTzF0anBflPce7Ighbcn7ZwxXy\nRsPGOVfnPrl0hwHWNd4bq2+Svvqd+28o8z1U4Jx63U9v9Dps2FD8FESOanrM\nS1dhYB86bkcHpU02hHE9fEYIgX5LmS7o+wuKWIsc9LhyOUK3VlnUKizRnCEQ\nwwI7KOdf1M2sXB/uj5dRyrrmfVAdc2ESxfxtCrZO4l9UYDjcUs/f5f2C71MY\ngCkZ6C6ySr0WiKaigCYomaPnL2x+U4g189jDTElJgVCsWGvIGFrontXuDUc5\nixJlTCGyK37vUYIun8Eyd+9HjiEJEK7dF40n5ef3pPD3dS+SgaxVZlwePc7L\n4nhJo7JuTFXGkQ3/6bCnCb/68EY36u3GeTcnt5Y4aXeQMcFBFU72vgD2ySNo\nH+UswLctvyLjIb9/God5tKXftY7WrZLRUkvttDrqanxSDKg30Q/ImTgsSeEx\n/W+d\r\n=p6Xp\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHU5InYdDiDbbtW35nGEp1CAdAn9B6QvEKpWqem84a48AiA+3sneCzlkZp6YNXHHFIrUzcT7bEz6sIP5yRf/Yojtxg=="}]},"directories":{},"maintainers":[{"name":"vriad","email":"colin@vriad.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/trpc_0.11.3-beta.2_1608065896644_0.4160075505664147"},"_hasShrinkwrap":false},"0.11.3":{"name":"trpc","version":"0.11.3","description":"TypeScript-first toolkit for building RPC APIs","main":"./lib/src/index.js","types":"./lib/src/index.d.ts","repository":{"type":"git","url":"git+https://github.com/vriad/trpc.git"},"author":{"name":"Colin McDonnell","email":"colin@vriad.com"},"license":"MIT","sideEffects":false,"bugs":{"url":"https://github.com/vriad/trpc/issues"},"homepage":"https://github.com/vriad/trpc","dependencies":{"axios":"^0.19.2"},"tags":[],"keywords":[],"include":["src"],"exclude":["node_modules","**/__tests__/*"],"scripts":{"clean":"rm -rf lib/*","build":"yarn run clean && tsc --p tsconfig.package.json","format":"prettier --write \"src/**/*.ts\" \"src/**/*.js\"","lint":"tslint -p tsconfig.json","test":"jest --config jestconfig.json --coverage","testone":"jest --config jestconfig.json","dryrun":"nodemon -e ts -w . -x ts-node src/dryrun.ts","serve":"nodemon -e ts -w . -x ts-node src/serve.ts","prepublishOnly":"npm run build","play":"nodemon -e ts -w . -x ts-node src/playground.ts"},"devDependencies":{"@types/compression":"^1.7.0","@types/cors":"^2.8.7","@types/express":"^4.17.7","@types/jest":"^25.1.4","compression":"^1.7.4","cors":"^2.8.5","express":"^4.17.1","jest":"^25.1.0","nodemon":"^2.0.2","prettier":"^2.0.5","ts-jest":"^25.2.1","typescript":"^4.1.0-beta","zod":"^1.10.1"},"gitHead":"ed697b645790b59604782e506e45b928e8e62961","_id":"trpc@0.11.3","_npmVersion":"6.4.1","_nodeVersion":"10.15.3","_npmUser":{"name":"vriad","email":"colin@vriad.com"},"dist":{"integrity":"sha512-vfj6WrxYk8XDZzCsFNLwo5WhlKi4IYmVRzRgRQAlcK8zH4sY0yIAlJ7Nd1lZcGFe985GfP2LZLoEsCrMsIl/tA==","shasum":"1e47f770c418c5d48dcd93dfc3ccc4792c45fc46","tarball":"https://registry.npmjs.org/trpc/-/trpc-0.11.3.tgz","fileCount":37,"unpackedSize":75679,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf2SQJCRA9TVsSAnZWagAAcT8P/1mlP4EyePQd6DTCqfia\n2zCKKTKPUmF73zOp/rx22PLYfHgXOvmHCbe/bo/WIp/9/uDW+F141paZTZc4\nQMGbvNnQUX/atPdY48mWXPqVp6LR59gkij69kYvkb7mYcBfv1/IShfxJRTFb\nCTfX9ZbVt2j4o7dKFxIiXVN5SbMVW74B01YZomI1MAYF689b/tsL8IA2KEx0\nNdXGFkB5jl84xwUYela+KRCnSjW4zGELpqm3Cxk4H8m5qYW9h3WUSH4x4E2a\nut+0SF1+X4rLa/PvQombZ3e3H5ziKRHa/+pGy97f4KzN88dDVdqL9AeMah2U\nyjngL4uwUWtxNFH96NhYrhfX76tUo/+dv1gDNT/Ah/nO6LYYrcITtGhSSr3v\nS7pEYTary0s73qBJc366hQ2cHIYu175o1sXk8KVYnTJvp9UfGwA0mBBXUsoC\nvowPP5oeRw17ltmUluqGTuWsNioWtBJbIgyxQDkSxQorESVUbl8kW3aqweo0\n77eVulSvEyFBubg5R6JWPUvAZqx522syePTq95jTEp2OWUaw4YVGAZKzrTPz\nohhtm3jLPYGJsl5bKp/UMQRYe5KK4H2A2gPHlokvRmbInyRU7BUVSv4ne6/r\nghtnFedGaS2HOHKXHxlXKy630dwXodfUqXpPjOSN7AVx5KfC8PxGRP0BK1II\n3dyx\r\n=Al7H\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEgQ7Xz/bKL/SkDIcUW4PUMbnMcarhycHoWtUOhXc59pAiAfY6d7Sldg8HLqRn5pSIfhzrx2BIArAGV898+TOAa+YQ=="}]},"directories":{},"maintainers":[{"name":"vriad","email":"colin@vriad.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/trpc_0.11.3_1608066057204_0.46863381564882634"},"_hasShrinkwrap":false,"deprecated":"superseded by @trpc/*-packages - see tRPC.io"}},"time":{"created":"2020-08-03T23:41:47.932Z","0.0.2":"2020-08-03T23:41:48.079Z","modified":"2022-05-22T06:07:01.916Z","0.1.0":"2020-08-08T03:05:12.621Z","0.2.0":"2020-08-08T06:08:52.791Z","0.3.0":"2020-08-08T06:22:38.841Z","0.4.0":"2020-08-09T05:40:29.529Z","0.4.1":"2020-08-09T05:56:02.967Z","0.4.3":"2020-08-09T06:08:48.170Z","0.4.4":"2020-08-09T06:12:26.525Z","0.4.5":"2020-08-09T06:22:54.503Z","0.5.0":"2020-08-09T07:04:08.084Z","0.6.0":"2020-08-09T08:01:53.556Z","0.6.1":"2020-08-09T08:13:39.887Z","0.6.2":"2020-08-09T08:19:41.947Z","0.7.0":"2020-08-10T09:32:38.181Z","0.8.0":"2020-08-20T04:28:07.422Z","0.8.1":"2020-08-21T00:26:42.076Z","0.8.2":"2020-08-21T00:36:30.787Z","0.8.3":"2020-08-21T00:45:49.844Z","0.8.4":"2020-08-21T01:05:02.774Z","0.8.5":"2020-08-21T23:15:24.213Z","0.8.6":"2020-08-25T04:37:02.243Z","0.8.7":"2020-08-29T04:39:00.937Z","0.9.0":"2020-08-29T04:48:05.770Z","0.9.1":"2020-08-29T05:02:17.408Z","0.10.0":"2020-10-21T19:25:14.520Z","0.10.1":"2020-10-27T21:16:07.767Z","0.10.2":"2020-10-27T21:17:51.918Z","0.10.3":"2020-10-27T21:23:24.713Z","0.10.4":"2020-10-27T21:26:09.697Z","0.11.0":"2020-12-09T20:49:51.847Z","0.11.1":"2020-12-09T23:11:24.804Z","0.11.2":"2020-12-10T05:16:03.243Z","0.11.3-beta.1":"2020-12-15T20:49:34.546Z","0.11.3-beta.2":"2020-12-15T20:58:16.818Z","0.11.3":"2020-12-15T21:00:57.348Z"},"maintainers":[{"name":"vriad","email":"colin@vriad.com"}],"description":"TypeScript-first toolkit for building RPC APIs","keywords":[],"author":{"name":"Colin McDonnell","email":"colin@vriad.com"},"license":"MIT","readme":"<div align=\"center\">\n  <h1 align=\"center\">tRPC</h1>\n  <p>a toolkit for building end-to-end TypeScript data layers</p>\n</div>\n\n<br/>\n<br/>\n\n# Motivation\n\n> This library is undergoing rapid development and should be considered experimental. 🤙\n\ntRPC is a framework for building strongly typed RPC APIs with TypeScript. Alternatively, you can think of it as a way to avoid APIs altogether.\n\n# Usage\n\n### Installation\n\n`npm install trpc`\n\n`yarn add trpc`\n\n### Importing\n\n```ts\nimport { trpc } from 'trpc';\n```\n\n### Compatibility\n\ntRPC depends on the Proxy API and dynamic imports, both of which are [not supported in IE11 and earlier](https://caniuse.com/#feat=proxy).\n\nCompatible with TypeScript 3.2+.\n\n## Define your endpoints\n\n`trpc.endpoint(func: (ctx: any) => (...args: any[]) => any)=>TRPCEndpoint`\n\nInstantiate an endpoint with `trpc.endpoint()`. This function takes a _function that returns a function_.\n\n```ts\nconst computeLength = trpc.endpoint(() => (data: string) => {\n  return data.length;\n});\n```\n\nThe outer function can (optionally) accept a single `ctx` argument. This is how tRPC makes the `ctx` of your RPC calls avaiable to your endpoint logic.\n\n<!-- If you don't need context, you should include it. You'll see why later. Naming the variable `_ctx` will prevent TypeScript from complaining about unused variables. -->\n\n```ts\ntype Ctx = { token: string };\n\nconst getUsername = trpc.endpoint((ctx: Ctx) => () => {\n  const user = await getUserFromToken(ctx.token);\n  return user.username;\n});\n```\n\nThat is a simple endpoint that doesn't actually accept any inputs. Here's a more complex example that posts new \"tweets\" to the user's account.\n\n```ts\ntype Ctx = { token: string };\n\nconst postTweet = trpc.endpoint((ctx: Ctx) => (data: { content: string }) => {\n  const user = await getUserFromToken(ctx.token);\n  const newTweet = await createTweet({\n    content: data.content,\n    userId: user.id,\n  });\n  return newTweet;\n});\n```\n\n## Implement authorization\n\ntRPC provides a built-in way to add authorization logic to your endpoints using the `.authorize` method. **By default all incoming requests are rejected!**\n\n`.authorize` accepts a _function that returns a function_, just like `trpc.endpoint`. It must return a boolean. You can use `ctx` or the endpoint's arguments to determine whether to allow the request.\n\n```ts\nconst getUsername = trpc\n  .endpoint((ctx: Ctx) => async () => {\n    const user = await getUserFromToken(ctx.token);\n    return user.username;\n  })\n  .authorize((ctx) => async (data) => {\n    if (!ctx.token) return false;\n    return true;\n  });\n```\n\n## Define your router(s)\n\n`trpc.router()=>TRPCRouter`\n\nRouters are collections of endpoints. Here's how to create a router and add the `getUsername` endpoint we created above.\n\n```ts\nconst userRouter = trpc.router().endpoint('getUsername', getUsername);\n```\n\nTo add multiple endpoints, you _must chain_ the calls to `.endpoint()`.\n\n```ts\nconst userRouter = trpc\n  .router()\n  .endpoint('getUsername', getUsername)\n  .endpoint('postTweet', postTweet);\n```\n\nIf you're used to Express you may be tempted to try this:\n\n```ts\n// DONT DO THIS\nconst stringRouter = trpc.router();\n\nstringRouter.endpoint('getById', getUserById);\nstringRouter.endpoint('otherEndpoint', otherEndpoint);\n```\n\nThis won't work. In `trpc` routers are _immutable_. The `.endpoint()` method returns an entirely new router, so you must chain the calls.\n\n## Compose multiple routers\n\nYou can compose routers into hierarchies. Below we create a `rootRouter` with one endpoint (`computeLength`, defined above) and one child router (`userRouter`, defined above, aliased to `user`). This will be important later.\n\n```ts\nconst rootRouter = trpc\n  .router()\n  .endpoint('computeLength', computeLength)\n  .compose('user', userRouter);\n```\n\n## Handle requests\n\n`router.handle(payload: Payload)=>any`\n\nThe `Payload` type is:\n\n```ts\ntype Payload = {\n  path: string[];\n  context: any;\n  args: any[];\n};\n```\n\nRouters can handle \"requests\" using the `.handle` method.\n\n```ts\nrootRouter.handle({\n  endpoint: ['computeLength'],\n  context: {},\n  args: ['this is a sample string'],\n}); // => Promise<23>\n\nrootRouter.handle({\n  endpoint: ['user', 'postTweet'],\n  context: { token: `SAMPLE_TOKEN` },\n  args: [{ content: 'just setting up my twttr' }],\n}); // => Promise<{ /* new Tweet object */ }>\n```\n\n### Express\n\nThere is a convenience function for generating an Express middleware from your router.\n\n```ts\nimport express from 'express';\nimport bodyParser from 'body-parser';\n\nexport const app = express();\napp.use(bodyParser.json());\n\n// serve requests\napp.post('/rpc', rootRouter.toExpress());\n```\n\nSimilar to GraphQL, your entire API is exposed over a single endpoint (in this case `/rpc`). All incoming requests should POST to this endpoint with a body of type `Payload` (defined above).\n\n## Creating a server SDK\n\ntRPC automatically tracks the structure of your router hierarchy and the input/output types of your endpoint. This means we can do some exciting things.\n\ntRPC can autogenerate an \"server SDK\" from any router like so:\n\n```ts\nconst serverSDK = rootRouter.toServerSDK();\n\n// synchronous\n// first argument is context\nconst asdfLength = serverSDK.computeLength({}, 'asdf'); // => 4\n\nconst username = await serverSDK.user.getUsername({ token: 'SAMPLE_TOKEN' });\n// Promise<\"username\">\n\nconst newTweet = await serverSDK.user.postTweet(\n  { token: 'SAMPLE_TOKEN' },\n  {\n    content: 'just setting up my twttr',\n  },\n);\n// Promise<\"username\">\n```\n\nThe first argument to _all_ server SDK calls is the context. Just pass an empty object if your endpoint doesn't use context.\n\nThis is useful for server environments. It provides a standard way to call your own APIs without any code duplication. Plus it **automatically bypasses all authorization checks**. Do not accidentally make this available to any client side code!\n\n## Creating a client SDK\n\n⚠️ Follow the instructions below very carefully! Otherwise you may accidentally expose your server code to the client.\n\nIt's easier than ever to share code between your client and server. The example code below assumes you have a way to do this, either using a tool like [Yarn Workspaces](https://classic.yarnpkg.com/en/docs/workspaces/)/[Lerna](https://github.com/lerna/lerna) or a framework like [Next.js](https://nextjs.org/).\n\n<!-- The days of auto-generating an SDK from OpenAPI specifications — and GraphQL definition files 🙄 — is over. -->\n\n```ts\n// server.ts\n\nexport const rootRouter = /* define router here */;\n```\n\n```ts\n// client.tsx\n\nimport { trpc } from 'trpc';\n\n// only import the TypeScript type of your router!\n// this uses dynamic imports\ntype RootRouter = typeof import('../path/to/server.ts').rootRouter;\n\n// pass in your router type\n// as a generic parameter to trpc.sdk\nconst clientSDK = trpc.sdk<RootRouter>({\n  url: 'http:localhost:3000',\n  getContext: () => {\n    const token = getTokenFromCookies();\n    return { token };\n  },\n});\n```\n\nAs you can see, `trpc.sdk()` accepts a params object with the following keys:\n\n- `url: string` — the URL of your tRPC endpoint, e.g. `http://localhost:3000/rpc`\n- `getContext: ()=>any` — a _synchronous_ function for gathering/computing/fetching any `context` data for the request. This is where you should return the cookies/tokens you'd like to pass with the request. The returned value will be provided to your endpoints in the `ctx` argument.\n\n### Using the SDK\n\n```ts\nconst trySDK = async () => {\n  const query = clientSDK.computeLength('asdf');\n};\n```\n\nThe above SDK call _synchronously_ returns a result of type `TRPCResult<number>`. `TRPCResult<T>` is defined here:\n\n```ts\ntype TRPCResult<T> = {\n  run: () => Promise<T>;\n  payload: {\n    path: string[];\n    args: unknown[];\n    context: unknown;\n  };\n};\n```\n\nHere is how to retreive data from the server:\n\n```ts\nconst trySDK = async () => {\n  const query = clientSDK.computeLength('asdf');\n  const result = await query.run();\n};\n```\n\nThis may seem redundant; why bother including the extra step of calling `.run()`?\n\nAnswer: to make it easier to implement a caching layer on top of TRPC. When you create a new \"query\" (e.g. `const query = clientSDK.computeLength('asdf');`) you immediately have access to a _serializable_ representation of that query in the `payload` parameter. This object _uniquely identifies_ the query you are making! So you can take `query.payload`, serialize it however you like (`JSON.stringify` would work fine), and use it to cache the request!\n\nThis also makes it much easier to integrate with tools like [SWR](https://swr.vercel.app/) which require a unique \"key\" for each request.\n\n```ts\nawait clientSDK.computeLength('asdf'); // => Promise<4>\nawait clientSDK.user.getUsername(); // => Promise<\"username\">\nawait clientSDK.user.postTweet({ content: 'hello world' });\n```\n\nThe client SDK always returns a Promise, even if the server-side logic in synchronous, since the SDK is making a round-trip HTTP request under the hood.\n\nThere's no need to pass a context object as the first input (as with the server SDK) because the context object is produced by the `getContext` function you passed into `trpc.sdk`.\n\n### Custom request handler\n\nBy default tRPC uses Axios to send requests to the `url` you specify in the SDK params. Optionally you can provide an entirely custom HTTP request handler using with `handler`:\n\n```ts\nconst clientSDK = trpc.sdk<RootRouter>({\n  url: 'http:localhost:3000',\n  getContext: () => {\n    const token = getTokenFromCookies();\n    return { token };\n  },\n  handler: async (url, payload) => {\n    const result = await fetch(url, {\n      method: 'POST',\n      headers: {\n        'Content-Type': 'application/json',\n      },\n      body: payload,\n    });\n    return result.json();\n  },\n});\n```\n\n## Recipes\n\n### Usage with Hooks\n\n`tRPC` is designed to be as minimal as possible, so it doesn't ship with any React hooks out of the box. Instead you are encouraged to build your own, using tRPC as a building block, or use a hook built by the community. As a starting point, here is a fully functional example of a `useSDK` hook built with tRPC:\n\n```ts\nimport { useState, useEffect } from 'react';\nimport { trpc, TRPCRequest } from 'trpc';\n\ntype RootRouter = typeof import('../api/api').rootRouter;\n\nconst SDK = trpc.sdk<RootRouter>({\n  url: 'http://localhost:3000/api/rpc',\n  getContext: () => {\n    const token = getTokenFromCookies();\n    if (!token) return null;\n    return { token };\n  },\n});\n\nexport type SDK = typeof SDK;\n\nexport type UseSDKResult<T> = {\n  loading: boolean;\n  error: string | null;\n  data: T | null;\n};\n\nexport const useSDK = <T>(\n  fetcher: (sdk: SDK) => TRPCRequest<T>,\n): UseSDKResult<T> => {\n  const [loading, setLoading] = useState<boolean>(true);\n  const [error, setError] = useState<string | null>(null);\n  const [data, setData] = useState<T | null>(null);\n\n  useEffect(() => {\n    const fetchData = async () => {\n      try {\n        const data = await fetcher(SDK).run();\n        setData(data);\n      } catch (err) {\n        console.log(err);\n        setError(err.message);\n      }\n      setLoading(false);\n      return;\n    };\n    setLoading(true);\n    fetchData();\n  }, []);\n\n  return { data, loading, error };\n};\n```\n\nIt is possible to build other hooks that integrate with popular data fetching libraries like [`react-query`](https://github.com/tannerlinsley/react-query) or [`swr`](https://swr.vercel.app/). If you do so, submit a PR and we'll include that code in the README!\n\n©2020 Colin McDonnell [@vriad](https://twitter.com/vriad)\n","readmeFilename":"README.md","homepage":"https://github.com/vriad/trpc","repository":{"type":"git","url":"git+https://github.com/vriad/trpc.git"},"bugs":{"url":"https://github.com/vriad/trpc/issues"}}