Completed
Push — master ( a0dc3e...1ff52f )
by Magnus
04:45
created

app.js   A

Complexity

Total Complexity 2
Complexity/F 1

Size

Lines of Code 47
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Test Coverage

Coverage 11.11%

Importance

Changes 10
Bugs 0 Features 0
Metric Value
cc 0
wmc 2
c 10
b 0
f 0
nc 4
mnd 0
bc 2
fnc 2
dl 0
loc 47
rs 10
bpm 1
cpm 1
noi 0
ccs 3
cts 27
cp 0.1111
crap 0

2 Functions

Rating   Name   Duplication   Size   Complexity  
A app.use 0 7 1
A ➔ ??? 0 4 1
1
"use strict";
2
3
const express = require('express');
4
const routes = require('./routes');
5
const http = require('http');
6
const errorHandler = require('errorhandler');
7
const logger = require('morgan');
8
9
const app = express();
10
const server = http.createServer(app);
11
12 2
const dsn =  process.env.DBWEBB_DSN || "mongodb://localhost:27017/mumin";
13
14
const socket = require('./src/socket');
15
16
socket.socket(server);
17
18
// all environments
19 2
app.set('port', process.env.DBWEBB_PORT || 3000);
20
app.use(logger('dev'));
21
22
// development only
23 2
'development' == app.get('env') && app.use(errorHandler());
24
25
app.locals.something = 'value';
26
app.locals.qaz = 'qut';
27
28
app.get('/', routes.index);
29
app.get('/posts/:id', routes.posts);
30
app.get('/db/getAll', routes.dbGetAll);
31
app.get('/db/insert/:ob', routes.dbInsert);
32
33
34
app.use(function(req, res, next) {
35
    let err = new Error('Not Found');
36
37
    err.status = 404;
38
    next(err);
39
    res.json({'error': 'error'});
40
});
41
42
server.listen(app.get('port'), () => {
43
    console.info('Express server listening on port ' + app.get('port'));
44
    console.info('DNS is ' + dsn);
45
});
46
47
module.exports = app;
48