-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
34 lines (25 loc) · 944 Bytes
/
index.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
// Created by Sinisa Drpa on 02/18/18.
const express = require('express')
const cors = require('cors') // https://github.com/expressjs/cors
const bodyParser = require('body-parser')
const config = require('./config')
const verifyToken = require('./server/middleware/verifyToken')
const Monitor = require('./server/modules/monitor')
const Auth = require('./server/routes/auth')
const auth = new Auth()
const Status = require('./server/routes/status')
const stat = new Status()
const app = express()
app.use(bodyParser.urlencoded({ extended: false }))
app.use(bodyParser.json())
// Static
app.use(express.static('./server/static/'))
app.use(express.static('./client/dist/'))
// Routes
app.use('/auth', cors(), auth.authenticate)
app.use('/status', cors(), verifyToken, stat.get)
const monitor = new Monitor()
const serverPort = 3000
app.listen(serverPort, () => {
console.log('Server is running on http://localhost:' + serverPort);
})