hapi-dribble
Advanced tools
Comparing version 1.0.1 to 2.0.0
@@ -11,2 +11,3 @@ module.exports = { | ||
"sourceType": "script", | ||
"ecmaVersion": 8, | ||
"ecmaFeatures": { | ||
@@ -13,0 +14,0 @@ "modules": false, |
@@ -42,3 +42,3 @@ 'use strict'; | ||
const filterResponse = (request, reply) => { | ||
const filterResponse = (request, h) => { | ||
const config = request.route.settings.plugins.dribble; | ||
@@ -48,3 +48,3 @@ | ||
if (!config) { | ||
return reply.continue(); | ||
return h.continue; | ||
} | ||
@@ -55,3 +55,3 @@ | ||
if (!match) { | ||
return reply.continue(); | ||
return h.continue; | ||
} | ||
@@ -64,13 +64,10 @@ | ||
return reply.continue(); | ||
return h.continue; | ||
}; | ||
exports.register = (server, options, next) => { | ||
server.ext('onPreResponse', filterResponse); | ||
next(); | ||
exports.plugin = { | ||
pkg: require('../package.json'), | ||
register: async function register(server) { | ||
server.ext('onPreResponse', filterResponse); | ||
} | ||
}; | ||
exports.register.attributes = { | ||
name: 'hapi-dribble', | ||
version: '1.0.0' | ||
}; |
{ | ||
"name": "hapi-dribble", | ||
"version": "1.0.1", | ||
"version": "2.0.0", | ||
"description": "dynamically filter api responses", | ||
@@ -24,3 +24,3 @@ "main": "lib/index.js", | ||
"eslint-plugin-import": "^1.7.0", | ||
"hapi": "^16.1.0", | ||
"hapi": "^17.0.0", | ||
"lab": "^13.0.1" | ||
@@ -27,0 +27,0 @@ }, |
@@ -27,5 +27,5 @@ # hapi-dribble | ||
omit: ['user.id'] | ||
deep: {[ | ||
{ for: 'user.data': omit: ['personal'] } | ||
]} | ||
deep: [ | ||
{ for: 'user.data', omit: ['personal'] } | ||
] | ||
} | ||
@@ -38,5 +38,5 @@ }, | ||
keep: ['user', 'meta'] | ||
deep: {[ | ||
{ for: 'user.data': omit: ['personal'] } | ||
]} | ||
deep: [ | ||
{ for: 'user.data', omit: ['personal'] } | ||
] | ||
} | ||
@@ -43,0 +43,0 @@ } |
@@ -14,30 +14,34 @@ 'use strict'; | ||
const testFilter = (options, done) => { | ||
const server = new Hapi.Server(); | ||
server.connection(); | ||
const testFilter = async (options, done) => { | ||
const server = Hapi.server(); | ||
server.register(require('../lib'), () => { | ||
// eslint-disable-next-line no-unused-expressions | ||
await server.register(require('../lib')); | ||
server.route({ | ||
method: 'GET', | ||
path: '/filter', | ||
config: { | ||
plugins: { | ||
dribble: { | ||
all: { | ||
rule: () => true, | ||
filter: options.filter | ||
} | ||
server.route({ | ||
method: 'GET', | ||
path: '/filter', | ||
config: { | ||
plugins: { | ||
dribble: { | ||
all: { | ||
rule: () => true, | ||
filter: options.filter | ||
} | ||
}, | ||
handler: (request, reply) => | ||
reply(options.fixture).code(200) | ||
} | ||
}); | ||
} | ||
}, | ||
handler: (request, h) => | ||
h.response(options.fixture).code(200) | ||
} | ||
}); | ||
server.inject('/filter', (res) => { | ||
expect(JSON.parse(res.payload)).to.equal(options.expected); | ||
done(); | ||
}); | ||
}); | ||
const injectOptions = { | ||
method: 'GET', | ||
url: '/filter' | ||
}; | ||
const res = await server.inject(injectOptions); | ||
expect(JSON.parse(res.payload)).to.equal(options.expected); | ||
done(); | ||
}; | ||
@@ -44,0 +48,0 @@ |
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
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 104 instances 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
166424
155
1266
104