Testing coffeescript in nodejs

This commit is contained in:
Jörn-Michael Miehe 2018-10-04 00:07:17 +02:00
parent dbe2dd5238
commit 68c63563ef
2 changed files with 40 additions and 0 deletions

View file

@ -11,6 +11,7 @@
"express": "^4.16.1",
"helmet": "*",
"socket.io": "^2.1.1",
"coffeescript": "*",
"merge-stream": "*",
"gulp": "*",
"gulp-sourcemaps": "*",

View file

@ -0,0 +1,39 @@
# libraries
http = require 'http'
socketio = require 'socket.io'
express = require 'express'
gulp = global.gulp = require 'gulp'
helmet = require 'helmet'
# gulp the sources
require './gulpfile'
gulp.start 'default'
# socket.io framework
app = express()
web = http.Server app
io = socketio web
# Listen server
web.listen 8080, ->
console.log 'Node.js listening on port 8080'
app.use helmet()
# Static content
app.use ( express.static __dirname + '/../static' )
# Server logic
io.on 'connection', (socket) ->
console.log 'a user connected'
console.log socket.id
socket.on 'disconnect', ->
# console.log 'user disconnected'
return
socket.on 'login', ->
console.log 'message:', msg.uname, msg.password
return
return