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


        else
            views = res.views
            views[params.req_name] = body
            db.merge "_design/#{params.type}", {views:views}, (err, res) ->
                if err
                    console.log "[Definition] err: " + JSON.stringify err

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