client.js 514 B

12345678910111213141516171819
  1. module.exports = function apiClient (getConnection) {
  2. // getConnection is a function that returns a promise
  3. // for the current q-connection instance to be used
  4. function apiCall (path) {
  5. var args = Array.prototype.slice.call(arguments, 1)
  6. var connection = apiCall.getConnection();
  7. console.debug("api call", path, args);
  8. return connection.then(function (connection) {
  9. return connection.connection.fcall(path, args) })
  10. }
  11. apiCall.getConnection = getConnection;
  12. return apiCall;
  13. }