Total Complexity | 2 |
Complexity/F | 1 |
Lines of Code | 47 |
Function Count | 2 |
Duplicated Lines | 0 |
Ratio | 0 % |
Coverage | 11.11% |
Changes | 10 | ||
Bugs | 0 | Features | 0 |
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 |