effortlessness, et al.


effortlessness, serverside et al.

$ npm install et

This example uses jugglingdb as a resource to provide schema based database access

module.exports = 
    config: (opts) -> 
        # config() is called when the server starts up 
        # to allow for things like schema definitions 
        opts.resource.database1.define 'things'
            id: Number
            name: String
            location: String
    get: (req, res) ->
        # The presence of a get() method here causes the  
        # automatic creation of the rest endpoint '/things/:id'  
        Thing =
        Thing.find, data, arg3) -> 
            # apologies, have not looked into what args1&3 are... 
            res.send data
    # although called a model, this is more precisely a combination 
    # of model and controller 
    #   ie. a "controdel" 
et      = require('et')
Schema  = require('jugglingdb').Schema
server  =
    port: 3001
        # resources become available in the models 
        # (see above) 
        database1: new Schema 'postgres'
            host: '',
            database: 'dbname',
            username: 'dbuser',
            password: 'passrod'
        # link '' as a 'model' 
        things: require './thing'
            # key (above) must match last path element (below) 
            path: __dirname + '/nested/path/to/scripts'
$ coffee server
$ curl http://localhost:3001/things/1
    "id": 1
    "name": "Venus of Hohle Fels"
    "location": "Schelklingen, Germany"
  • TODO Added post() to enable http POST endpoints
  • TODO Configurables for redis session store (eg. redis:hostname:port:password)
  • Added middleware config opts.before and opts.use callbacks
  • Added use of env vars APP_NAME, APP_VERSION, APP_PORT, APP_LOGLEVEL (if present)
  • Added use of restify app name and version
  • Added overideable request logger, first into the connect stack
  • Added configurable bunyan logger
  • Added auto serve static assets from `opts.static.key.path (if present)
  • Added auto spawn a restify server if no provided
  • opts ) returns the running server
  • Switched specs to mocha
  • Added call to model.config (if present), to configure resources at startup
  • Added opts.resource available at startup and on req._et.resource
  • Added basic local auth using passport
  • Added basic redis session using connect.session (very defaulty! See TODO in src/session)
  • Added all encompasser
  • Added support for http GET to et
  • Transparently plugin to express' routing