hapi-dribble
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -6,3 +6,3 @@ 'use strict'; | ||
const _ = require('lodash'); | ||
const { isEmpty, forEach } = require('lodash'); | ||
@@ -66,3 +66,5 @@ const removeInferredItems = (arr) => | ||
const prevObj = objToBuild; | ||
if (!child) return; | ||
if (!child) { | ||
return; | ||
} | ||
@@ -91,2 +93,3 @@ let newObj; | ||
} | ||
walkAndAddProps(tail, currentProp, objToBuild, visited); | ||
@@ -99,2 +102,3 @@ if (remaining.length) { | ||
}; | ||
iter(0); | ||
@@ -141,3 +145,3 @@ visited.push(head); | ||
currentProp.forEach((current) => { | ||
if (_.isEmpty(current)) { | ||
if (isEmpty(current)) { | ||
previousProp.forEach(previous => { | ||
@@ -215,3 +219,2 @@ if (Array.isArray(previous)) { | ||
if (head === '[]') { | ||
// eslint-disable-next-line no-return-assign | ||
currentProp.forEach(prop => prop.length = 0); | ||
@@ -221,3 +224,3 @@ } else { | ||
const clean = (properyNames, predicate) => { | ||
_.forEach( | ||
forEach( | ||
omit(prop, properyNames, predicate), | ||
@@ -224,0 +227,0 @@ (value, key) => { delete prop[key]; } |
{ | ||
"name": "hapi-dribble", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "dynamically filter api responses", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
# hapi-dribble | ||
`hapi-dribble` allows api responses to be filtered dynamically based upon the `server.request` state. | ||
`hapi-dribble` allows api responses to be filtered dynamically based upon a `request` state. | ||
@@ -23,3 +23,4 @@ ## Install | ||
hasAdminScope: { | ||
rule: (request) => request.auth.credentials.scope.includes('admin') | ||
rule: (request) => | ||
request.auth.credentials.scope.includes('admin'), | ||
filter: { | ||
@@ -33,3 +34,4 @@ omit: ['user.id'] | ||
hasSuperAdminScope: { | ||
rule: (request) => request.auth.credentials.scope.includes('super-admin') | ||
rule: (request) => | ||
request.auth.credentials.scope.includes('super-admin'), | ||
filter: { | ||
@@ -186,8 +188,4 @@ keep: ['user', 'meta'] | ||
``` | ||
A filter which specifies: `Keep: ['a.b.c', 'a.b']` | ||
A filter which specifies: `Keep: ['a.b.c', 'a.b']` is reduced to: `Keep: ['a.b']` as pointing to path `'a.b'` will keep all of the properties in object `b` (`'c'` here is inferred). | ||
is reduced to: `Keep: ['a.b']` | ||
as pointing to path `'a.b'` will keep all of the properties in object `b` (`'c'` here is inferred). | ||
- If the path contains an array property, it is assumed each item in the array has a consistent schema. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
37816
1263
188