{"_id":"rpc-with-types","_rev":"28-c4006d519cd28112a8b1ab879eef253c","name":"rpc-with-types","dist-tags":{"latest":"4.0.3"},"versions":{"4.0.0":{"name":"rpc-with-types","version":"4.0.0","keywords":["rpc","typescript","websockets","ws","framework"],"license":"MIT","_id":"rpc-with-types@4.0.0","maintainers":[{"name":"hashelq","email":"suramaru0@gmail.com"}],"homepage":"https://github.com/hashelq/rpc-ts#readme","bugs":{"url":"https://github.com/hashelq/rpc-ts/issues"},"dist":{"shasum":"2f6c85fa776a82422719769013710be8b7d25bfd","tarball":"https://registry.npmjs.org/rpc-with-types/-/rpc-with-types-4.0.0.tgz","fileCount":23,"integrity":"sha512-aIY6h6e+FdCCyBWOvRWAuThtqvdUrXoJNOBL+wz7LjjQyw0oo8C3ZnZTzZFEcsZ6pAth15RLpsKbRckVfcnRYg==","signatures":[{"sig":"MEYCIQDetvRN7WWlwamUhZ+B1gfhB48OgAb2ULtgYwfjCodLCgIhAK9jXUZbmrIC4ABKjl4LrLnIdeCtQWyihEhh3Vig35FQ","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":32612},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","gitHead":"8b4715857786faa3cb52fb1f4e18aa3f4fb0ab01","scripts":{"test":"tsc --esModuleInterop && mocha ./dist/tests.js","build":"tsc --esModuleInterop","do-publish":"npm run build && npm publish"},"_npmUser":{"name":"hashelq","email":"suramaru0@gmail.com"},"repository":{"url":"git+https://github.com/hashelq/rpc-ts.git","type":"git"},"_npmVersion":"10.5.0","description":"TypeScript Remote-procedure-call Framework","directories":{},"_nodeVersion":"20.12.2","dependencies":{"ws":"^8.13.0","fp-ts":"^2.16.0","io-ts":"^2.2.20","isomorphic-ws":"^5.0.0"},"_hasShrinkwrap":false,"devDependencies":{"chai":"^4.3.7","mocha":"^10.2.0","@types/ws":"^8.5.5","typescript":"^5.3.3","@types/chai":"^4.3.5","@types/mocha":"^10.0.1"},"_npmOperationalInternal":{"tmp":"tmp/rpc-with-types_4.0.0_1716633085852_0.8786304615977778","host":"s3://npm-registry-packages"}},"4.0.1":{"name":"rpc-with-types","version":"4.0.1","keywords":["rpc","typescript","websockets","ws","framework"],"license":"MIT","_id":"rpc-with-types@4.0.1","maintainers":[{"name":"hashelq","email":"suramaru0@gmail.com"}],"homepage":"https://github.com/hashelq/rpc-ts#readme","bugs":{"url":"https://github.com/hashelq/rpc-ts/issues"},"dist":{"shasum":"6e6e14ea9890c1ee2fbde38d3cbe60907f619d30","tarball":"https://registry.npmjs.org/rpc-with-types/-/rpc-with-types-4.0.1.tgz","fileCount":23,"integrity":"sha512-zehhbBmPdzRy2fVM47mj5SG7Y06j1X+Ge9wjfiEVFuIF/USRNsvRcarVY+gRQ4eHIkhQWJ831VoUcG/II5FF/w==","signatures":[{"sig":"MEUCIQCHuoacvHk16Gh58ojLDkmv7g8sSHihEM9NMPKRztB/TAIgTQLKUhdm6akrAOuIN3UGEDL1oBcmpM8ym5b4goTHyhw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":32680},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","gitHead":"bf495a48b066cff1b15bfc6fe5eaa5c966d3db75","scripts":{"test":"tsc --esModuleInterop && mocha ./dist/tests.js","build":"tsc --esModuleInterop","do-publish":"npm run build && npm publish"},"_npmUser":{"name":"hashelq","email":"suramaru0@gmail.com"},"repository":{"url":"git+https://github.com/hashelq/rpc-ts.git","type":"git"},"_npmVersion":"10.5.0","description":"TypeScript Remote-procedure-call Framework","directories":{},"_nodeVersion":"20.12.2","dependencies":{"ws":"^8.13.0","fp-ts":"^2.16.0","io-ts":"^2.2.20","isomorphic-ws":"^5.0.0"},"_hasShrinkwrap":false,"devDependencies":{"chai":"^4.3.7","mocha":"^10.2.0","@types/ws":"^8.5.5","typescript":"^5.3.3","@types/chai":"^4.3.5","@types/mocha":"^10.0.1"},"_npmOperationalInternal":{"tmp":"tmp/rpc-with-types_4.0.1_1720066105689_0.530594126101074","host":"s3://npm-registry-packages"}},"4.0.2":{"name":"rpc-with-types","version":"4.0.2","keywords":["rpc","typescript","websockets","ws","framework"],"license":"MIT","_id":"rpc-with-types@4.0.2","maintainers":[{"name":"hashelq","email":"suramaru0@gmail.com"}],"homepage":"https://github.com/hashelq/rpc-ts#readme","bugs":{"url":"https://github.com/hashelq/rpc-ts/issues"},"dist":{"shasum":"f2f4bec014e707d02febbfcf67661bcee4e35acd","tarball":"https://registry.npmjs.org/rpc-with-types/-/rpc-with-types-4.0.2.tgz","fileCount":23,"integrity":"sha512-FCdD8LxevjvP9TdGpRmQbkVkk4tE1kvWklKdfjdb9ZOzW5UzNK+23ae1lbAfRQjWEfL5Z3MoIyR3Z2Kf6Fcg6g==","signatures":[{"sig":"MEUCIHJIQx/VtevaHW6NvZbJ+GEFnU7NmtdsjzPdojJB4bAYAiEA/L/3dqBEtWKdCaNlCF1h+99y2WPRCzq3ARgb6PL3Fhw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":32568},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","gitHead":"2555f6408699ddf46eebe52e1149f7c2e1139e68","scripts":{"test":"tsc --esModuleInterop && mocha ./dist/tests.js","build":"tsc --esModuleInterop","do-publish":"npm run build && npm publish"},"_npmUser":{"name":"hashelq","email":"suramaru0@gmail.com"},"repository":{"url":"git+https://github.com/hashelq/rpc-ts.git","type":"git"},"_npmVersion":"10.5.0","description":"TypeScript Remote-procedure-call Framework","directories":{},"_nodeVersion":"20.12.2","dependencies":{"ws":"^8.13.0","fp-ts":"^2.16.0","io-ts":"^2.2.20","isomorphic-ws":"^5.0.0"},"_hasShrinkwrap":false,"devDependencies":{"chai":"^4.3.7","mocha":"^10.2.0","@types/ws":"^8.5.5","typescript":"^5.3.3","@types/chai":"^4.3.5","@types/mocha":"^10.0.1"},"_npmOperationalInternal":{"tmp":"tmp/rpc-with-types_4.0.2_1720221015290_0.07570847365041677","host":"s3://npm-registry-packages"}},"4.0.3":{"name":"rpc-with-types","type":"module","license":"MIT","repository":{"type":"git","url":"git+https://github.com/hashelq/rpc-ts.git"},"description":"TypeScript Remote-procedure-call Framework","version":"4.0.3","keywords":["rpc","typescript","websockets","ws","framework"],"main":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"tsc --esModuleInterop","do-publish":"npm run build && npm publish","test":"tsc --esModuleInterop && mocha ./dist/tests.js"},"dependencies":{"fp-ts":"^2.16.0","io-ts":"^2.2.20","isomorphic-ws":"^5.0.0","ws":"^8.13.0"},"devDependencies":{"@types/ws":"^8.5.5","@types/chai":"^4.3.5","@types/mocha":"^10.0.1","chai":"^4.3.7","mocha":"^10.2.0","typescript":"^5.3.3"},"_id":"rpc-with-types@4.0.3","gitHead":"095a0c191c3edd80e003435eda0529345a06498c","bugs":{"url":"https://github.com/hashelq/rpc-ts/issues"},"homepage":"https://github.com/hashelq/rpc-ts#readme","_nodeVersion":"20.17.0","_npmVersion":"10.8.2","dist":{"integrity":"sha512-qa3Ky3tMQ50ybgpFc44pQ7XZPXpAj9c7HLFcHpjp2yXhsvXuDCndMuDPZvoxVsjCs3CRrfnmDI/7O39uV9sGKQ==","shasum":"c41373880b5537917347a1a91dc0c101371d675f","tarball":"https://registry.npmjs.org/rpc-with-types/-/rpc-with-types-4.0.3.tgz","fileCount":23,"unpackedSize":32680,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCDoclLTdUUA/i6xMX9RBld8LOCqnsYG3WGQXVXyYTAhwIgSs6iUgumu5kho5ggDiq8+yEz34hRMrTInkdHJdiyjPg="}]},"_npmUser":{"name":"hashelq","email":"suramaru0@gmail.com"},"directories":{},"maintainers":[{"name":"hashelq","email":"suramaru0@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rpc-with-types_4.0.3_1729400116692_0.03014547869627915"},"_hasShrinkwrap":false}},"time":{"created":"2024-05-25T10:31:25.851Z","modified":"2024-10-20T04:55:17.044Z","1.0.0":"2023-06-17T10:05:00.479Z","1.0.1":"2023-06-17T10:07:59.882Z","1.0.2":"2023-06-17T10:09:27.302Z","1.0.3":"2023-06-18T02:35:49.465Z","1.0.4":"2023-06-18T02:39:17.506Z","1.0.6":"2023-09-18T11:17:20.438Z","1.0.7":"2023-09-20T09:39:47.829Z","1.0.8":"2023-09-22T04:48:14.205Z","1.1.0":"2023-10-19T16:01:23.531Z","1.1.1":"2023-10-19T16:07:02.576Z","1.1.2":"2023-10-19T16:31:16.003Z","1.1.3":"2023-10-26T02:40:45.528Z","1.1.4":"2023-10-26T02:42:41.902Z","1.1.5":"2023-10-26T04:07:58.720Z","1.1.6":"2023-10-26T04:11:08.027Z","1.2.0":"2023-10-28T05:16:36.064Z","2.0.0":"2023-10-28T05:49:27.174Z","2.0.1":"2023-10-28T05:53:47.517Z","2.0.2":"2023-10-28T05:58:48.611Z","2.0.3":"2023-10-28T06:04:34.023Z","3.0.0":"2023-11-01T11:21:53.143Z","3.0.1":"2023-11-13T05:51:30.275Z","3.0.2":"2023-11-13T06:12:48.131Z","3.0.3":"2024-01-12T10:22:15.678Z","4.0.0":"2024-05-25T10:31:26.037Z","4.0.1":"2024-07-04T04:08:25.836Z","4.0.2":"2024-07-05T23:10:15.436Z","4.0.3":"2024-10-20T04:55:16.882Z"},"bugs":{"url":"https://github.com/hashelq/rpc-ts/issues"},"license":"MIT","homepage":"https://github.com/hashelq/rpc-ts#readme","keywords":["rpc","typescript","websockets","ws","framework"],"repository":{"type":"git","url":"git+https://github.com/hashelq/rpc-ts.git"},"description":"TypeScript Remote-procedure-call Framework","maintainers":[{"name":"hashelq","email":"suramaru0@gmail.com"}],"readme":"# rpc-with-types\nAn experimental library that implements a bidirectional Method+Event protocol for your homogenous Typescript code.\n\nHere is a short example how it works:\n```typescript\n// { server, client }\n\n// Define a Method and an Event\nconst FindUser = Method.new(\"GetUser\", t.string, t.type({ name: t.string, age: t.number }));\nconst NewUser = Event.new(\"NewUser\", t.string);\n\n// Implement a Method on the Server\nserver.onMethod(FindUser, name => { name: \"Alice\", age: 80000 });\nserver.onEvent(NewUser, name => console.log(`New user: ${name}`));\n\n// Call it from the Client\nconst { name, age } = await (new FindUser(\"Alice\").with(client));\nnew NewUser(\"Hashelq\").with(client)\n```\n\nWhat is interesting, that everything you have just seen can also be used backwards!\n```typescript\nclient.onMethod(FindUser, name => { name: \"???\", age: -1 });\nclient.onEvent(NewUser, name => console.log(`New user: ${name}`));\n\nconst { name, age } = await (new FindUser(\"Alice\").withs(server, server.clients[0]));\nnew NewUser(\"HashElq\").withs(client, server.clients[0]);\n```\n\n### Too complicated\n`src/tests.ts` - is a great source of finding ways to create a websocket RPC environment.\n\n### How it works\nA human readable JSON text is sent between the server and client sides.\n\nDefault protocol to use is `WS`.\nIn fact you can implement any protocol you want to use with the lib.\n\n### Compatibility\n`rpc-with-types` is tested against:\n* nodejs 20.11.0\n* bun 1.0.26\n\n### Sessions\n```typescript\ninterface Session {\n  lastMessage: string\n};\n\nconst server = new Server<Session>({ sessionInit: () => { lastMessage: \"\" } /* other params */});\n\nserver.onEvent(..., (message: string, { _socket, session } => {\n  session.lastMessage = message;\n}))\n```\n\n### Links to understand how to deal with it\n* [Runtime type system for IO decoding/encoding ](https://gcanti.github.io/io-ts/)\n* [io-ts github page](https://github.com/gcanti/io-ts/)\n* [test.ts](https://github.com/hashelq/rpc-ts/blob/master/src/tests.ts)\n","readmeFilename":"README.md"}