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

Regex support for remote hooks declarations #340

Closed
superkhau opened this issue Aug 22, 2016 · 2 comments
Closed

Regex support for remote hooks declarations #340

superkhau opened this issue Aug 22, 2016 · 2 comments

Comments

@superkhau
Copy link
Contributor

superkhau commented Aug 22, 2016

As an end user, I would like to use regular expressions to match multiple remote methods.

For example:

module.exports = function(Payment) {
  Payment.helloRemote = function(msg, cb) {
    cb(null, 'hello');
  };
  Payment.remoteMethod('helloRemote', {
    accepts: {arg: 'msg', type: 'string'},
    returns: {arg: 'greeting', type: 'string'}
  });

  Payment.worldRemote = function(msg, cb) {
    cb(null, 'world');
  };
  Payment.remoteMethod('worldRemote', {
    accepts: {arg: 'msg', type: 'string'},
    returns: {arg: 'greeting', type: 'string'}
  });

  Payment.afterRemote('*Remote', function(ctx, user, next) {
    console.log('wildcard triggered');
    next();
  });
};

The current workaround is to use ctx.method.name to check if the remote method needs triggering:

Payment.afterRemote('*', function(ctx, user, next) {
  var ignoreList = ['helloRemote', 'worldRemote'];
  if (ignoreList.indexOf(ctx.method.name)) return next();

  // do something
  next();
});
@superkhau
Copy link
Contributor Author

@bajtos This is probably just be a one off case for a customer request and I believe the workaround should be good enough for now. Feel free to plan accordingly as you see fit as this is probably a good feature to have in general.

@bajtos
Copy link
Member

bajtos commented Oct 11, 2018

With the release of LoopBack 4.0 GA (see the announcement), this module has entered Active LTS mode and no longer accepts new features (see our LTS policy).

@bajtos bajtos closed this as completed Oct 11, 2018
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

3 participants