clear mongo query from malicious operators (where) and unsafe regex expressions.
npm install mongo-query-sanitize
const { sanitizeMongoQuery } = require('mongo-query-sanitize');
const maliciousQuery = {$where: "sleep(1000)"}; // or unsafe regex
sanitizeMongoQuery(maliciousQuery); // will throw error