How can I can catch data between client and server?

I’m trying to understand DDP protocol that meteor uses
I use Meteor Methods to send data from client to server, and I have many methods

I wish to know if there is a way to have in the main.js of server some sort of function that display the transmitted data before it arrives to server Method

for example

Client calls a method ( any method from anywhere ) → I catch the data before it arrives to server Meteor Method and apply some kind of work on it like sanitizing the data entered to prevent XSS → data continues to Method Method

This way i will have one place to receive every argument sent from any method and I will sanitize it and and the data just continues to find its way to that specific method in a cleaner form

I could do this per method and do all the work on the arguments per method but i thought one place for such work like sanitizing the data would be better

My primary choice in a situation like this would be to use the basic building block of js itself - put the sanitizing code into a separate function and just import and run it in every method you have. The code will be readable and easy to understand to any new developer thst might join the project in the future.

As an alternative you might consider validated methods with its mixins or maybe even zodern’s new tool zodern:relay if the issue can be mitigated with just types and schemas. Have not used either of these.

Hooking straight into Meteor’s internals by trying to catch arguments before they reach methods seems like a rather fragile setup. Unless you do it just to get to know Meteor better :slight_smile:

I agreed with @vooteles. I know another package you may want to use: GitHub - Meteor-Community-Packages/meteor-method-hooks