I have a nodejs server written using express module.The input to the server is a url and output is a json response.I came across some attacks called XHR,XSS and CSRF.Express has a function that handles csrf.Node-validator is one module that i came across when i browsed regarding these.Below is the code
Say my url is
localhost:1340/promotionDetails?promotion_id=PROM008765
I have done the manipulation below as
//Validate user input
req.check('promotionDetails', 'Please enter a valid promotionDetails').len(4,5).isInt();
req.checkHeader('referer').contains('localhost');
Is this approach the correct way to handle such attacks.Any idea will be really helpful