initial commit

This commit is contained in:
2017-05-20 16:42:43 -04:00
commit e6530a1fa6
2106 changed files with 206258 additions and 0 deletions

276
node_modules/got/index.js generated vendored Normal file
View File

@@ -0,0 +1,276 @@
'use strict';
var http = require('http');
var https = require('https');
var urlLib = require('url');
var util = require('util');
var zlib = require('zlib');
var querystring = require('querystring');
var objectAssign = require('object-assign');
var infinityAgent = require('infinity-agent');
var duplexify = require('duplexify');
var isStream = require('is-stream');
var readAllStream = require('read-all-stream');
var timedOut = require('timed-out');
var prependHttp = require('prepend-http');
var lowercaseKeys = require('lowercase-keys');
var isRedirect = require('is-redirect');
var NestedErrorStacks = require('nested-error-stacks');
function GotError(message, nested) {
NestedErrorStacks.call(this, message, nested);
objectAssign(this, nested, {nested: this.nested});
}
util.inherits(GotError, NestedErrorStacks);
GotError.prototype.name = 'GotError';
function got(url, opts, cb) {
if (typeof url !== 'string' && typeof url !== 'object') {
throw new GotError('Parameter `url` must be a string or object, not ' + typeof url);
}
if (typeof opts === 'function') {
cb = opts;
opts = {};
}
opts = objectAssign(
{
protocol: 'http:'
},
typeof url === 'string' ? urlLib.parse(prependHttp(url)) : url,
opts
);
opts.headers = objectAssign({
'user-agent': 'https://github.com/sindresorhus/got',
'accept-encoding': 'gzip,deflate'
}, lowercaseKeys(opts.headers));
if (opts.pathname) {
opts.path = opts.pathname;
}
if (opts.query) {
if (typeof opts.query !== 'string') {
opts.query = querystring.stringify(opts.query);
}
opts.path = opts.pathname + '?' + opts.query;
delete opts.query;
}
var encoding = opts.encoding;
var body = opts.body;
var json = opts.json;
var timeout = opts.timeout;
var proxy;
var redirectCount = 0;
delete opts.encoding;
delete opts.body;
delete opts.json;
delete opts.timeout;
if (json) {
opts.headers.accept = opts.headers.accept || 'application/json';
}
if (body) {
if (typeof body !== 'string' && !Buffer.isBuffer(body) && !isStream.readable(body)) {
throw new GotError('options.body must be a ReadableStream, string or Buffer');
}
opts.method = opts.method || 'POST';
if (!opts.headers['content-length'] && !opts.headers['transfer-encoding'] && !isStream.readable(body)) {
var length = typeof body === 'string' ? Buffer.byteLength(body) : body.length;
opts.headers['content-length'] = length;
}
}
opts.method = opts.method || 'GET';
// returns a proxy stream to the response
// if no callback has been provided
if (!cb) {
proxy = duplexify();
// forward errors on the stream
cb = function (err, data, response) {
proxy.emit('error', err, data, response);
};
}
if (proxy && json) {
throw new GotError('got can not be used as stream when options.json is used');
}
function get(opts, cb) {
var fn = opts.protocol === 'https:' ? https : http;
var url = urlLib.format(opts);
if (opts.agent === undefined) {
opts.agent = infinityAgent[fn === https ? 'https' : 'http'].globalAgent;
if (process.version.indexOf('v0.10') === 0 && fn === https && (
typeof opts.ca !== 'undefined' ||
typeof opts.cert !== 'undefined' ||
typeof opts.ciphers !== 'undefined' ||
typeof opts.key !== 'undefined' ||
typeof opts.passphrase !== 'undefined' ||
typeof opts.pfx !== 'undefined' ||
typeof opts.rejectUnauthorized !== 'undefined')) {
opts.agent = new infinityAgent.https.Agent({
ca: opts.ca,
cert: opts.cert,
ciphers: opts.ciphers,
key: opts.key,
passphrase: opts.passphrase,
pfx: opts.pfx,
rejectUnauthorized: opts.rejectUnauthorized
});
}
}
var req = fn.request(opts, function (response) {
var statusCode = response.statusCode;
var res = response;
// auto-redirect only for GET and HEAD methods
if (isRedirect(statusCode) && 'location' in res.headers && (opts.method === 'GET' || opts.method === 'HEAD')) {
// discard response
res.resume();
if (++redirectCount > 10) {
cb(new GotError('Redirected 10 times. Aborting.'), undefined, res);
return;
}
var redirectUrl = urlLib.resolve(url, res.headers.location);
var redirectOpts = objectAssign({}, opts, urlLib.parse(redirectUrl));
if (opts.agent === infinityAgent.http.globalAgent && redirectOpts.protocol === 'https:' && opts.protocol === 'http:') {
redirectOpts.agent = undefined;
}
if (proxy) {
proxy.emit('redirect', res, redirectOpts);
}
get(redirectOpts, cb);
return;
}
if (proxy) {
proxy.emit('response', res);
}
if (['gzip', 'deflate'].indexOf(res.headers['content-encoding']) !== -1) {
res = res.pipe(zlib.createUnzip());
}
if (statusCode < 200 || statusCode > 299) {
readAllStream(res, encoding, function (err, data) {
err = new GotError(opts.method + ' ' + url + ' response code is ' + statusCode + ' (' + http.STATUS_CODES[statusCode] + ')', err);
err.code = statusCode;
if (data && json) {
try {
data = JSON.parse(data);
} catch (e) {
err = new GotError('Parsing ' + url + ' response failed', new GotError(e.message, err));
}
}
cb(err, data, response);
});
return;
}
// pipe the response to the proxy if in proxy mode
if (proxy) {
proxy.setReadable(res);
return;
}
readAllStream(res, encoding, function (err, data) {
if (err) {
err = new GotError('Reading ' + url + ' response failed', err);
} else if (json && statusCode !== 204) {
// only parse json if the option is enabled, and the response
// is not a 204 (empty reponse)
try {
data = JSON.parse(data);
} catch (e) {
err = new GotError('Parsing ' + url + ' response failed', e);
}
}
cb(err, data, response);
});
}).once('error', function (err) {
cb(new GotError('Request to ' + url + ' failed', err));
});
if (timeout) {
timedOut(req, timeout);
}
if (!proxy) {
if (isStream.readable(body)) {
body.pipe(req);
} else {
req.end(body);
}
return;
}
if (body) {
proxy.write = function () {
throw new Error('got\'s stream is not writable when options.body is used');
};
if (isStream.readable(body)) {
body.pipe(req);
} else {
req.end(body);
}
return;
}
if (opts.method === 'POST' || opts.method === 'PUT' || opts.method === 'PATCH') {
proxy.setWritable(req);
return;
}
req.end();
}
get(opts, cb);
return proxy;
}
[
'get',
'post',
'put',
'patch',
'head',
'delete'
].forEach(function (el) {
got[el] = function (url, opts, cb) {
if (typeof opts === 'function') {
cb = opts;
opts = {};
}
return got(url, objectAssign({}, opts, {method: el.toUpperCase()}), cb);
};
});
module.exports = got;

