Stef
02/12/2018, 10:08 PMStef
02/12/2018, 10:09 PM@google-cloud/pubsub
);
const pubsub = new PubSub();
const topicName = ‘report-creation’;
const cors = require(“cors”)();
exports.requestReport = (req, res) => {
cors(req, res, () => {
const data = JSON.stringify(req.body.data);
const dataBuffer = Buffer.from(data);
pubsub
.topic(topicName)
.publisher()
.publish(dataBuffer)
.then(results => {
const messageId = results[0];
console.log(Message ${messageId} published.
);
res.send(messageId)
})
.catch(err => {
console.error(‘ERROR:’, err);
res.send(err)
});
})
}Kevin S
02/12/2018, 10:14 PMKevin S
02/12/2018, 10:14 PMKevin S
02/12/2018, 10:14 PMKevin S
02/12/2018, 10:14 PMStef
02/12/2018, 10:15 PMStef
02/12/2018, 10:17 PMnilan
02/12/2018, 10:27 PMnilan
02/12/2018, 10:27 PMKevin S
02/12/2018, 11:50 PMKevin S
02/12/2018, 11:50 PMKevin S
02/12/2018, 11:50 PMKevin S
02/12/2018, 11:51 PMKevin S
02/12/2018, 11:54 PM