Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@ksnabb
Created August 2, 2013 19:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ksnabb/6142680 to your computer and use it in GitHub Desktop.
Save ksnabb/6142680 to your computer and use it in GitHub Desktop.
This is a short example file of how an express app and socket.io work together with the CRUDS module.
express = require("express")
app = express()
# app configuration etc...
server = http.createServer(app)
server.listen app.get("port"), ->
console.log "Express server listening on port " + app.get("port")
# REST API and socket.io interface
socketio = require 'socket.io'
io = socketio.listen server
cruds = require("./cruds/lib/cruds")()
cruds.set "Entity", io # only websocket API
cruds.set "Entity2", app # only REST API
cruds.set "Entity3", app, io # both websocket and REST API
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment