@AppKu/StashKu

@AppKu/StashKu

v1.0.46

Class

FetchEngine

Extends

This StashKu engine is built-in and provides an engine to make requests to HTTP endpoints using fetch. Requests correspond to their HTTP request method.

Constructor

new FetchEngine()

Creates a new FetchEngine instance.

Source

Members

Methods

async

delete(request) → {Promise.<module:response~Response>}

Parameters

  • request DeleteRequest

    The DELETE request to send to the storage engine.

Returns

  • Promise.<module:response~Response>

    Returns the data objects from storage that were deleted with the request criteria.

Source

async

get(request) → {Promise.<module:response~Response>}

Parameters

  • request GetRequest

    The GET request to send to the storage engine.

Returns

  • Promise.<module:response~Response>

    Returns the data objects from storage matching request criteria.

Source

async

options(request) → {Promise.<module:response~Response>}

Parameters

  • request OptionsRequest

    The OPTIONS request to send to the storage engine.

Returns

  • Promise.<module:response~Response>

    Returns a response with a single data object- the dynamically created model configuration.

Source

async

patch(request) → {Promise.<module:response~Response>}

Parameters

  • request PatchRequest

    The PATCH request to send to the storage engine.

Returns

  • Promise.<module:response~Response>

    Returns a response with the total number of the objects affected in storage. No data objects are typically returned with this request.

Source

async

post(request) → {Promise.<module:response~Response>}

Parameters

  • request PostRequest

    The POST request to send to the storage engine.

Returns

  • Promise.<module:response~Response>

    Returns the data objects from storage that were created with the request criteria.

Source

async

put(request) → {Promise.<module:response~Response>}

Parameters

  • request PutRequest

    The PUT request to send to the storage engine.

Returns

  • Promise.<module:response~Response>

    Returns the data objects from storage that were updated with the request criteria. This may not exactly match the objects requested to be updated, as some may have been deleted from storage or some may not match the key criteria.

Source

Type Definitions

Configuration

Properties

  • root String <optional>

    The root URI of each fetch request. If specified, will be prefixed to each resource.

  • path String <optional>
    "/api"

    The path to the URI endpoint. This is prefixed before each resource, but after the root (if specified).

  • trailingSlash Boolean <optional>
    false

    Sets whether a slash will be added at the end of the generated URI.

  • omitResource Boolean <optional>
    false

    Omits to and from properties and values from the request payload sent over fetch. This may help force endpoints to ensure the resource is determined on their end instead of by the requestor.

  • model FetchEngine <optional>
  • fetch RequestInit <optional>

    Optional fetch defaults to apply before request-specific configuration is set.

Source

ModelConfiguration

Properties

  • pathProperty String <optional>
    "resource"

    Instructs StashKu which property from the $stashku object on a model type to populate the resource (to or from) on a request. Can be "name", "slug", "plural.name", "plural.slug", or "resource" (default).

  • header Boolean <optional>
    false

    Determines whether the fetch request to the HTTP endpoint will include the model header when STASHKU_MODEL_HEADER is enabled. By default this is disabled and the header model property will not be sent. Setting this flag to true will forward the model header of the StashKu request.

Source