Skip to content

Clear up makeRequest_ naming conventions #847

@stephenplusplus

Description

@stephenplusplus

We follow a few different patterns throughout the codebase, so I think we should try to sync up.

In some constructors, you might find this.makeRequest_ = storage.bucket.makeRequest.bind(storage.bucket). In other places, we define a makeRequest_ on the prototype. (props to @callmehiphop for first calling us out on this).

We should also clear up the naming conventions around making requests. Currently:

function Class() {
  this.makeAuthorizedRequest_ = util.makeAuthenticatedRequestFactory();
}

Class.prototype.makeReq_ = function(method, path, qs, body, callback) {
  var reqOpts = {
    method: method,
    uri: path,
    // ...
  };

  this.makeAuthorizedRequest_(reqOpts);
};

I think we should go through and have only one style; Class.prototype.request instead of constructor-initialized functions.

function Class() {
  this.authClient = util.getAuthClient();
}

Class.prototype.request = function(reqOpts, callback) {
  util.request(this.authClient, reqOpts, callback);
};

It should make it easier to follow along with, and it should be possible.

Also note using (reqOpts, callback) over (method, path, query, body, callback). It's pretty non-JS to have multiple arguments. We should just use the standard request options format, with reqOpts.uri, reqOpts.method, reqOpts.qs, reqOpts.json, etc.

LMKWYT!

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions