@metreeca/gate - v0.12.0
    Preparing search index...

    Type Alias Driver

    Driver: RequestHandler & {
        lookup(hooks?: LookupHooks): Driver;
        create(hooks?: WriteHooks): Driver;
        update(hooks?: WriteHooks): Driver;
        delete(): Driver;
    }

    Model-driven resource driver.

    Serves a resource through the HTTP methods enabled on it: its retrieval, the creation of new resources in the collection it holds, its replacement and its removal, so that one driver serves containers, items and standalone resources alike, each enabling only the methods its role in the API calls for and answering others with 405.

    Type Declaration

    • lookup: function
      • Enables GET and HEAD, retrieving the resource.

        The query component of the request selects what to retrieve. It may state a @metreeca/qest template, or form-encoded criteria filtering the collection the resource holds, as a client filtering a list would state them. An empty query retrieves the default view the shape describes. Localised content is negotiated through the Accept-Language header, and the store default applies where none is given.

        • 200 OK with the resource as JSON
        • 404 Not Found where the store holds no such resource, or the review hook withholds it

        Parameters

        • Optionalhooks: LookupHooks

          Retrieval hooks; if omitted, the request is bounded by the shape alone

        Returns Driver

        This driver

    • create: function
      • Enables POST, creating a resource from the request body in the collection the resource holds.

        The body is validated against the shape of the collected resources. A body stating no identifier is named after the Slug header, or given a generated name where the header is missing or holds no letter or digit.

        • 201 Created with a Location header pointing to the new resource
        • 409 Conflict where the store refuses to create the resource, as when its identifier is taken

        Parameters

        Returns Driver

        This driver

        TypeError Where the shape holds no collection ranging over resources, or several

    • update: function
      • Enables PUT, replacing the resource with the request body, validated against the shape.

        The resource keeps the identifier of the request target, so a client cannot redirect the update elsewhere.

        • 204 No Content where the resource is replaced
        • 404 Not Found where the store holds no such resource

        Parameters

        Returns Driver

        This driver

    • delete: function
      • Enables DELETE, removing the resource along with the embedded and captive data the shape ties to it.

        • 204 No Content where the resource is removed
        • 404 Not Found where the store holds no such resource

        Returns Driver

        This driver