mirror of
https://github.com/strapi/strapi.git
synced 2025-07-28 11:30:21 +00:00
27 lines
690 B
JavaScript
27 lines
690 B
JavaScript
'use strict';
|
|
|
|
const { curry } = require('lodash/fp');
|
|
|
|
const { pipeAsync } = require('../async');
|
|
const traverseEntity = require('../traverse-entity');
|
|
|
|
const { removePassword, removePrivate } = require('./visitors');
|
|
|
|
const sanitizePasswords = curry((schema, entity) => {
|
|
return traverseEntity(removePassword, { schema }, entity);
|
|
});
|
|
|
|
const sanitizePrivates = curry((schema, entity) => {
|
|
return traverseEntity(removePrivate, { schema }, entity);
|
|
});
|
|
|
|
const defaultSanitizeOutput = curry((schema, entity) => {
|
|
return pipeAsync(sanitizePrivates(schema), sanitizePasswords(schema))(entity);
|
|
});
|
|
|
|
module.exports = {
|
|
sanitizePasswords,
|
|
sanitizePrivates,
|
|
defaultSanitizeOutput,
|
|
};
|