jsonapi-server
Advanced tools
Comparing version 0.15.1 to 0.15.2
@@ -47,1 +47,3 @@ 2015-06-29 - Initial release | ||
2015-11-18 - v0.15.1 | ||
2015-11-19 - Validate filter params before handing over to resourceHandler.search | ||
2015-11-19 - v0.15.2 |
@@ -52,2 +52,25 @@ "use strict"; | ||
}, | ||
function validateFilterParams(callback) { | ||
var allFilters = request.params.filter; | ||
if (!allFilters) return callback(); | ||
var filters = { }; | ||
for (var i in allFilters) { | ||
if (!request.resourceConfig.attributes[i]) { | ||
return callback({ | ||
status: "403", | ||
code: "EFORBIDDEN", | ||
title: "Invalid filter", | ||
detail: request.resourceConfig.resource + " do not have property " + i | ||
}); | ||
} | ||
if (allFilters[i] instanceof Array) { | ||
allFilters[i] = allFilters[i].join(","); | ||
} | ||
filters[i] = allFilters[i]; | ||
} | ||
request.params.filter = filters; | ||
return callback(); | ||
}, | ||
function(callback) { | ||
@@ -54,0 +77,0 @@ resourceConfig.handlers.search(request, callback); |
{ | ||
"name": "jsonapi-server", | ||
"version": "0.15.1", | ||
"version": "0.15.2", | ||
"description": "A fully featured NodeJS sever implementation of json:api. You provide the resources, we provide the api.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
3661
159100
56