From 2ebc9352955e628890f96bbb089c76f314e9e9e2 Mon Sep 17 00:00:00 2001 From: Julian Simioni Date: Fri, 4 Sep 2015 11:56:48 -0400 Subject: [PATCH] Rename query/indidces to query/types It didn't really contain a list of indices. --- helper/types.js | 2 +- query/{indeces.js => types.js} | 4 ++-- sanitiser/_id.js | 8 ++++---- sanitiser/_layers.js | 8 ++++---- test/unit/helper/types.js | 2 +- test/unit/query/{indeces.js => types.js} | 10 +++++----- test/unit/run.js | 2 +- test/unit/sanitiser/place.js | 4 ++-- test/unit/sanitiser/reverse.js | 1 - 9 files changed, 20 insertions(+), 21 deletions(-) rename query/{indeces.js => types.js} (89%) rename test/unit/query/{indeces.js => types.js} (63%) diff --git a/helper/types.js b/helper/types.js index 30ab74d5..20443ad9 100644 --- a/helper/types.js +++ b/helper/types.js @@ -1,4 +1,4 @@ -var valid_types = require( '../query/indeces' ); +var valid_types = require( '../query/types' ); module.exports = function calculate_types(clean_types) { if (!clean_types) { diff --git a/query/indeces.js b/query/types.js similarity index 89% rename from query/indeces.js rename to query/types.js index 1fff5961..5f8cfab7 100644 --- a/query/indeces.js +++ b/query/types.js @@ -1,5 +1,5 @@ -// querable indeces +// querable types module.exports = [ 'geoname', @@ -13,4 +13,4 @@ module.exports = [ 'local_admin', 'osmaddress', 'openaddresses' -]; \ No newline at end of file +]; diff --git a/sanitiser/_id.js b/sanitiser/_id.js index a8424363..78ff6b1f 100644 --- a/sanitiser/_id.js +++ b/sanitiser/_id.js @@ -7,7 +7,7 @@ var isObject = require('is-object'); function sanitize( req ){ req.clean = req.clean || {}; var params = req.query; - var indeces = require('../query/indeces'); + var types = require('../query/types'); var delim = ':'; // ensure params is a valid object @@ -55,9 +55,9 @@ function sanitize( req ){ if('string' !== typeof type || !type.length){ return errormessage(thisparam); } - // type text must be one of the indeces - if(indeces.indexOf(type) === -1){ - return errormessage('type', type + ' is invalid. It must be one of these values - [' + indeces.join(', ') + ']'); + // type text must be one of the types + if(types.indexOf(type) === -1){ + return errormessage('type', type + ' is invalid. It must be one of these values - [' + types.join(', ') + ']'); } req.clean.ids.push({ id: id, diff --git a/sanitiser/_layers.js b/sanitiser/_layers.js index be13526a..8feb50e9 100644 --- a/sanitiser/_layers.js +++ b/sanitiser/_layers.js @@ -1,6 +1,6 @@ var isObject = require('is-object'), - indeces = require('../query/indeces'), + types = require('../query/types'), get_layers = require('../helper/layers'); // validate inputs, convert types and apply defaults @@ -23,7 +23,7 @@ function sanitize( req ){ // decide which layers can be queried var alias_layers = ['poi', 'admin', 'address']; - var alias_indeces = indeces.concat(alias_layers); + var alias_types = types.concat(alias_layers); // parse GET params var layers = params.layers.split(',').map( function( layer ){ @@ -32,10 +32,10 @@ function sanitize( req ){ // validate layer names for( var x=0; x0'; }, defaultFormatError = 'invalid: must be of the format type:id for ex: \'geoname:4163334\'', defaultError = 'invalid param \'id\': text length, must be >0', defaultMissingTypeError = function(input) { var type = input.split(delimiter)[0]; - return type + ' is invalid. It must be one of these values - [' + indeces.join(', ') + ']'; }, + return type + ' is invalid. It must be one of these values - [' + types.join(', ') + ']'; }, defaultClean = { ids: [ { id: '123', type: 'geoname' } ], details: true }, sanitize = function(query, cb) { _sanitize({'query':query}, cb); }, inputs = { diff --git a/test/unit/sanitiser/reverse.js b/test/unit/sanitiser/reverse.js index 73e3b381..bf9462b8 100644 --- a/test/unit/sanitiser/reverse.js +++ b/test/unit/sanitiser/reverse.js @@ -13,7 +13,6 @@ var suggest = require('../../../sanitiser/reverse'), categories: [] }, sanitize = function(query, cb) { _sanitize({'query':query}, cb); }; -var all_layers = ( '../../query/indeces' ); module.exports.tests = {};