Skip to content

Instantly share code, notes, and snippets.

@Kennypee Kennypee/server.js
Created Jul 6, 2018

Embed
What would you like to do?
const Pusher = require('pusher');
const express = require('express');
const bodyParser = require('body-parser');
const cors = require('cors');
const app = express();
app.use(cors());
app.use(bodyParser.urlencoded({extended: false}));
app.use(bodyParser.json());
var pusher = new Pusher({
appId: 'use-your-own-Id',
key: 'use-your-own-key',
secret: 'use-your-own-secret',
cluster: 'eu',
encrypted: true
});
app.set('PORT', process.env.PORT || 6000);
app.post('/message', (req, res) => {
const message = req.body;
pusher.trigger('chat', 'message', message);
res.send(message)
});
app.listen(app.get('PORT'), () =>
console.log('Listening at ' + app.get('PORT')))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.