Can this be simplified to use with websockets?
tamilvendhank-helptap opened this issue · 3 comments
tamilvendhank-helptap commented
Hello there,
I am wondering, if this library can be simplified to create an another library, for websocket messages routing.
If it can do something like following, it would be great!
const router = new Router();
router.on('/users/:userId/posts', handler);
function handler(urlParams, payload) {
console.log(urlParams, payload); // {userId: 12345} {...}
}
websocketServer.on('connection', function connectionHandler(connection) {
connection.on('message', function messageHandler(message) {
const messageObject = validateMessageFormat(message);
// messageObject = { url: '/users/12345/posts', payload: {...} };
router.lookup(messageObject);
});
});
mcollina commented
I think you could create such a small wrapper, but that is not in the purview of this module.
ivan-tymoshenko commented
I agree that it's shouldn't be here. Can we close it?
tamilvendhank-helptap commented
@mcollina, @ivan-tymoshenko apologies. I must have closed this on my own.
@mcollina, I took your suggestion and wrote the code. I have been using it on production for a while. Thanks for that.