delvedor/find-my-way

[proposal] Add MQTT PubSub

nvandamme opened this issue · 2 comments

Hi,

find-my-way is clearly focused on handling HTTP verbs, but under the hood, it has all requirements for MQTT PubSub or WebSocket routing.

Is it possible to overload HTTPMethods and req/resp in handlers to support Mqtt routing based on topics path ?
The main use case is to route MQTT message on subscribed topics.

For example:

import Router from "find-my-way";
import * as mqtt from "mqtt";

router = Router();

router.on("MESSAGE", "device/:deviceId/telemetry", (client, topic, message, params) => {
// handle message and topic params
}

client =  mqtt.connect("mqtt://localhost:1833");
client.on("message", (topic: string, message: Buffer | string) => {
  router.lookup(client, topic, message);
};

I would recommend you to check out https://npm.im/mqemitter. I worked a lot on the topic and I would say this is really out of topic for FMW

Ok thanks, interesting project but it doesn't handle regexp dynamic params extraction, hence my proposal.