moul/node-onlinelabs

View on GitHub
browser/bundle.map.js

Summary

Maintainability
A
0 mins
Test Coverage
{
  "version": 3,
  "sources": [
    "node_modules/browserify/node_modules/browser-pack/_prelude.js",
    "lib/config.js",
    "lib/index.js"
  ],
  "names": [],
  "mappings": "AAAA;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACVA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA",
  "file": "generated.js",
  "sourceRoot": "",
  "sourcesContent": [
    "(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require==\"function\"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error(\"Cannot find module '\"+o+\"'\");throw f.code=\"MODULE_NOT_FOUND\",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require==\"function\"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})",
    "var config = require('rc')('node_scaleway', {\n  api_endpoint: 'https://api.scaleway.com/',\n\n  organization: null,\n  token: null\n});\n\n// FIXME: data validation\n\nmodule.exports = config;\n",
    "var rp = require('request-promise'),\n    debug = require('debug')('node-scaleway:lib'),\n    config = require('./config'),\n    _ = require('lodash');\n\n\nvar Client = module.exports = function(options) {\n  this.config = _.defaults(options || {}, config);\n};\n\n\n(function() {\n  var client;\n\n  this.request = function(path, method, input, options, cb) {\n    client = this;\n\n    // options parameter is optional\n    if (typeof options === 'function') {\n      cb = options;\n      options = {};\n    }\n    options = options || {};\n\n    var url = client.config.api_endpoint + path.replace(/^\\//, '');\n\n    // build options\n    _.defaults(options, {\n      method: method,\n      url: url,\n      headers: {},\n      resolveWithFullResponse: true\n    });\n    // default headers\n    _.defaults(options.headers, {\n      'Accept': 'application/json',\n      'User-Agent': 'node-scaleway'  // FIXME: append version dynamically\n    });\n    // token-based authentication\n    if (client.config.token) {\n      _.defaults(options.headers, {\n        'X-Auth-Token': client.config.token\n      });\n    }\n    // input is passed in the options object to rp, if input is empty\n    // we need to use json:true to enable automatic response JSON parsing\n    _.defaults(options, {\n      json: input || true\n    });\n\n    debug(method + ' ' + url, options);\n\n    // display response from server\n    if (debug.enabled) {\n      options.transform = function(data, response) {\n        debug(response.statusCode, {\n          headers: response.headers,\n          body: data\n        });\n        return response;\n      };\n    }\n\n    return rp(options).promise().nodeify(cb);\n  };\n\n  // HTTP verbs\n  this.get = function(path, options, cb) {\n    return this.request(path, 'GET', null, options, cb);\n  };\n  this.post = function(path, input, options, cb) {\n    return this.request(path, 'POST', input, options, cb);\n  };\n  this.patch = function(path, input, options, cb) {\n    return this.request(path, 'PATCH', input, options, cb);\n  };\n  this.put = function(path, input, options, cb) {\n    return this.request(path, 'PUT', input, options, cb);\n  };\n  this.delete = function(path, options, cb) {\n    return this.request(path, 'DELETE', null, options, cb);\n  };\n\n}).call(Client.prototype);\n"
  ]
}