Skip to content

Instantly share code, notes, and snippets.

@tommedema
Created May 6, 2012 11:09
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 tommedema/2621673 to your computer and use it in GitHub Desktop.
Save tommedema/2621673 to your computer and use it in GitHub Desktop.

All application logic is defined using routines. Routines are loaded on runtime and are passed a global event emitter instance, called the mediator.

##Example The following describes an application example structure.

Application objective: create a http server and serve a RESTful API (serves current music stations and the current songs for each station).

###File tree

  • src/ (contains source files)

    • bootstrap.js (initializes the application and loads routines)

    • config.js (contains environment-dependent project config, used by routines)

    • routines/ (the application logic routines loaded on runtime)

      • debug/ (outputs debug information to stdout)

        • server.js (outputs server debug information by listening to server events)
        • boot.js (outputs boot debug)
      • music/ (contains music related routines)

        • stations/ (stations related routines)
          • server.js (servers stations on request)
          • pop/ (the pop station)
          • -----> queue.js (holds the song queue for this station and serves it on request)
          • -----> creator.js (creates the pop station and emits its existence event)
          • -----> discjockey.js (periodically searches for new songs to be picked up by the queue)
      • server/ (contains server related routines)

        • creator.js (creates the http server on boot)
        • configurer.js (configures the http server when created)
        • runner.js (runs the http server when configured)
        • routes/ (defines RESTful routes)
          • stations.js (answers /api/stations)
          • songs.js (answers /api/songs/station+name)
    • definitions/ (contains shared object definitions, used by routines)

      • station.js (defines what a station is, eg. name, nr of listeners, current song)
      • song.js (defines what a song is, eg. artist name, title and thumbnail url)
    • util/ (contains shared utility modules, used by routines)

      • moduleloading.js (contains module loading utilities)
  • test/ (contains unit tests)

  • node_modules/ (contains general node modules, used by routines and utils)

  • Makefile (contains project commands such as test and deploy)

  • package.json (contains project information and dependencies)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment