-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
48 lines (39 loc) · 1.06 KB
/
app.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
43
44
45
46
47
48
const express = require('express')
const dotenv = require('dotenv')
const app = express()
const nunjucks = require('nunjucks')
const request = require('request')
const compression = require('compression')
const sockJs = require('sockjs-client-node')
const Stomp = require('stompjs')
const api = {
url: new sockJs('https://app.jouliette.net/stomp/'),
client: null,
init: function() {
this.client = Stomp.over(this.url)
this.client.connect('web', 'mnwdTGgQu5zPmSrz', this.onConnect)
},
onConnect: function() {
api.client.subscribe('/exchange/aquaponics/deceuvel', api.handleData)
},
handleData: function(d) {
console.log(JSON.parse(d.body))
}
}
api.init()
dotenv.config()
app.use(compression())
app.use(express.static(`${__dirname}/assets`))
nunjucks.configure('views', {
autoescape: true,
express: app
})
app.get('/', (req, res) => {
res.render('index.html', {})
})
app.get('/aquaponics', (req, res) => {
res.render('aquaponics.html', {})
})
app.listen(process.env.PORT, () => {
console.log('Listening.. port ' + process.env.PORT)
})