GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( afb7bc...dee889 )
by Vladimir
32s
created

src/back/routes/index.js   A

Complexity

Total Complexity 4
Complexity/F 1.33

Size

Lines of Code 63
Function Count 3

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 0
wmc 4
c 1
b 0
f 0
nc 4
mnd 1
bc 4
fnc 3
dl 0
loc 63
rs 10
bpm 1.3333
cpm 1.3333
noi 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A index.js ➔ ??? 0 4 1
1
const express = require('express');
2
3
const router = express.Router();
4
5
/**
6
 * Homepage route, which will redirect to page with random stream id.
7
 *
8
 * @param {Object} req HTTP request.
9
 * @param {Object} res HTTP response.
10
 */
11
router.get('/', (req, res) => {
12
  const streamId = Math.random().toString(36).substring(2);
13
  res.redirect(`/${streamId}`);
14
});
15
16
/**
17
 * Stream page route. Renders web page for particular stream id.
18
 *
19
 * @param {Object} req HTTP request.
20
 * @param {Object} res HTTP response.
21
 */
22
router.get('/:streamId?', (req, res) => {
23
  res.render('index', {
24
    hostName: global.APP_HOST_NAME,
25
    host: global.APP_HOST,
26
    port: global.APP_PORT_FOR_HELP_BLOCK,
27
    socketIoJs: global.APP_SOCKET_IO_JS,
28
    streamId: req.params.streamId,
29
    sentryDSN: global.SENTRY_DSN_FRONTEND,
30
    googleAnalyticsId: global.GOOGLE_ANALYTICS_ID,
31
  });
32
});
33
34
/**
35
 * Post message into page with particular stream id.
36
 *
37
 * @emits LOG.NEW
38
 *
39
 * @param {Object} req HTTP request.
40
 * @param {Object} res HTTP response.
41
 */
42
router.post('/:streamId?', (req, res) => {
43
  // Capture message sender ip address as additional information.
44
  const ip = req.headers['x-forwarded-for']
45
    || req.connection.remoteAddress
46
    || req.socket.remoteAddress
47
    || req.connection.socket.remoteAddress;
48
49
  // Emit WebSocket event.
50
  if (req.headers['content-type'] === 'application/json') {
51
    // Socket.io rooms disabled here because rooms provide restricted behavior,
52
    // for example: it is impossible to open in one browser two or three different streams (rooms).
53
    global.socket.emit('log', {
54
      streamId: req.params.streamId, format: 'json', data: req.body, ip,
55
    });
56
  }
57
58
  // No need to provide any payload, just empty body and success status code.
59
  res.status(204);
60
  res.send('');
61
});
62
63
module.exports = router;
64