120
node_modules/got/package.json generated vendored Normal file
View File

@@ -0,0 +1,120 @@
{
"_args": [
[
{
"raw": "got@^3.2.0",
"scope": null,
"escapedName": "got",
"name": "got",
"rawSpec": "^3.2.0",
"spec": ">=3.2.0 <4.0.0",
"type": "range"
},
"C:\\Users\\chvra\\Documents\\angular-play\\nodeRest\\node_modules\\package-json"
]
],
"_from": "got@>=3.2.0 <4.0.0",
"_id": "got@3.3.1",
"_inCache": true,
"_location": "/got",
"_npmUser": {
"name": "floatdrop",
"email": "floatdrop@gmail.com"
},
"_npmVersion": "1.4.28",
"_phantomChildren": {},
"_requested": {
"raw": "got@^3.2.0",
"scope": null,
"escapedName": "got",
"name": "got",
"rawSpec": "^3.2.0",
"spec": ">=3.2.0 <4.0.0",
"type": "range"
},
"_requiredBy": [
"/package-json"
],
"_resolved": "https://registry.npmjs.org/got/-/got-3.3.1.tgz",
"_shasum": "e5d0ed4af55fc3eef4d56007769d98192bcb2eca",
"_shrinkwrap": null,
"_spec": "got@^3.2.0",
"_where": "C:\\Users\\chvra\\Documents\\angular-play\\nodeRest\\node_modules\\package-json",
"bugs": {
"url": "https://github.com/sindresorhus/got/issues"
},
"dependencies": {
"duplexify": "^3.2.0",
"infinity-agent": "^2.0.0",
"is-redirect": "^1.0.0",
"is-stream": "^1.0.0",
"lowercase-keys": "^1.0.0",
"nested-error-stacks": "^1.0.0",
"object-assign": "^3.0.0",
"prepend-http": "^1.0.0",
"read-all-stream": "^3.0.0",
"timed-out": "^2.0.0"
},
"description": "Simplified HTTP/HTTPS requests",
"devDependencies": {
"from2-array": "0.0.3",
"istanbul": "^0.3.13",
"pem": "^1.4.4",
"tap": "^1.0.0"
},
"directories": {},
"dist": {
"shasum": "e5d0ed4af55fc3eef4d56007769d98192bcb2eca",
"tarball": "https://registry.npmjs.org/got/-/got-3.3.1.tgz"
},
"engines": {
"node": ">=0.10.0"
},
"files": [
"index.js"
],
"gitHead": "7bc82b8eb63893f264d3c109abe1530ca74a3fb0",
"homepage": "https://github.com/sindresorhus/got",
"keywords": [
"http",
"https",
"get",
"got",
"url",
"uri",
"request",
"util",
"utility",
"simple",
"curl",
"wget",
"fetch"
],
"license": "MIT",
"maintainers": [
{
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
},
{
"name": "floatdrop",
"email": "floatdrop@gmail.com"
},
{
"name": "kevva",
"email": "kevinmartensson@gmail.com"
}
],
"name": "got",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+https://github.com/sindresorhus/got.git"
},
"scripts": {
"coverage": "istanbul cover tape --report html -- test/test-*.js",
"test": "tap test/test-*.js"
},
"version": "3.3.1"
}

