Last active
July 29, 2019 09:02
-
-
Save maxmckenzie/a67197860fbc2e40bd2a8e52b4bebbea to your computer and use it in GitHub Desktop.
basic bare minimum express server #express
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import express from 'express'; | |
import http from 'http' | |
/** | |
* Express Set Up | |
*/ | |
const app = express() | |
app.set('view engine', 'pug') | |
app.use('/assets', express.static('assets')); | |
const server = http.createServer(app); | |
const io = require('socket.io').listen(server); | |
server.listen(5050); | |
io.on('connection', function (socket) { | |
socket.emit('news', { hello: 'world' }); | |
socket.on('my other event', function (data) { | |
console.log(data); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment