 
 Config      = require '../common/config'
 
+# The REST API request the database.
 class Api
     constructor     : () ->
         @app            = do Express

            catch e
                res.send 400

    updateOrCreate  : (model, req, res) =>
        if not req.body.id or req.body.id is req.params.id
            obj = new @models[model] req.body

                @models[name]   = @db.define name, ModelDef
                AfterModelDef @models[name]

    # Initialize REST API context.
    configure       : () =>
        @app.set 'port', Config.Restapi.Port
        @app.use Express.logger 'dev'
