Skip to content

💡 [REQUEST] - Add middleware to do data sanitization against NOSQL query injection and XSS and Implement a global error handling controller #53

@BiswajitSahoo-tech

Description

@BiswajitSahoo-tech

Start Date

09/04/2022

Implementation PR

No response

Reference Issues

No response

Summary

  • Want to add some middleware that will prevent cross-site scripting and NoSQL query injection.

  • Also want to implement a global error handler, which means after catching errors all over the application we send the error to a global error handler which will decide what to do with it.

Basic Example

Let on user.js we get an error which will go to catch section

e,g

try{
   //......
  }catch( err) {
      next( err) // calling the global err handler
  }

And in index.js we have the global error handler which will be called

index.js

app.use( (err, req, res, next) => {
          res.status( err.statuscode) . json( {
          data: err.message
          })
});

Drawbacks

There is no drawback of adding above features

Unresolved questions

No response

Metadata

Metadata

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions