Closed Nisthar closed 2 years ago
Made it optional as enforcing that for custom handlers makes no sense 😄
Made it optional as enforcing that for custom handlers makes no sense 😄
also when sending custom events, it omits all the other data. It would be nice if you could keep the custom data for custom events.
@br41nslug why am i getting Error: Invalid message type! Either get, post, patch, delete or subscribe expected
? can't i pass custom type?
@ Hmmm seems i've not documented that properly. It is expecting your handler's It is expecting your handler to have the parseMessage
function to return a non-false result to pass the the onMessageHandler
onMessage
function because if not it will mark the incoming message as "unhandled" and throw that error 😓
https://github.com/br41nslug/directus-websocket-subscribe/blob/e8df409dd190e579400ae94451165ef46dce9f60/src/server.ts#L78
I think the whole message handling might be due a bit of a refactor considering proper extensibility
I had some false value in my handler. Its working fine now.
sorry i realized my mistake and updated my message @Nisthar
I do see there's very much room for improvement here so any PRs/issues/discussions after playing around with it will be appreciated 😄
It checks for a collection key for custom handlers. I think this is the code that throws the error
https://github.com/br41nslug/directus-websocket-subscribe/blob/623db0cfe560380b6454e8f54e3a9c9535cd7b34/src/util.ts#L16
Maybe give priority to custom handlers might fix it. But i am not sure.