-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.js
36 lines (30 loc) · 1.09 KB
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const express = require('express');
const bodyParser = require('body-parser');
const cors = require('cors');
const swaggerUi = require('swagger-ui-express')
const swaggerFile = require('./swagger_output.json')
const {connectToDb} = require('./db/db');
require('dotenv').config();
// init app
var app = express();
app.use(cors());
// db connection
connectToDb((err) => {
if (!err) {
let server = app.listen(process.env.port || 8080, function () {
let host = server.address().address
let port = server.address().port
console.log("River Visualizator app listening at http://%s:%s", host, port)
})
}
})
// convert to json
app.use(bodyParser.json({limit: '200mb'}));
// routers
app.use('/river', require("./router/river"));
app.use('/device', require("./router/device"));
app.use('/measurement', require("./router/measurement"));
app.use('/interpolate', require("./router/interpolate"));
app.use('/river-catalog', require("./router/rivercatalog").router);
app.use('/login', require("./router/login"));
app.use('/doc', swaggerUi.serve, swaggerUi.setup(swaggerFile))