 # PUT /request/:type/:req_name
 action 'definition', ->
     # no need to precise language because it's javascript
-    db.get "_design/#{params.type}", (err, res) ->
+    db.get "_design/#{params.type}", (err, res) =>
 
         if err && err.error is 'not_found'
             design_doc = {}

        # db.view seems to alter the options object
        # cloning the object before each query prevents that
        query = JSON.parse JSON.stringify body
        db.view "#{params.type}/#{params.req_name}", query, (err, res) ->
            if err
                send error: "not found", 404
            else

before 'permissions', ->
    auth = req.header('authorization')
    checkDocType auth, params.type, (err, appName, isAuthorized) =>
        @appName = appName
        compound.app.feed.publish 'usage.application', appName
        next()

