| Total Complexity | 4 |
| Complexity/F | 1.33 |
| Lines of Code | 30 |
| Function Count | 3 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | var express = require('express'); |
||
| 2 | |||
| 3 | var router = express.Router(); |
||
| 4 | |||
| 5 | router.get("/", function (req, res) { |
||
| 6 | var streamId = Math.random().toString(36).substring(2); |
||
| 7 | res.redirect("/" + streamId); |
||
| 8 | }); |
||
| 9 | |||
| 10 | router.get("/:streamId?", function (req, res) { |
||
| 11 | res.render("index", { |
||
| 12 | host: global.host, |
||
| 13 | socketIoJs: global.socketIoJs, |
||
| 14 | streamId: req.params.streamId |
||
| 15 | }); |
||
| 16 | }); |
||
| 17 | |||
| 18 | router.post("/:streamId?", function (req, res) { |
||
| 19 | var ip = req.headers["x-forwarded-for"] |
||
| 20 | || req.connection.remoteAddress |
||
| 21 | || req.socket.remoteAddress |
||
| 22 | || req.connection.socket.remoteAddress |
||
| 23 | ; |
||
| 24 | if (req.headers["content-type"] === "application/json") { |
||
| 25 | global.socket.emit("log", {streamId: req.params.streamId, format: "json", data: req.body, ip: ip}); |
||
| 26 | } |
||
| 27 | res.send(""); |
||
| 28 | }); |
||
| 29 | |||
| 30 | module.exports = router; |
||
| 31 |