Search code examples
nestjssanitization

How to sanitize data in NestJs?


There was one question before but with no answer. Since expresss-sanitizer is deprecated I'm wondering how to properly sanitize data in the NestJs queries?

I would probably use a global and custom pipe for that, but honestly I have no idea how could I replace string of <script>....</script> into properly sanitized format.

Do you know any npm packages that would help to sort that out?


Solution

  • Check out this question. I think your best option is using a package like xss or strip-js to strip javascript code from a string. Then wrap it in a custom pipe.