Guest User

Untitled

a guest
Oct 24th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. timeout = require('connect-timeout')
  2.  
  3. app.get('/', timeout('5s'), function(req, res){
  4. ##DO SOMETHING 1
  5. ##DO SOMETHING 2
  6. ##DO SOMETHING 3
  7. res.send('ok'); ##line 7
  8. });
  9.  
  10. app.get('/', timeout('5s'), function(req, res){
  11. ##DO SOMETHING 1
  12. ##DO SOMETHING 2
  13. ##DO SOMETHING 3
  14. if (!req.timedout) {
  15. res.send('ok'); ##line 7
  16. }
  17. });
  18.  
  19. app.use(function(req,res,next){
  20. var _send = res.send;
  21. var sent = false;
  22. res.send = function(data){
  23. if(sent) return;
  24. _send.bind(res)(data);
  25. sent = true;
  26. };
  27. next();
  28. });
Add Comment
Please, Sign In to add comment