     return request
 
   validate_resource: (resource, args) ->
-    return resource in @resources
+    return _.find @resources, (str) -> resource.indexOf(str) is 0
 
   get: (resource, args, callback) ->
     return callback null, 'error', null unless @validate_resource resource, args

          key: value
        return new FeedlyNode name, @path, 'leaf', json

###
        # item 2+, details
        _console.debug """
        [Josh.FeedlyConsole]
        not implemented, path: %s, name %s""", path, name
        get "streams/"
        callback null
###

class RootFeedlyNode extends FeedlyNode
  constructor: () ->


  @call_api_by_path: (path, callback) ->
    parts = path.split('/')
    _console.debug "[feedlyconsole:FeedlyNode.call_api_by_path]
 depth %i, %O.", parts.length, parts
    if parts.length is 2 # [ "", "profile" ]
      @_api().get _.last(parts), [], (response, status) ->
        callback(response, status)
    else # [ "", "categories", "blackberry" ]
      # get parent node
      parent_path = parts[0...-1].join '/'
      name = _.last parts
      @getNode parent_path, (parent) =>
        _console.debug "[feedlyconsole:FeedlyNode.call_api_by_path]
 parent %O @ %s.", parent, parent_path
        id = encodeURIComponent parent.getChildId(name)
        @_api().get "streams/#{id}/contents", [], (response, status) ->
          callback(response, status)

  @getChildNodes: (node, callback) =>
    @_initRootNode()
    node.getChildNodes callback

  call_api_by_path: ->
    FeedlyNode.call_api_by_path @path, (json, status) ->
      @json_data = json

  # match title or label to get id
  getChildId: (name) ->
    @call_api_by_path unless @json_data?
    if _.isArray(@json_data)
      item = _.find @json_data, (item) ->
        _.find ['title', 'label', 'id'], (field) ->
          item[field] is name
      return item.id if item?
    return null

  getChildNodes: (callback) ->
    if @type is 'leaf'
      @children = null
    else
      @call_api_by_path unless @json_data?
      @children ?= @makeJSONNodes()
    return callback @children

  makeJSONNodes: (json) ->
    json ?= @json_data
    if _.isArray(json)
      nodes = _.map json, (item) =>
        name = item.title or item.label or item.id
        path = [@path, name].join '/'
        type = if 'id' of item then 'node' else 'leaf'
        json = if 'id' of item then null else item
        return new FeedlyNode name, path, type, json
      return nodes
    else
      # its a map, so all children are leaves
      _.map json, (value, key) =>
        name = [
          key
          value
