             statusCode: 404
             body: {status: "fail", message: "Unable to retrieve items from collection"}
     deleteAll: (collection) ->
-      delete: ->
-        itemsRemoved = collection.remove()
-        if itemsRemoved
-          {status: "success", data: message: "Removed #{itemsRemoved} items"}
-        else
-          statusCode: 404
-          body: {status: "fail", message: "No items found"}
+      delete:
+        action: ->
+          itemsRemoved = collection.remove()
+          if itemsRemoved
+            {status: "success", data: message: "Removed #{itemsRemoved} items"}
+          else
+            statusCode: 404
+            body: {status: "fail", message: "No items found"}
 
 
   ###

    else
      collection = new Mongo.Collection name

    # Get the path or use name as default
    path = options.path or name

    # Get the endpoints and any global options
    requestedEndpoints = options.endpoints
    endpointOptions = options.endpointOptions or {}

    # Separate the requested endpoints by the route they belong to (one for operating on the entire collection and one
    # for operating on a single entity within the collection)
    collectionEndpoints = {}
    entityEndpoints = {}
    if requestedEndpoints
      console.log requestedEndpoints
      console.log "Setting up a #{method} endpoint at #{path} with options #{endpointOptions.toString()}"
    else
      _.each methods, (method) ->
        if method in methodsOnCollection
          _.extend collectionEndpoints, @_collectionEndpoints[method](collection)
        else _.extend entityEndpoints, @_collectionEndpoints[method](collection)
        return
      , this

    # Add the routes to the API
    @add path, endpointOptions, collectionEndpoints
    @add "#{path}/:id", endpointOptions, entityEndpoints

    return


            statusCode: 404
            body: {status: "fail", message: "Item not found"}
    put: (collection) ->
      put:
        action: ->
          entityIsUpdated = collection.update @urlParams.id, @bodyParams
          if entityIsUpdated
            entity = collection.findOne @urlParams.id
            {status: "success", data: entity}
          else
            statusCode: 404
            body: {status: "fail", message: "Item not found"}
    delete: (collection) ->
      delete:
        action: ->
          if collection.remove @urlParams.id
            {status: "success", data: message: "Item removed"}
          else
            statusCode: 404
            body: {status: "fail", message: "Item not found"}
    post: (collection) ->
      post:
        action: ->
          entityId = collection.insert @bodyParams
          entity = collection.findOne entityId
          if entity
            {status: "success", data: entity}
          else
            statusCode: 400
            {status: "fail", message: "No item added"}
    getAll: (collection) ->
      get:
        action: ->
