forked from pebsconsulting/pusher-realtime-jquery-datatable
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
26 lines (21 loc) · 588 Bytes
/
server.js
File metadata and controls
26 lines (21 loc) · 588 Bytes
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
const express = require('express');
const bodyParser = require('body-parser')
const Pusher = require('pusher')
const cors = require('cors')
const app = express();
app.use(cors())
app.use(bodyParser.urlencoded({ extended: false }))
app.use(bodyParser.json())
const pusher = new Pusher({
appId: 'APP ID',
key: 'APP KEY',
secret: 'SECRET',
cluster: 'CLUSTER',
encrypted: true
});
app.post('/record', (req, res) => {
console.log(req.body);
pusher.trigger('records', 'new-record', req.body);
res.send('Pushed');
})
app.listen(2000, () => console.log('Listening at 2000'));