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.

src/back/routes/index.js   A
last analyzed

Complexity

Total Complexity 4
Complexity/F 1.33

Size

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