src/dispatcher.js
function createStacks (state) {
  const serviceErrors = state.config.service.errors || {}
  _.each(state.resources, function (resource) {
    const resourceErrors = resource.errors
    _.each(resource.actions, function (action, actionName) {
      action.name = actionName
      const actionErrors = action.errors
      var transform
      const key = [ resource.name, action.name ].join('!')

      if (state.config.middlewareStack) {
        const middleware = getStack(state, state.config.middlewareStack, resource, action)
        state.handlers[ middleware.name ] = middleware
      }
      if (state.config.transformStack) {
        transform = getStack(state, state.config.transformStack, resource, action)
      } else {
        transform = state.snap.stack(key)
      }
      transform.append(unit)
      state.transforms[ transform.name ] = transform
      const errors = Object.assign({}, serviceErrors, resourceErrors, actionErrors)
      state.errors[ key ] = handleError.bind(null, state, errors)
    })
  })
}
function createStacks (state) {
  const serviceErrors = state.config.service.errors || {}
  _.each(state.resources, function (resource) {
    const resourceErrors = resource.errors
    _.each(resource.actions, function (action, actionName) {
      action.name = actionName
      const actionErrors = action.errors
      var transform
      const key = [ resource.name, action.name ].join('!')

      if (state.config.middlewareStack) {
        const middleware = getStack(state, state.config.middlewareStack, resource, action)
        state.handlers[ middleware.name ] = middleware
      }
      if (state.config.transformStack) {
        transform = getStack(state, state.config.transformStack, resource, action)
      } else {
        transform = state.snap.stack(key)
      }
      transform.append(unit)
      state.transforms[ transform.name ] = transform
      const errors = Object.assign({}, serviceErrors, resourceErrors, actionErrors)
      state.errors[ key ] = handleError.bind(null, state, errors)
    })
  })
}
function createStacks ( state ) { const serviceErrors = state . config . service . errors || { } _ . each ( state . resources , function ( resource ) { const resourceErrors = resource . errors _ . each ( resource . actions , function ( action , actionName ) { action . name = actionName const actionErrors = action . errors var transform const key = [ resource . name , action . name ] . join ( '!' ) if ( state . config . middlewareStack ) { const middleware = getStack ( state , state . config . middlewareStack , resource , action ) state . handlers [ middleware . name ] = middleware } if ( state . config . transformStack ) { transform = getStack ( state , state . config . transformStack , resource , action ) } else { transform = state . snap . stack ( key ) } transform . append ( unit ) state . transforms [ transform . name ] = transform const errors = Object . assign ( { } , serviceErrors , resourceErrors , actionErrors ) state . errors [ key ] = handleError . bind ( null , state , errors ) } ) } ) }
iterate over all resources and actions and create the middleware and transform stacks for each resource!action pair
iterate over all resources and actions and create the middleware and transform stacks for each resource!action pair