{"id":19066492,"url":"https://github.com/geut/nanomessage","last_synced_at":"2025-10-09T15:44:41.639Z","repository":{"id":57307988,"uuid":"218331335","full_name":"geut/nanomessage","owner":"geut","description":"Simple module that helps you to build a `request-response` abstraction on top of any other solution.","archived":false,"fork":false,"pushed_at":"2022-10-22T23:01:35.000Z","size":785,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-10-09T15:44:41.472Z","etag":null,"topics":["eventemitter","messages","request-response","rpc","socket","streams","websocket"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/geut.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-10-29T16:20:05.000Z","updated_at":"2023-08-22T18:40:05.000Z","dependencies_parsed_at":"2022-09-12T11:44:14.614Z","dependency_job_id":null,"html_url":"https://github.com/geut/nanomessage","commit_stats":null,"previous_names":[],"tags_count":41,"template":false,"template_full_name":null,"purl":"pkg:github/geut/nanomessage","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geut%2Fnanomessage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geut%2Fnanomessage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geut%2Fnanomessage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geut%2Fnanomessage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/geut","download_url":"https://codeload.github.com/geut/nanomessage/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geut%2Fnanomessage/sbom","scorecard":{"id":424811,"data":{"date":"2025-08-11","repo":{"name":"github.com/geut/nanomessage","commit":"469fd843214a53d0d4831d3b42af8d981958995e"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.4,"checks":[{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/geut/nanomessage/test.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/geut/nanomessage/test.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/geut/nanomessage/test.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:24: update your workflow using https://app.stepsecurity.io/secureworkflow/geut/nanomessage/test.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/test.yml:31: update your workflow using https://app.stepsecurity.io/secureworkflow/geut/nanomessage/test.yml/main?enable=pin","Warn: npmCommand not pinned by hash: .github/workflows/test.yml:18","Warn: npmCommand not pinned by hash: .github/workflows/test.yml:28","Info:   0 out of   4 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 third-party GitHubAction dependencies pinned","Info:   0 out of   2 npmCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/test.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-19T02:00:30.720Z","repository_id":57307988,"created_at":"2025-08-19T02:00:30.720Z","updated_at":"2025-08-19T02:00:30.720Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279001648,"owners_count":26083147,"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","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["eventemitter","messages","request-response","rpc","socket","streams","websocket"],"created_at":"2024-11-09T00:57:03.586Z","updated_at":"2025-10-09T15:44:41.592Z","avatar_url":"https://github.com/geut.png","language":"JavaScript","readme":"# nanomessage (aka nm)\n\n![Test Status](https://github.com/geut/nanomessage/actions/workflows/test.yml/badge.svg)\n[![Coverage](https://raw.githubusercontent.com/geut/nanomessage/gh-pages/badges/coverage.svg?raw=true)](https://geut.github.io/nanomessage/)\n[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)\n[![standard-readme compliant](https://img.shields.io/badge/readme%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)\n\n\u003e Simple module that helps you to build a `request-response` abstraction on top of any other solution (e.g. streams).\n\n## \u003ca name=\"install\"\u003e\u003c/a\u003e Install\n\n```\n$ npm install nanomessage\n```\n\n## \u003ca name=\"usage\"\u003e\u003c/a\u003e Usage\n\n```javascript\nimport WebSocket from 'ws'\n\nimport { Nanomessage } from 'nanomessage'\n\n// server.js\nconst server = new WebSocket.Server({ port: 3000 })\nserver.on('connection', function connection (ws) {\n  const nm = new Nanomessage({\n    subscribe (ondata) {\n      // Define how to read data\n      ws.on('message', ondata)\n    },\n    send (msg) {\n      // Define how to send data\n      ws.send(msg)\n    },\n    onMessage (msg, opts) {\n      // Process the new request and return a response\n      console.log(msg)\n      return 'pong from Alice'\n    }\n  })\n\n  nm.open().catch(err =\u003e console.error(err))\n})\n\n// client.js\nconst ws = new WebSocket('ws://127.0.0.1:3000')\nconst Bob = new Nanomessage({\n  async open() {\n    if (ws.readyState === 0) {\n      await new Promise(resolve =\u003e ws.once('open', resolve))\n    }\n  },\n  subscribe (ondata) {\n    ws.on('message', ondata)\n  },\n  send (msg) {\n    ws.send(msg)\n  }\n})\n\n;(async () =\u003e {\n  await Bob.open()\n  console.log(await Bob.request('ping from Bob'))\n})()\n```\n\n## \u003ca name=\"api\"\u003e\u003c/a\u003e API\n\n#### `const nm = new Nanomessage(options)`\n\nCreate a new nanomessage.\n\nOptions include:\n\n- `send: (chunk: Buffer, info: Object) =\u003e (Promise|undefined)`: Defines how to send the messages provide it by nanomessage to the low level solution.\n- `subscribe: (onData: buf =\u003e Promise) =\u003e UnsubscribeFunction`: Defines how to read data from the low level solution.\n- `onMessage: (msg: *, info: Object) =\u003e Promise\u003cResponse\u003e`: Async handler to process the incoming requests.\n- `open: () =\u003e Promise`: Defines a function to run before the nanomessage instance is opened.\n- `close: () =\u003e Promise`: Defines a function to run after the nanomessage instance was close.\n- `timeout: null`: Time to wait for the response of a request. Disabled by default.\n- `concurrency: { incoming: 256, outgoing: 256 }`: Defines how many requests do you want to run (outgoing) and process (incoming) in concurrent.\n- `valueEncoding: msgpackr`: Defines a [compatible codec](https://github.com/mafintosh/codecs) to encode/decode messages in nanomessage. By default use: [msgpackr](https://github.com/kriszyp/msgpackr)\n\n`info` is an object with:\n\n- `info.id: Number`: Incremental ID request.\n- `info.data: *`: Plain data to send.\n- `info.ephemeral: boolean`: It's true if the message is ephemeral.\n- `info.response: boolean`: It's true if the message is a response.\n- `info.responseData: *`: Plain data to response.\n\nYou can also extend from this prototype if you prefer:\n\n```javascript\nconst { Nanomessage } = require('nanomessage')\n\nclass CustomNanomessage exports Nanomessage {\n  constructor (...args) {\n    super(...args)\n  }\n\n  _subscribe (onData) {}\n\n  async _send (chunk, info) {}\n\n  async _onMessage (msg, info) {}\n\n  async _open() {\n    await super._open()\n  }\n\n  async _close () {\n    await super._close()\n  }\n}\n```\n\n#### `nm.requests: Array\u003cRequests\u003e`\n\nGet the current list of requests (inflight and pending).\n\n#### `nm.inflightRequests: Number`\n\nNumber of requests processing in the queue.\n\n#### `nm.requestTimeout: Number`\n\nGet the current request timeout.\n\n#### `nm.concurrency: { incoming: Number, outgoing: Number }`\n\nGet the current concurrency.\n\n#### `nm.setRequestsTimeout(Number)`\n\nChange the timeout for the future requests.\n\n#### `nm.setConcurrency(Number | { incoming: Number, outgoing: Number })`\n\nUpdate the concurrency number of operations for incoming and outgoing requests.\n\n#### `nm.open() =\u003e Promise`\n\nOpens nanomessage and start listening for incoming data.\n\n#### `nm.close() =\u003e Promise`\n\nCloses nanomessage and unsubscribe from incoming data.\n\n#### `nm.request(data, [opts]) =\u003e Promise\u003cResponse\u003e`\n\nSend a request and wait for a response. `data` can be any serializable type supported by your codec.\n\n- `opts.timeout: number`: Define a custom timeout for the current request.\n- `opts.signal: AbortSignal`: Set an abort signal object to cancel the request.\n\n#### `nm.send(data) =\u003e Promise\u003cResponse\u003e`\n\nSend a `ephemeral` message. `data` can be any serializable type supported by your codec.\n\n#### `nm.processIncomingMessage(buf: Buffer) =\u003e Promise`\n\nAccess directly to the handler of incoming messages. It's recommended to use the subscription model instead.\n\n#### `nm.setMessageHandler(handler) =\u003e Nanomessage`\n\nDefines a request handler. It will override the old handler.\n\n## \u003ca name=\"issues\"\u003e\u003c/a\u003e Issues\n\n:bug: If you found an issue we encourage you to report it on [github](https://github.com/geut/nanomessage/issues). Please specify your OS and the actions to reproduce it.\n\n## \u003ca name=\"contribute\"\u003e\u003c/a\u003e Contributing\n\n:busts_in_silhouette: Ideas and contributions to the project are welcome. You must follow this [guideline](https://github.com/geut/nanomessage/blob/main/CONTRIBUTING.md).\n\n## License\n\nMIT © A [**GEUT**](http://geutstudio.com/) project\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeut%2Fnanomessage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgeut%2Fnanomessage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeut%2Fnanomessage/lists"}