Skip to content

Commit

Permalink
Refactor(main): JSdoc the functions
Browse files Browse the repository at this point in the history
  • Loading branch information
fvdm committed Aug 16, 2016
1 parent ec38a79 commit 953b88d
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@ var defaults = {
timeout: 5000
};


/**
* Call back an error
*
* @callback callback
* @param msg {string} - Error.message
* @param err {mixed} - Error.error
* @param res {object, null} - Client response
* @param callback {function} - `function (err) {}`
* @return {void}
*/

function doError (msg, err, res, callback) {
var error = new Error (msg);

Expand All @@ -23,6 +35,14 @@ function doError (msg, err, res, callback) {
callback (error);
}


/**
* Translate nested params to string
*
* @param obj {mixed} - Object to process
* @return {string} - Querystring
*/

function fixParams (obj) {
var key;
var nw = [];
Expand All @@ -48,7 +68,31 @@ function fixParams (obj) {
}


/**
* Setup
*
* @param config {object}
* @param config.apikey {string} - API key
* @param config.dataset {string} - API dataset
* @param [config.timeout = 5000] {number} - Request timeout in ms
* @return {function}
*/

module.exports = function (config) {


/**
* Send API request
*
* @param request {object}
* @param request.dataset {string} - Name of dataset, i.e. `kvk`
* @param [request.timeout = 5000] {number} - Request timeout in ms
* @param request.path {string} - Request path after `dataset` part
* @param request.params {object} - Data parameters to send
* @param request.callback {function} - `function (err, data) {}`
* @return {void}
*/

return function (request) {
var options = {
url: 'https://overheid.io/api/' + (request.dataset || config.dataset),
Expand Down

0 comments on commit 953b88d

Please sign in to comment.