Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Namespace methods per package #48

Open
dandv opened this issue Dec 19, 2014 · 2 comments
Open

Namespace methods per package #48

dandv opened this issue Dec 19, 2014 · 2 comments

Comments

@dandv
Copy link
Member

dandv commented Dec 19, 2014

SO question, zero replies after one week.

I'm writing a package that exposes a few Meteor.methods. Is there a smarter way to namespace them to the package than hardcoding their names like this?

Meteor.methods({
  'my:package/methodName': function ...
})

A way to figure out the name of a package from inside its JavaScript files would be a good start.

@mitar
Copy link

mitar commented Dec 19, 2014

This could be made as a wrapper package, which would internally use Meteor.methods, but otherwise expose richer API. I was thinking of making a package for this, where you would do something like:

BetterMethods.register 'name', 'documentation', argsSpecification, (arg1, arg2, arg3) ->
   ...

The idea is that it handles both namespacing, argument checking, and documentation. So argsSpecification would automatically check all arguments, but also make sure that automatically generated documentation for the method would have nice table of arguments with descriptions. So documentation would then be:

  • package of the method
  • name of the method
  • block of documentation
  • for each argument, name of it, and type, and documentation

We could even document if it is blocking or not (does it call .unblock), but I am not sure how to do this automatically.

A similar wrapper I made for publish functions already: https://github.com/peerlibrary/meteor-middleware (There is additional feature of being able to stack them.) (Documentation feature is not yet implemented.)

@raix
Copy link
Contributor

raix commented Dec 19, 2014

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants