routes/week.js   A
last analyzed

Complexity

Total Complexity 3
Complexity/F 1

Size

Lines of Code 33
Function Count 3

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 17
mnd 0
bc 0
fnc 3
dl 0
loc 33
rs 10
bpm 0
cpm 1
noi 2
c 0
b 0
f 0
1
var express = require('express');
2
var router = express.Router();
3
const sqlite3 = require('sqlite3').verbose();
0 ignored issues
show
Unused Code introduced by
The constant sqlite3 seems to be never used. Consider removing it.
Loading history...
4
// const db = new sqlite3.Database('./db/texts.sqlite');
5
const db = require("../db/database.js");
6
7
router.get('/', function(req, res, next) {
0 ignored issues
show
Unused Code introduced by
The parameter next is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
8
    const data = {
9
        data: {
10
            msg:  "No week given"
11
        }
12
    };
13
14
    res.json(data);
15
});
16
17
router.get("/:msg", (req, res) => {
18
    db.each("SELECT week, text FROM reports WHERE week = " + req.params.msg, function(err, row) {
19
        // console.log(row.week + ": " + row.text);
20
        const data = {
21
            data: {
22
                week: row.week,
23
                text: row.text
24
            }
25
        };
26
27
        res.json(data);
28
    });
29
30
31
});
32
33
module.exports = router;
34