-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
42 lines (33 loc) · 966 Bytes
/
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
38
39
40
41
42
const express = require('express')
const cors = require('cors')
const os = require('os')
// Start Application
class App {
constructor () {
this.express = express()
this.http = require('http').createServer(this.express)
this.io = require('socket.io')(this.http)
}
init () {
this.express.use(express.json())
this.express.use(cors())
this.express.use((req, res, next) => {
this.express.set('io', this.io)
next()
})
this.express.use('/api', require('./src/routes'))
require('./src/realtime/Main').init(this.io)
this.http.listen(3080, () => {
console.log('# Vetor TODO-API iniciada!')
let interfaces = os.networkInterfaces()
Object.keys(interfaces).forEach(function(key) {
let name = interfaces[key]
if (key === 'Wi-Fi' || key === 'Ethernet') {
console.log(`\tIP: ${name[1].address}`)
console.log(`\tExecutando em http://${name[1].address}:3080/api/tasks`)
}
})
})
}
}
module.exports = new App()