meteor / validated-method

Meteor methods with better scoping, argument checking, and good defaults.
https://atmospherejs.com/mdg/validated-method
MIT License
194 stars 28 forks source link

Allow defining methods on non-default servers/connections #1

Closed glasser closed 8 years ago

glasser commented 8 years ago

It would be nice if there was an option to make this call .methods on a connection or server object other than Meteor.connection/Meteor.server.

stubailo commented 8 years ago

Would that look like an option to the constructor called connection? Would the option need to be passed differently on client and server?

I agree this is a very valid concern, should be addressed in the next revision.

glasser commented 8 years ago

Yeah. connection isn't necessarily the best name since it can be either a server or a client, but that's what the Mongo.Collection constructor calls it.

stubailo commented 8 years ago

Done: https://github.com/meteor/validated-method#defining-a-method-on-a-non-default-connection

If a lot of people run into this issue, we can document it more thoroughly.

brucejo75 commented 8 years ago

Hello, I am trying to figure out how to make this work.

If I pass in Meteor to both server and client side then it seems to work.

If I pass in a Connection object (e.g. Meteor.connection or the result of a DDP.connect) it fails this call because of this line with this error:

Uncaught Error: Match error: Expected plain object in field connection

I tried just running a check on any Connection object and it fails like above.

Did this ever work? I had used ValidatedMethod objects for all my methods, now I am trying to add other client side apps connecting to the same server.

Any help?

brucejo75 commented 8 years ago

Hi @stubailo, I cloned the package and commented out this line. And now it is working.

Maybe there is a way to check the connection parameter separately? It is not passing the object test, because it has a constructor?