(req, res, next)
| 9 | * @returns {void} |
| 10 | */ |
| 11 | export function zuul (req, res, next) { |
| 12 | const uri = req.url; |
| 13 | let protect = false; |
| 14 | |
| 15 | if (req.unprotect === false) { |
| 16 | for (const i of req.server.auth.protect) { |
| 17 | if (i.test(uri)) { |
| 18 | protect = true; |
| 19 | break; |
| 20 | } |
| 21 | } |
| 22 | } |
| 23 | |
| 24 | // Setting state so the connection can be terminated properly |
| 25 | req.protect = protect; |
| 26 | req.protectAsync = false; |
| 27 | |
| 28 | rate(req, res, e => { |
| 29 | if (e !== void 0) { |
| 30 | res.error(e); |
| 31 | } else if (protect) { |
| 32 | next(); |
| 33 | } else { |
| 34 | req.exit(); |
| 35 | } |
| 36 | }); |
| 37 | } |
no test coverage detected