-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
34 lines (26 loc) · 835 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
const express = require('express')
const app = express()
const bodyParser = require('body-parser')
const mongoose = require('mongoose')
const path = require('path')
const morgan = require('morgan')
const authController = require('./controllers/auth')
const runController = require('./controllers/runner')
const port = process.env.PORT || 3750;
const indexPath = path.resolve(__dirname, 'public')
app.use(morgan('dev'))
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({
extended: true
}))
app.use(express.static(indexPath))
mongoose.connect(process.env.MONGODB_URI || process.env.MONGOLAB_URI)
app.get('/auth', authController)
app.post('/command', runController)
app.get('/', function(req, res) {
res.sendFile(indexPath)
})
app.listen(port, function() {
console.log('listening on', port)
})
module.exports = app;