Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ags-walk

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ags-walk - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

60

index.js

@@ -6,19 +6,19 @@ const request = require('xhr-request')

/**
* A module to walk the folders of an ArcGIS Server Rest API
* and return all the services
* @name ags-walk
* @param {string} url the base url of an ArcGIS Server Rest API
* @param {Object} [opts] options for the module
* @param {number} [opts.limit=5] the maximum number of folders to
* index at the same time
* @param {Function} cb the callback function to run after
* results have been returned
* @returns {string[]}
* @example
* // returns [{ name: 'Elevation/earthquakedemoelevation, type: 'MapServer'}...]
* agsWalk('http://sampleserver6.arcgisonline.com/arcgis/rest/services', function(err, services) {
* if (err) throw err
* return services
* }
*/
* A module to walk the folders of an ArcGIS Server Rest API
* and return all the services
* @name ags-walk
* @param {string} url the base url of an ArcGIS Server Rest API
* @param {Object} [opts] options for the module
* @param {number} [opts.limit=5] the maximum number of folders to
* index at the same time
* @param {Function} cb the callback function to run after
* results have been returned
* @returns {string[]}
* @example
* // returns [{ name: 'Elevation/earthquakedemoelevation, type: 'MapServer'}...]
* agsWalk('http://sampleserver6.arcgisonline.com/arcgis/rest/services', function(err, services) {
* if (err) throw err
* return services
* }
*/
module.exports = function (url, opts, cb) {

@@ -71,15 +71,19 @@ if (typeof opts === 'function') {

function _harvestFolders (baseUrl, folders) {
const tasks = folders.map(function (folder) {
return function (cb) {
const opts = {
json: true
if (folders) {
const tasks = folders.map(function (folder) {
return function (cb) {
const opts = {
json: true
}
request(baseUrl + '/' + folder + '?f=json', opts, function (err, data) {
if (err) return cb(err)
cb(null, data)
})
}
request(baseUrl + '/' + folder + '?f=json', opts, function (err, data) {
if (err) return cb(err)
cb(null, data)
})
}
})
return tasks
})
return tasks
} else {
return []
}
}
}
{
"name": "ags-walk",
"version": "1.0.1",
"version": "1.0.2",
"description": "Walks an ArcGIS Server Rest API and returns all services",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -6,6 +6,14 @@ const test = require('tape')

const rootNoServices = {
'currentVersion': 10.22,
'services': [
'Thing1',
'Thing2'
]
}
const root = {
'currentVersion': 10.22,
'folders': [
'Basemaps',
'Basemaps'
],

@@ -59,2 +67,19 @@ 'services': [

test('ags with no folders', function (t) {
t.plan(3)
const server = http.createServer(function (req, res) {
t.equal(req.url, '/arcgis/rest/services?f=json', 'should return correct url')
res.status = 200
res.end(JSON.stringify(rootNoServices))
})
server.listen(0, function () {
const port = server.address().port
agsWalk('http://localhost:' + port + '/arcgis/rest/services', function (err, res) {
t.error(err)
t.equal(res.length, 2)
server.close()
})
})
})
test('invalid ags', function (t) {

@@ -61,0 +86,0 @@ t.plan(3)

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc