featureservice
Advanced tools
Comparing version 0.0.4 to 0.1.0
@@ -5,2 +5,9 @@ # Change Log | ||
## [0.1.0] - 2015-08-05 | ||
### Added | ||
* Requests time out after 5 minutes of inactivity by default | ||
### Changed | ||
* TCP sockets are kept alive | ||
## [0.0.4] - 2015-07-29 | ||
@@ -28,2 +35,3 @@ ### Fixed | ||
[0.1.0]: https://github.com/chelm/featureservice/ompare/v0.0.4...v0.1.0 | ||
[0.0.4]: https://github.com/chelm/featureservice/ompare/v0.0.3...v0.0.4 | ||
@@ -30,0 +38,0 @@ [0.0.3]: https://github.com/chelm/featureservice/ompare/v0.0.2...v0.0.3 |
28
index.js
@@ -1,4 +0,1 @@ | ||
// A module designed to talk to feature services and get every feature | ||
// this code will expose methods for getting the URL to each page | ||
var queue = require('async').queue | ||
@@ -11,9 +8,16 @@ var http = require('http') | ||
/** | ||
* A feature service object needs a url and some optional params to make requests | ||
* this module exposes a pageQueue that can take an array of page url | ||
* the pageQueue will report back each page of features as they return | ||
* @module FeatureService | ||
* Feature Service constructor. Requires a URL. | ||
* Exposes a pageQueue that can take an array of page URLs. | ||
* The pageQueue will report back each page of features as they return. | ||
* | ||
* @class | ||
* @param {string} url - address of feature service | ||
* @param {object} options - layer (default: 0) | ||
*/ | ||
var FeatureService = function (url, options) { | ||
// catch omission of `new` keyword | ||
if (!(this instanceof FeatureService)) { | ||
return new FeatureService(url, options) | ||
} | ||
// check the last char on the url | ||
@@ -30,2 +34,3 @@ // protects us from urls registered with layers already in the url | ||
this.layer = options.layer || 0 | ||
this.timeOut = 5 * 60 * 1000 | ||
@@ -42,4 +47,2 @@ // an async for requesting pages of data | ||
} | ||
return this | ||
} | ||
@@ -54,2 +57,3 @@ | ||
var uri = urlUtils.parse(encodeURI(decodeURI(url))) | ||
var self = this | ||
@@ -59,2 +63,3 @@ var opts = { | ||
port: (uri.protocol === 'https:') ? 443 : uri.port || 80, | ||
keepAlive: true, | ||
hostname: uri.hostname, | ||
@@ -92,2 +97,7 @@ path: uri.path, | ||
req.setTimeout(self.timeOut, function () { | ||
req.end() | ||
callback(new Error('The request timed out after ' + self.timeOut / 1000 + ' seconds.')) | ||
}) | ||
req.on('error', function (error) { | ||
@@ -94,0 +104,0 @@ callback(error) |
{ | ||
"name": "featureservice", | ||
"description": "a node module meant to extract every feature from an Esri geo-service thing", | ||
"version": "0.0.4", | ||
"version": "0.1.0", | ||
"author": "Chris Helm", | ||
"contributors": "Daniel Fenton", | ||
"bugs": { | ||
"url": "https://github.com/chelm/featureservice/issues" | ||
"url": "https://github.com/dmfenton/featureservice/issues" | ||
}, | ||
@@ -18,4 +19,5 @@ "dependencies": { | ||
"minifyify": "^7.0.3", | ||
"nock": "^2.10.0", | ||
"sinon": "^1.15.4", | ||
"standard": "^4.5.4", | ||
"standard": "^5.0.0", | ||
"tap-spec": "^4.0.2", | ||
@@ -25,3 +27,3 @@ "tape": "^4.0.1", | ||
}, | ||
"homepage": "https://github.com/chelm/featureservice", | ||
"homepage": "https://github.com/dmfenton/featureservice", | ||
"keywords": [ | ||
@@ -36,3 +38,3 @@ "esri", | ||
"type": "git", | ||
"url": "https://github.com/chelm/featureservice.git" | ||
"url": "https://github.com/dmfenton/featureservice.git" | ||
}, | ||
@@ -39,0 +41,0 @@ "scripts": { |
@@ -65,1 +65,7 @@ # featureservice | ||
## License | ||
[Apache 2.0](LICENSE) | ||
<!-- [](Esri Tags: ArcGIS Web Mapping GeoJson FeatureServices) --> | ||
<!-- [](Esri Language: JavaScript) --> |
var sinon = require('sinon') | ||
var test = require('tape') | ||
var FeatureService = require('../') | ||
var nock = require('nock') | ||
@@ -84,2 +85,16 @@ var service = new FeatureService('http://koop.dc.esri.com/socrata/seattle/2tje-83f6/FeatureServer/0', {}) | ||
test('time out when there is no response', function (t) { | ||
var error | ||
service.timeOut = 5 | ||
nock('http://www.timeout.com').get('/').socketDelay(100) | ||
service.request('http://www.timeout.com', function (err, data) { | ||
error = err | ||
}) | ||
setTimeout(function () { | ||
t.equal(typeof error, 'object') | ||
t.end() | ||
}, 25) | ||
}) | ||
test('teardown', function (t) { | ||
@@ -86,0 +101,0 @@ service.request.restore() |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
71
4
193550
10
8
1
1254
2
3
7