public
Created

This is a short example file of how an express app and socket.io work together with the CRUDS module.

  • Download Gist
express app with CRUDS
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.