{"id":22396080,"url":"https://github.com/hoehrmann/node-jipe","last_synced_at":"2025-07-27T18:05:01.588Z","repository":{"id":65460716,"uuid":"181779888","full_name":"hoehrmann/node-jipe","owner":"hoehrmann","description":"Process composition via JSON-RPC pipes","archived":false,"fork":false,"pushed_at":"2019-04-26T18:13:54.000Z","size":35,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-25T19:02:34.829Z","etag":null,"topics":["json-rpc","typescript-library"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hoehrmann.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-04-16T23:01:31.000Z","updated_at":"2019-04-26T18:13:49.000Z","dependencies_parsed_at":"2023-01-24T15:05:13.503Z","dependency_job_id":null,"html_url":"https://github.com/hoehrmann/node-jipe","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hoehrmann%2Fnode-jipe","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hoehrmann%2Fnode-jipe/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hoehrmann%2Fnode-jipe/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hoehrmann%2Fnode-jipe/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hoehrmann","download_url":"https://codeload.github.com/hoehrmann/node-jipe/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245749907,"owners_count":20666086,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["json-rpc","typescript-library"],"created_at":"2024-12-05T06:06:54.650Z","updated_at":"2025-03-26T23:13:55.803Z","avatar_url":"https://github.com/hoehrmann.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# node-jipe - Process composition via JSON-RPC pipes\n\nWhen you enter `cat file | sort | uniq -c | sort -rn | head -n10` in\nyour terminal, your shell will spawn the listed processes; they talk\nover stdio streams in an unidirectional and unstructured pipeline\nwith their neighbours. This package helps you do something like that,\nbut asynchronously, bidirectionally, and with structured data.\n\nThere is a library that implements JSON-RPC 2.0 helping you write\ntools like those in the initial example, and a command line tool\ncalled `jipe` that spawns such processes and routes requests to a\nprocess that announced they can handle such requests.\n\n## JSON-RPC 2.0 library\n\n```typescript\nimport { Channel, api, jipe } from 'node-jipe';\n\n/**\n * Type class for JSON-RPC 2.0 request `ping`.\n */\nexport class ping implements api.Definition {\n  method = 'ping';\n  params: any;\n  result: any;\n}\n\nasync function main() {\n\n  const channel = new Channel(process.stdin, process.stdout);\n\n  // manually do `jipe.start`\n  const available = await channel.requestResult(jipe.start, {\n    implements: []\n  });\n\n  // Could check here that available.implements has `request.ping`\n\n  const result = await channel.requestResult(ping, {\n    data: 123\n  });\n\n}\n\nmain();\n```\n\n```typescript\n\n/**\n * Feature map mapping method names to api.Definition.\n */\nclass Features {\n  ping = ping\n}\n\nclass Pingme\n// provides `start` method that does `jipe.start`\nextends api.Jipe\u003cFeatures\u003e\n// requires proper implementation of the Features\nimplements api.Interface\u003cFeatures\u003e {\n\n  async ping(params: api.Params\u003cping\u003e): api.Promised\u003cping\u003e {\n    // echo back parameters\n    return params;\n  }\n\n}\n\nasync function main() {\n  const us = new Pingme();\n\n  // This automatically does `jipe.start` announcing the Features\n  await us.start(new Features(), process.stdin, process.stdout);\n}\n\n```\n\nDocumentation of the library is available via something like:\n\n```bash\n% git clone https://github.com/hoehrmann/node-jipe.git\n% cd node-jipe\n% npm install -g yarn\n% NODE_ENV=development yarn\n% node_modules/.bin/typedoc --out docs  ./src/\n% sensible-browser docs/index.html\n```\n\n## jipe\n\n```plaintext\n---------------------------------------------------------------------\n  jipe - stdio ndjson jsonrpc process composition\n---------------------------------------------------------------------\n\n  Jipe allows you compose an implementation of a JSON-RPC 2.0 API\n  from multiple independent processes. It spawns child process as\n  specified on the command line and expects them to communicate\n  with newline-delimited messages on their STDIN/STDOUT streams.\n\n  In order for `jipe` to know where requests and notifications\n  should be sent, child processes initially have to send a request\n  for method `jipe.start` to `jipe` with `params.implements`\n  set to an array of method names prefixed by `notification.` or\n  `request.`. When all children have made such a request, `jipe`\n  will send a result to all children with `params.implements` set\n  to the union of all values it received, allowing children to\n  complain when methods they need are missing.\n\n  EXAMPLE:\n\n    % jipe -- pinger -- pingme\n\n  Here `jipe` will spawn `pinger` and `pingme` which are then\n  expected to send a `jipe.start` request:\n\n    pingme stdout: { \"jsonrpc\" : \"2.0\",\n                     \"id\"      : 1,\n                     \"method\"  : \"jipe.start\",\n                     \"params\"  : {\"implements\":[\"request.ping\"]} }\n\n    pinger stdout: { \"jsonrpc\" : \"2.0\",\n                     \"id\"      : 1,\n                     \"method\"  : \"jipe.start\",\n                     \"params\"  : {\"implements\":[]} }\n\n  Now that all processes have signaled they are ready, `jipe` will\n  send the union of all reported `implements` values as result:\n\n    pingme stdin:  { \"jsonrpc\" : \"2.0\",\n                     \"id\"      : 1,\n                     \"method\"  : \"jipe.start\",\n                     \"params\"  : {\"implements\":[\"request.ping\"]} }\n\n    pinger stdin:  { \"jsonrpc\" : \"2.0\",\n                     \"id\"      : 1,\n                     \"method\"  : \"jipe.start\",\n                     \"params\"  : {\"implements\":[\"request.ping\"]} }\n\n  And then `pinger` can send a `ping` request to `jipe`:\n\n    pinger stdout: { \"jsonrpc\" : \"2.0\",\n                     \"id\"      : 2,\n                     \"method\"  : \"ping\",\n                     \"params\"  : {\"value\": 123} }\n\n  Which `jipe` will then route to `pingme`:\n\n    pingme stdin:  { \"jsonrpc\" : \"2.0\",\n                     \"id\"      : 1,\n                     \"method\"  : \"ping\",\n                     \"params\"  : {} }\n\n  Which could then respond by echoing the params back:\n\n    pingme stdout: { \"jsonrpc\" : \"2.0\",\n                     \"id\"      : 1,\n                     \"params\"  : {\"value\": 123} }\n\n  And `jipe` will forward the result to `pinger`:\n\n    pinger stdin:  { \"jsonrpc\" : \"2.0\",\n                     \"id\"      : 2,\n                     \"params\"  : {\"value\": 123} }\n\n  Note that `jipe` does not blindly forward messages literally,\n  it takes care to create new requests with appropriate `id`s.\n\n---------------------------------------------------------------------\n  https://github.com/hoehrmann/node-jipe/\n---------------------------------------------------------------------\n  Copyright (c) 2019 Bjoern Hoehrmann, https://bjoern.hoehrmann.de/\n---------------------------------------------------------------------\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhoehrmann%2Fnode-jipe","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhoehrmann%2Fnode-jipe","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhoehrmann%2Fnode-jipe/lists"}