{"id":15493833,"url":"https://github.com/seriousme/opifex","last_synced_at":"2026-03-16T22:32:47.976Z","repository":{"id":61106296,"uuid":"490802293","full_name":"seriousme/opifex","owner":"seriousme","description":"MQTT Server and Client on Deno, NodeJS and Bun","archived":false,"fork":false,"pushed_at":"2025-04-22T17:53:53.000Z","size":484,"stargazers_count":21,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-22T20:16:51.871Z","etag":null,"topics":["bun","deno","mqtt","mqtt-broker","nodejs","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/seriousme.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-05-10T17:44:12.000Z","updated_at":"2025-04-22T17:53:41.000Z","dependencies_parsed_at":"2024-06-27T20:38:42.761Z","dependency_job_id":"d81b0fc1-1335-44a3-9a43-bcd3adf78c72","html_url":"https://github.com/seriousme/opifex","commit_stats":{"total_commits":40,"total_committers":1,"mean_commits":40.0,"dds":0.0,"last_synced_commit":"969077c25043cba84683d7c408bbf6308e964014"},"previous_names":[],"tags_count":36,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seriousme%2Fopifex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seriousme%2Fopifex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seriousme%2Fopifex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seriousme%2Fopifex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/seriousme","download_url":"https://codeload.github.com/seriousme/opifex/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250316068,"owners_count":21410476,"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":["bun","deno","mqtt","mqtt-broker","nodejs","typescript"],"created_at":"2024-10-02T08:09:37.244Z","updated_at":"2026-03-16T22:32:47.971Z","avatar_url":"https://github.com/seriousme.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Nodejs CI](https://github.com/seriousme/opifex/actions/workflows/nodejs-ci.yml/badge.svg)](https://github.com/seriousme/opifex/actions/workflows/nodejs-ci.yml)\n[![Deno CI](https://github.com/seriousme/opifex/actions/workflows/deno-ci.yml/badge.svg)](https://github.com/seriousme/opifex/actions/workflows/deno-ci.yml)\n[![CodeQL](https://github.com/seriousme/opifex/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/seriousme/opifex/actions/workflows/codeql-analysis.yml)\n\n# Opifex\n\nOpifex aims to provide a MQTT server and MQTT client in Typescript to be used\nwith [NodeJS](https://nodejs.org), [Deno](https://deno.land) or\n[Bun](https://bun.sh) It has _no_ third party dependencies, it only relies on\nbuilt in modules.\n\n# Compatibility\n\nThe following MQTT versions are supported:\n\n|                | MQTT 3.1 (v3) | MQTT 3.1.1 (v4) | MQTT 5.0 (v5) |\n| -------------- | ------------- | --------------- | ------------- |\n| Packet/encoder | ✅            | ✅              | ✅            |\n| Client         | ✅            | ✅              | ✅ partially  |\n| Server         | ❌            | ✅              | ❌            |\n\nClient and server currently only have memory based persistence, but one can\nprovide its own persistence. (see [Architecture](#architecture))\n\n## Usage\n\nThe easiest way to use this project is to just use the demo server (demoServer)\nand/or the demo client (mqtt).\n\n- [NodeJS/Bun](node/README.md)\n- [Deno](deno/README.md)\n\nIf you want to change the behaviour of the server and/or the client beyond what\ncan be done with CLI options then the next step is to clone the demo server\nand/or the client scripts and modify them to your liking.\n\nIf you want to port the platform independent client and server libs to other\ntypes of transports (e.g. Unix sockets or websocketstream) then it's recommended\nto clone and modify the platform specific code in `/node` or `/deno` as well.\n\nIf you want to port the platform independent client and server libs to another\nplatform then the platform specific code in `/node` or `/deno` might serve as\ninspiration.\n\nBun (as of version 1.2) and Deno are both capable of running the NodeJS version,\nbut for historic reasons `/deno` still exists.\n\n## Example\n\nA simple server example using Deno.\n\n```typescript\nimport { MqttServer } from \"./server/mod.ts\";\n\nconst listener = Deno.listen();\nconst mqttServer = new MqttServer(mqttOptions);\nfor await (const conn of this.listener) {\n  mqttServer.serve(conn);\n}\n```\n\nA more elaborate example including client and server can be found in the\n[examples](/examples/) folder.\n\n## Architecture\n\n1. The basis of Opifex is the MQTT packet module\n   ([mqttPacket/mod.ts](mqttPacket/mod.ts)) which contains all the logic to\n   encode and decode packets.\n\n2. On top of mqttPacket sits the MQTT connection module\n   ([mqttConn/mod.ts](mqttConn/mod.ts)) module that reads packets from a\n   Readable stream and writes them to Writable stream. It will take care of\n   incomplete and/or malformed packets. mqttConn provides an async iterable that\n   can be awaited for new packets.\n\n3. On top of mqttConn live the MQTT server ([server/mod.ts](server/mod.ts)) and\n   MQTT client ([client/mod.ts](client/mod.ts)) that take care of the MQTT\n   protocol handling like requiring an authentication to be successful before\n   another type of packet will be accepted. Both follow a similar model of\n   implementation where for each packet that is received a handler is invoked\n   which then triggers the next step. Server and client are totally independent\n   of the technical implementation of the connection and only need a socketConn\n   ([socket](socket)) to be able to work.\n\n4. As the server needs to be able to serve multiple clients at the same time, it\n   maintains a context ([server/context.ts](server/context.ts)) per client to\n   keep track of its state and associated timers.\n\n5. Persistence of data is handled by a pluggable persistence module\n   ([persistence](persistence)) which currently only offers memory persistence\n   ([persistence/memory](persistence/memory)) but can be extended with database\n   backed persistence supported by third party modules.\n\n6. The demo server listens to a platform specific socket and runs the `serve()`\n   method from the server module on the platform independent streams of every\n   connection.\n\n7. The demo client opens a platform specific socket and passes the resulting\n   platform independent streams to the client module.\n\n## Exports\n\n| Export                        | Description                                             |\n| ----------------------------- | ------------------------------------------------------- |\n| @seriousme/opifex/tcpClient   | Exports a MQTT over TCP client                          |\n| @seriousme/opifex/tcpServer   | Exports a MQTT over TCP server                          |\n| @seriousme/opifex/server      | Exports a transport agnostic MQTT server                |\n| @seriousme/opifex/client      | Exports a transport agnostic MQTT client                |\n| @seriousme/opifex/persistence | Exports an Typescript interface for storage persistence |\n| @seriousme/opifex/mqttConn    | Exports MQTT connection handling                        |\n| @seriousme/opifex/mqttPacket  | Exports MQTT packet handling                            |\n| @seriousme/opifex/utils       | Exports various utilities                               |\n\n## Naming\n\nSome MQTT servers have names like:\n\n- [Mosquitto](https://en.wikipedia.org/wiki/Mosquito)\n- [Mosca](https://it.wikipedia.org/wiki/Musca_domestica)\n- [Aedes](https://en.wikipedia.org/wiki/Aedes)\n\nSo to stay with the theme: [Opifex](https://en.wikipedia.org/wiki/Opifex_(fly))\n\n# License\n\nLicensed under [MIT](LICENSE.txt)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseriousme%2Fopifex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fseriousme%2Fopifex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseriousme%2Fopifex/lists"}