Skip to content

Commit

Permalink
Update JSDoc.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredhanson committed Jan 29, 2016
1 parent 471b076 commit d79e0b1
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 54 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
docs/
reports/

# Mac OS X
Expand Down
16 changes: 6 additions & 10 deletions lib/errors/apierror.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
* `APIError` error.
*
* References:
* - https://dev.twitter.com/docs/error-codes-responses
* - https://dev.twitter.com/overview/api/response-codes
*
* @constructor
* @param {String} [message]
* @param {Number} [code]
* @api public
* @param {string} [message]
* @param {number} [code]
* @access public
*/
function APIError(message, code) {
Error.call(this);
Expand All @@ -18,13 +18,9 @@ function APIError(message, code) {
this.status = 500;
}

/**
* Inherit from `Error`.
*/
// Inherit from `Error`.
APIError.prototype.__proto__ = Error.prototype;


/**
* Expose `APIError`.
*/
// Expose constructor.
module.exports = APIError;
12 changes: 3 additions & 9 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
/**
* Module dependencies.
*/
// Load modules.
var Strategy = require('./strategy');


/**
* Expose `Strategy` directly from package.
*/
// Expose Strategy.
exports = module.exports = Strategy;

/**
* Export constructors.
*/
// Exports.
exports.Strategy = Strategy;
6 changes: 3 additions & 3 deletions lib/profile.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/**
* Parse profile.
*
* @param {Object|String} json
* @return {Object}
* @api private
* @param {object|string} json
* @return {object}
* @api public
*/
exports.parse = function(json) {
if ('string' == typeof json) {
Expand Down
60 changes: 28 additions & 32 deletions lib/strategy.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
/**
* Module dependencies.
*/
var parse = require('./profile').parse
// Load modules.
var OAuthStrategy = require('passport-oauth1')
, util = require('util')
, uri = require('url')
, XML = require('xtraverse')
, OAuthStrategy = require('passport-oauth1')
, Profile = require('./profile')
, InternalOAuthError = require('passport-oauth1').InternalOAuthError
, APIError = require('./errors/apierror');

Expand All @@ -17,7 +15,7 @@ var parse = require('./profile').parse
* Twitter using the OAuth protocol.
*
* Applications must supply a `verify` callback which accepts a `token`,
* `tokenSecret` and service-specific `profile`, and then calls the `done`
* `tokenSecret` and service-specific `profile`, and then calls the `cb`
* callback supplying a `user`, which should be set to `false` if the
* credentials are not valid. If an exception occured, `err` should be set.
*
Expand All @@ -33,16 +31,17 @@ var parse = require('./profile').parse
* consumerSecret: 'shhh-its-a-secret'
* callbackURL: 'https://www.example.net/auth/twitter/callback'
* },
* function(token, tokenSecret, profile, done) {
* function(token, tokenSecret, profile, cb) {
* User.findOrCreate(..., function (err, user) {
* done(err, user);
* cb(err, user);
* });
* }
* ));
*
* @param {Object} options
* @param {Function} verify
* @api public
* @constructor
* @param {object} options
* @param {function} verify
* @access public
*/
function Strategy(options, verify) {
options = options || {};
Expand All @@ -60,17 +59,16 @@ function Strategy(options, verify) {
this._includeEntities = (options.includeEntities !== undefined) ? options.includeEntities : true;
}

/**
* Inherit from `OAuthStrategy`.
*/
// Inherit from `OAuthStrategy`.
util.inherits(Strategy, OAuthStrategy);


/**
* Authenticate request by delegating to Twitter using OAuth.
*
* @param {Object} req
* @api protected
* @param {http.IncomingMessage} req
* @param {object} [options]
* @access protected
*/
Strategy.prototype.authenticate = function(req, options) {
// When a user denies authorization on Twitter, they are presented with a link
Expand Down Expand Up @@ -100,13 +98,13 @@ Strategy.prototype.authenticate = function(req, options) {
* Note that because Twitter supplies basic profile information in query
* parameters when redirecting back to the application, loading of Twitter
* profiles *does not* result in an additional HTTP request, when the
* `skipExtendedUserProfile` is enabled.
* `skipExtendedUserProfile` option is enabled.
*
* @param {String} token
* @param {String} tokenSecret
* @param {Object} params
* @param {Function} done
* @api protected
* @param {string} token
* @param {string} tokenSecret
* @param {object} params
* @param {function} done
* @access protected
*/
Strategy.prototype.userProfile = function(token, tokenSecret, params, done) {
if (!this._skipExtendedUserProfile) {
Expand Down Expand Up @@ -148,7 +146,7 @@ Strategy.prototype.userProfile = function(token, tokenSecret, params, done) {
return done(new Error('Failed to parse user profile'));
}

var profile = parse(json);
var profile = Profile.parse(json);
profile.provider = 'twitter';
profile._raw = body;
profile._json = json;
Expand All @@ -172,9 +170,9 @@ Strategy.prototype.userProfile = function(token, tokenSecret, params, done) {
* Return extra Twitter-specific parameters to be included in the user
* authorization request.
*
* @param {Object} options
* @return {Object}
* @api protected
* @param {object} options
* @return {object}
* @access protected
*/
Strategy.prototype.userAuthorizationParams = function(options) {
var params = {};
Expand All @@ -190,10 +188,10 @@ Strategy.prototype.userAuthorizationParams = function(options) {
/**
* Parse error response from Twitter OAuth endpoint.
*
* @param {String} body
* @param {Number} status
* @param {string} body
* @param {number} status
* @return {Error}
* @api protected
* @access protected
*/
Strategy.prototype.parseErrorResponse = function(body, status) {
var json, xml;
Expand All @@ -210,7 +208,5 @@ Strategy.prototype.parseErrorResponse = function(body, status) {
};


/**
* Expose `Strategy`.
*/
// Expose constructor.
module.exports = Strategy;

0 comments on commit d79e0b1

Please sign in to comment.