Skip to content

Commit

Permalink
adding more module docs
Browse files Browse the repository at this point in the history
  • Loading branch information
esatterwhite committed Dec 27, 2016
1 parent 242e359 commit dd7429d
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
21 changes: 21 additions & 0 deletions lib/server/api/middleware/proxy.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,31 @@
'use strict';
/*jshint laxcomma: true, smarttabs: true, esnext: true, node: true*/
/**
* Middleware that determines if the current server should handle the request, and will proxy
* it to the appropriate node if it isn't
* @module skyring/lib/server/api/middleware/proxy
* @author Eric Satterwhite
* @since 1.0.0
* @requires uid
* @requires body
* @requires debug
* @requires skyring/lib/json
*/

const uuid = require('uuid')
, body = require('body')
, debug = require('debug')('skyring:proxy')
, json = require('../../../json')
;

/**
 * @function
* @alias module:skyring/lib/server/api/middleware/proxy
 * @param {http.IncommingMessage} req
 * @param {http.ServerResponse} res
* @param {module:skyring/lib/server/node} node
* @param {Function} next
 **/
module.exports = function proxy(req, res, node, cb) {
const timer_id = req.$.headers['x-timer-id'] || uuid.v4()
req.headers['x-timer-id'] = timer_id
Expand Down
15 changes: 15 additions & 0 deletions lib/server/api/middleware/timer_id.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
'use strict';
/*jshint laxcomma: true, smarttabs: true, esnext: true, node: true*/
/**
* Middleware function the assigns the timer id to the customer header in the event it has been proxied
* @module skyring/lib/server/api/middleware/timer_id
* @author Eric Satterwhite
* @since 1.0.0
*/

/**
 * @function
* @alias module:skyring/lib/server/api/middleware/timer_id
 * @param {http.IncommingMessage} req
 * @param {http.ServerResponse} res
* @param {module:skyring/lib/server/node} node
* @param {Function} next
 **/
module.exports = function timer_id(req, res, node, next){
req.headers['x-timer-id'] = req.$.params.timer_id;
next();
Expand Down

0 comments on commit dd7429d

Please sign in to comment.