Permalink
Browse files

Update JSDoc.

  • Loading branch information...
1 parent 471b076 commit d79e0b1c9c28dda72db790a133658a26a9eba708 @jaredhanson committed Jan 29, 2016
Showing with 41 additions and 54 deletions.
  1. +1 −0 .gitignore
  2. +6 −10 lib/errors/apierror.js
  3. +3 −9 lib/index.js
  4. +3 −3 lib/profile.js
  5. +28 −32 lib/strategy.js
View
@@ -1,3 +1,4 @@
+docs/
reports/
# Mac OS X
@@ -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);
@@ -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;
View
@@ -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;
View
@@ -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) {
View
@@ -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');
@@ -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.
*
@@ -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 || {};
@@ -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
@@ -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) {
@@ -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;
@@ -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 = {};
@@ -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;
@@ -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.