mirror of
https://github.com/Raghu-Ch/nodeRestAPI.git
synced 2026-02-10 20:53:02 -05:00
initial commit
This commit is contained in:
34
node_modules/timed-out/index.js
generated
vendored
Normal file
34
node_modules/timed-out/index.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = function (req, time) {
|
||||
if (req.timeoutTimer) { return req; }
|
||||
|
||||
var host = req._headers ? (' to ' + req._headers.host) : '';
|
||||
|
||||
req.timeoutTimer = setTimeout(function timeoutHandler() {
|
||||
req.abort();
|
||||
var e = new Error('Connection timed out on request' + host);
|
||||
e.code = 'ETIMEDOUT';
|
||||
req.emit('error', e);
|
||||
}, time);
|
||||
|
||||
// Set additional timeout on socket - in case if remote
|
||||
// server freeze after sending headers
|
||||
req.setTimeout(time, function socketTimeoutHandler() {
|
||||
req.abort();
|
||||
var e = new Error('Socket timed out on request' + host);
|
||||
e.code = 'ESOCKETTIMEDOUT';
|
||||
req.emit('error', e);
|
||||
});
|
||||
|
||||
function clear() {
|
||||
if (req.timeoutTimer) {
|
||||
clearTimeout(req.timeoutTimer);
|
||||
req.timeoutTimer = null;
|
||||
}
|
||||
}
|
||||
|
||||
return req
|
||||
.on('response', clear)
|
||||
.on('error', clear);
|
||||
};
|
||||
98
node_modules/timed-out/package.json
generated
vendored
Normal file
98
node_modules/timed-out/package.json
generated
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
{
|
||||
"raw": "timed-out@^2.0.0",
|
||||
"scope": null,
|
||||
"escapedName": "timed-out",
|
||||
"name": "timed-out",
|
||||
"rawSpec": "^2.0.0",
|
||||
"spec": ">=2.0.0 <3.0.0",
|
||||
"type": "range"
|
||||
},
|
||||
"C:\\Users\\chvra\\Documents\\angular-play\\nodeRest\\node_modules\\got"
|
||||
]
|
||||
],
|
||||
"_from": "timed-out@>=2.0.0 <3.0.0",
|
||||
"_id": "timed-out@2.0.0",
|
||||
"_inCache": true,
|
||||
"_location": "/timed-out",
|
||||
"_npmUser": {
|
||||
"name": "floatdrop",
|
||||
"email": "floatdrop@gmail.com"
|
||||
},
|
||||
"_npmVersion": "1.4.28",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"raw": "timed-out@^2.0.0",
|
||||
"scope": null,
|
||||
"escapedName": "timed-out",
|
||||
"name": "timed-out",
|
||||
"rawSpec": "^2.0.0",
|
||||
"spec": ">=2.0.0 <3.0.0",
|
||||
"type": "range"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/got"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/timed-out/-/timed-out-2.0.0.tgz",
|
||||
"_shasum": "f38b0ae81d3747d628001f41dafc652ace671c0a",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "timed-out@^2.0.0",
|
||||
"_where": "C:\\Users\\chvra\\Documents\\angular-play\\nodeRest\\node_modules\\got",
|
||||
"author": {
|
||||
"name": "Vsevolod Strukchinsky",
|
||||
"email": "floatdrop@gmail.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/floatdrop/timed-out/issues"
|
||||
},
|
||||
"dependencies": {},
|
||||
"description": "Emit `ETIMEDOUT` or `ESOCKETTIMEDOUT` when ClientRequest is hanged",
|
||||
"devDependencies": {
|
||||
"mocha": "*"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "f38b0ae81d3747d628001f41dafc652ace671c0a",
|
||||
"tarball": "https://registry.npmjs.org/timed-out/-/timed-out-2.0.0.tgz"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"gitHead": "2f35278f664de824923bfacf48d5e695f300bc69",
|
||||
"homepage": "https://github.com/floatdrop/timed-out",
|
||||
"keywords": [
|
||||
"http",
|
||||
"https",
|
||||
"get",
|
||||
"got",
|
||||
"url",
|
||||
"uri",
|
||||
"request",
|
||||
"util",
|
||||
"utility",
|
||||
"simple"
|
||||
],
|
||||
"license": "MIT",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "floatdrop",
|
||||
"email": "floatdrop@gmail.com"
|
||||
}
|
||||
],
|
||||
"name": "timed-out",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/floatdrop/timed-out.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha"
|
||||
},
|
||||
"version": "2.0.0"
|
||||
}
|
||||
37
node_modules/timed-out/readme.md
generated
vendored
Normal file
37
node_modules/timed-out/readme.md
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
# timed-out [](https://travis-ci.org/floatdrop/timed-out)
|
||||
|
||||
> Timeout HTTP/HTTPS requests
|
||||
|
||||
Emit Error object with `code` property equal `ETIMEDOUT` or `ESOCKETTIMEDOUT` when ClientRequest is hanged.
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var get = require('http').get;
|
||||
var timeout = require('timed-out');
|
||||
|
||||
var req = get('http://www.google.ru');
|
||||
timeout(req, 2000); // Set 2 seconds limit
|
||||
```
|
||||
|
||||
### API
|
||||
|
||||
#### timedout(request, time)
|
||||
|
||||
##### request
|
||||
|
||||
*Required*
|
||||
Type: [`ClientRequest`](http://nodejs.org/api/http.html#http_class_http_clientrequest)
|
||||
|
||||
The request to watch on.
|
||||
|
||||
##### time
|
||||
|
||||
*Required*
|
||||
Type: `number`
|
||||
|
||||
Time in milliseconds before errors will be emitted and `request.abort()` call happens.
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Vsevolod Strukchinsky](floatdrop@gmail.com)
|
||||
Reference in New Issue
Block a user