Skip to content

Instantly share code, notes, and snippets.

@mikekunze
Created August 24, 2013 15:34
Show Gist options
  • Save mikekunze/6328781 to your computer and use it in GitHub Desktop.
Save mikekunze/6328781 to your computer and use it in GitHub Desktop.
This is a skel for containing your Express code when it is desired to isolate app routes and websockets in classical inheritance, while potentially sharing crucial web server information such as a user session and login information.
moduleKeywords = ['included', 'extended']
class SuperClass
@include: (obj) ->
throw('include(obj) requires obj') unless obj
for key, value of obj.prototype when key not in moduleKeywords
@::[key] = value
included = obj.included
included.apply(this) if included
@
class Controller
constructor: ()->
@hasController = true
class Events
constructor: ()->
@hasEvents = true
class Web extends SuperClass
@include Controller
@include Events
constructor: ()->
Controller.call @
Events.call @
module.exports = Web
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment