changes
This commit is contained in:
Родитель
04537f4223
Коммит
a7f166a413
|
@ -1,44 +1,40 @@
|
|||
let faye = require('faye');
|
||||
var pg = require('pg');
|
||||
let express = require('express');
|
||||
let app = express();
|
||||
let server = require('http').Server(app);
|
||||
let notification = require('./modules/notification');
|
||||
let faye = require('faye'),
|
||||
pg = require('pg'),
|
||||
express = require('express'),
|
||||
app = express(),
|
||||
server = require('http').Server(app),
|
||||
notification = require('./modules/notification'),
|
||||
salesforce = require('./modules/salesforce');
|
||||
|
||||
app.use(express.static('www'));
|
||||
app.use(express.static(path.join('www', 'build')));
|
||||
app.use(bodyParser.json());
|
||||
|
||||
let client = new pg.Client(process.env.DATABASE_URL);
|
||||
client.connect();
|
||||
|
||||
app.get('/property', (req, res) => {
|
||||
client.query('SELECT * FROM Property__c', (error, data) => {
|
||||
res.json(data.rows);
|
||||
res.json(data.rows);
|
||||
});
|
||||
});
|
||||
|
||||
app.get('/property/:id', (req, res) => {
|
||||
client.query('SELECT * FROM Property__c WHERE ID=$1', [req.params.sfid], (error, data) => {
|
||||
res.json(data.rows);
|
||||
res.json(data.rows);
|
||||
});
|
||||
});
|
||||
|
||||
// Subscribe to Platform Event
|
||||
let subscribeToPlatformEvents = () => {
|
||||
let client = new faye.Client(org.oauth.instance_url + '/cometd/42.0/');
|
||||
client.setHeader('Authorization', 'OAuth ' + org.oauth.access_token);
|
||||
client.subscribe('/event/Price_Change_Event__e', function(message) {
|
||||
notification.push(message);
|
||||
});
|
||||
};
|
||||
|
||||
let bayeux = new faye.NodeAdapter({mount: '/faye', timeout: 45});
|
||||
let bayeux = new faye.NodeAdapter({ mount: '/faye', timeout: 45 });
|
||||
bayeux.attach(server);
|
||||
bayeux.on('disconnect', function(clientId) {
|
||||
bayeux.on('disconnect', function (clientId) {
|
||||
console.log('Bayeux server disconnect');
|
||||
});
|
||||
|
||||
let PORT = process.env.PORT || 5000;
|
||||
saleforce.authenticate().then((oauth) => {
|
||||
let client = new faye.Client(oauth.instance_url + '/cometd/42.0/');
|
||||
client.setHeader('Authorization', 'OAuth ' + oauth.access_token);
|
||||
client.subscribe('/event/Price_Change_Event__e', function (message) {
|
||||
notification.push(message);
|
||||
});
|
||||
});
|
||||
|
||||
server.listen(PORT, () => console.log(`Express server listening on ${ PORT }`));
|
||||
server.listen(PORT, () => console.log(`Express server listening on ${process.env.PORT}`));
|
Загрузка…
Ссылка в новой задаче