Ocelot-Social/backend/src/middleware/xssMiddleware.ts
Ulf Gebhardt f782032563
refactor(backend): lint - import/order (#8350)
* lint - import/no-relative-parent-imports

fix build error

* fix md

* lint import/order

enabled rule import/order and fixed impot order in each file
2025-04-09 09:44:48 +02:00

24 lines
792 B
TypeScript

import walkRecursive from '@helpers/walkRecursive'
import { cleanHtml } from './helpers/cleanHtml'
// exclamation mark separetes field names, that should not be sanitized
const fields = [
{ field: 'content', excludes: ['CreateMessage', 'Message'] },
{ field: 'contentExcerpt' },
{ field: 'reasonDescription' },
{ field: 'description', excludes: ['embed'] },
{ field: 'descriptionExcerpt' },
]
export default {
Mutation: async (resolve, root, args, context, info) => {
args = walkRecursive(args, fields, info.fieldName, cleanHtml)
return resolve(root, args, context, info)
},
Query: async (resolve, root, args, context, info) => {
const result = await resolve(root, args, context, info)
return walkRecursive(result, fields, info.fieldName, cleanHtml)
},
}