Creating a package that makes REST API calls - make an object, or Meteor methods?

If I were to write a package that does API calls to some service, is it better to do it via objects:

var someService = new SomeService();

try {
  someService.authorize(token, secret);
} catch (e) { ... }
someService.updateRecord(recordId, data);

Or via Meteor methods:

Meteor.call('authorize', {token: token2, secret: mySecret}, function (error, result) {
  ...
});

Methods should only be used if you want people to be able to make these calls directly from the client. I think it should be up to the app developer whether they want to use this API from the server only or from the client as well, so I would ship it as a plain object and let the app developer make methods as needed if things need to be called from the client.

1 Like