-
Notifications
You must be signed in to change notification settings - Fork 4
/
server.js
37 lines (30 loc) · 1.08 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
37
const express = require("express")
const bodyParser = require("body-parser")
const favicon = require("serve-favicon")
const WebSocket = require("ws")
const methodOverride = require("method-override")
const cors = require("cors")
const app = express()
express.Router()
const http = require("http")
const mqtt = require("./src/back/controllers/mqtt")
const Controller = require("./src/back/controllers/controller")
app.use(cors())
app.use(bodyParser.urlencoded({ extended: false }))
app.use(bodyParser.json())
app.use(methodOverride())
app.use(express.static(__dirname + "/"))
app.use(favicon(__dirname + "/src/front/assets/favicon.png"))
const PORT = 8082
const server = http.Server(app)
const wss = new WebSocket.Server({ server })
server.listen(PORT, () =>
console.log(`Server started on http://localhost:${PORT}`)
)
new Controller(wss)
// mqtt(webSocketServer).then(mqttClient => {
// require('./src/back/controllers/socket')(mqttClient, io)
// require('./src/back/controllers/scenario')(mqttClient, io)
// })
// Drop & create tables in DB
//require('./src/back/models/createDatabase')