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

Add availableOn[Client,Server] options #9

Closed
tarmolov opened this issue Aug 8, 2014 · 3 comments
Closed

Add availableOn[Client,Server] options #9

tarmolov opened this issue Aug 8, 2014 · 3 comments

Comments

@tarmolov
Copy link
Member

tarmolov commented Aug 8, 2014

Rename existing method:
.hideOnDocPage -> .setOption('hiddenOnDocPage', true)

Add two new options:
.setOption('availableOnClient', false);
.setOption('availableOnServer', false);

If both options availableOnClient and availableOnServer are set to false, the error should be thrown.

//cc @dodev

@dodev
Copy link
Contributor

dodev commented Aug 8, 2014

You mean, if both options are set to 'false'.
Otherwise, LGTM 👍

@tarmolov
Copy link
Member Author

tarmolov commented Aug 8, 2014

Yeap. Fixed :)

@tarmolov
Copy link
Member Author

tarmolov commented Aug 8, 2014

Final changes:

  • Delete the method hideOnDocPage(). Now you should use setOption('hiddenOnDocPage', true).
  • Add option executeOnServerOnly to prevent execution on frontend side. I picked this name because only one option has been added.

Methods with set option have a special badge:
server only badge

And the middleware returns a following error:

{
    type: "BAD_REQUEST",
    message: "Method can be executed only on server side"
}

I didn't add option executeOnClientOnly because the middleware executes all methods on the server side. If I set executeOnClientOnly option to true for a method, the middleware cannot execute this method. Of course I could add a special option to api.exec method but it would look as a hack and I didn't like it.

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

No branches or pull requests

2 participants