Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const jsonMask = require('json-mask');
const compile = jsonMask.compile;
const filter = jsonMask.filter;
/**
* Mask parts of the response.
*
* - `name` querystring param name [fields]
*
* @param {Object} opts
* @return {Promise}
* @api public
*/
module.exports = opts => {
opts = opts || {};
const name = opts.name || 'fields';
var jsonMask = require('json-mask'),
compile = jsonMask.compile,
filter = jsonMask.filter;
module.exports = function (opt) {
opt = opt || {};
function partialResponse(obj, fields) {
if (!fields) return obj;
return filter(obj, compile(fields));
}
function wrap(orig) {
return function (obj) {
var param = this.req.query[opt.query || 'fields'];
if (1 === arguments.length) {
orig(partialResponse(obj, param));
} else if (2 === arguments.length) {
const jsonMask = require('json-mask')
const compile = jsonMask.compile
const filter = jsonMask.filter
const defaults = {
filteringKeyName: 'fields'
}
const getFilterParams = (handler, filteringKeyName) => {
const { body } = handler.response
const { queryStringParameters } = handler.event
const fields = queryStringParameters
? queryStringParameters[filteringKeyName]
: undefined
return {
body,
fields