203
node_modules/got/readme.md generated vendored Normal file
View File

@@ -0,0 +1,203 @@
<h1 align="center">
<br>
<img width="360" src="https://rawgit.com/sindresorhus/got/master/media/logo.svg" alt="got">
<br>
<br>
<br>
</h1>
> Simplified HTTP/HTTPS requests
[![Build Status](https://travis-ci.org/sindresorhus/got.svg?branch=master)](https://travis-ci.org/sindresorhus/got)
A nicer interface to the built-in [`http`](http://nodejs.org/api/http.html) module.
It supports following redirects, streams, automagically handling gzip/deflate and some convenience options.
Created because [`request`](https://github.com/mikeal/request) is bloated *(several megabytes!)* and slow.
## Install
```
$ npm install --save got
```
## Usage
```js
var got = require('got');
// Callback mode
got('todomvc.com', function (err, data, res) {
console.log(data);
//=> <!doctype html> ...
});
// Stream mode
got('todomvc.com').pipe(fs.createWriteStream('index.html'));
// For POST, PUT and PATCH methods got returns a WritableStream
fs.createReadStream('index.html').pipe(got.post('todomvc.com'));
```
### API
It's a `GET` request by default, but can be changed in `options`.
#### got(url, [options], [callback])
##### url
*Required*
Type: `string`, `object`
The URL to request or bare [http.request options](https://nodejs.org/api/http.html#http_http_request_options_callback) object.
Properties from `options` will override properties in the parsed `url`.
##### options
Type: `object`
Any of the [`http.request`](http://nodejs.org/api/http.html#http_http_request_options_callback) options.
###### body
Type: `string`, `Buffer`, `ReadableStream`
*This option and stream mode are mutually exclusive.*
Body that will be sent with a `POST` request. If present in `options` and `options.method` is not set - `options.method` will be set to `POST`.
If `content-length` or `transfer-encoding` is not set in `options.headers` and `body` is a string or buffer, `content-length` will be set to the body length.
###### encoding
Type: `string`, `null`
Default: `'utf8'`
Encoding to be used on `setEncoding` of the response data. If `null`, the body is returned as a Buffer.
###### json
Type: `boolean`
Default: `false`
*This option and stream mode are mutually exclusive.*
Parse response body with `JSON.parse` and set `accept` header to `application/json`.
###### query
Type: `string`, `object`
Query string object that will be added to the request URL. This will override the query string in `url`.
###### timeout
Type: `number`
Milliseconds after which the request will be aborted and an error event with `ETIMEDOUT` code will be emitted.
###### agent
[http.Agent](http://nodejs.org/api/http.html#http_class_http_agent) instance.
If `undefined` - [`infinity-agent`](https://github.com/floatdrop/infinity-agent) will be used to backport Agent class from Node.js core.
To use default [globalAgent](http://nodejs.org/api/http.html#http_http_globalagent) just pass `null`.
##### callback(error, data, response)
###### error
`Error` object with HTTP status code as `code` property.
###### data
The data you requested.
###### response
The [response object](http://nodejs.org/api/http.html#http_http_incomingmessage).
When in stream mode, you can listen for events:
##### .on('response', response)
`response` event to get the response object of the final request.
##### .on('redirect', response, nextOptions)
`redirect` event to get the response object of a redirect. Second argument is options for the next request to the redirect location.
##### .on('error', error, body, response)
`error` event emitted in case of protocol error (like `ENOTFOUND` etc.) or status error (4xx or 5xx). Second argument is body of server response in case of status error. Third argument is response object.
###### response
The [response object](http://nodejs.org/api/http.html#http_http_incomingmessage).
#### got.get(url, [options], [callback])
#### got.post(url, [options], [callback])
#### got.put(url, [options], [callback])
#### got.patch(url, [options], [callback])
#### got.head(url, [options], [callback])
#### got.delete(url, [options], [callback])
Sets `options.method` to the method name and makes a request.
## Proxy
You can use the [`tunnel`](https://github.com/koichik/node-tunnel) module with the `agent` option to work with proxies:
```js
var got = require('got');
var tunnel = require('tunnel');
got('todomvc.com', {
agent: tunnel.httpOverHttp({
proxy: {
host: 'localhost'
}
})
}, function () {});
```
## Tip
It's a good idea to set the `'user-agent'` header so the provider can more easily see how their resource is used. By default it's the URL to this repo.
```js
var got = require('got');
got('todomvc.com', {
headers: {
'user-agent': 'https://github.com/your-username/repo-name'
}
}, function () {});
```
## Related
- [gh-got](https://github.com/sindresorhus/gh-got) - Convenience wrapper for interacting with the GitHub API
- [got-promise](https://github.com/floatdrop/got-promise) - Promise wrapper
## Created by
[![Sindre Sorhus](https://avatars.githubusercontent.com/u/170270?v=3&s=100)](http://sindresorhus.com) | [![Vsevolod Strukchinsky](https://avatars.githubusercontent.com/u/365089?v=3&s=100)](https://github.com/floatdrop)
---|---
[Sindre Sorhus](http://sindresorhus.com) | [Vsevolod Strukchinsky](https://github.com/floatdrop)
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)