Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/starfx/mdw/query.ts

A micro-mvc framework for react apps
Go to Latest
import * as starfx from "https://deno.land/x/starfx@v0.13.2/mdw/query.ts";

Functions

This middleware will take the result of ctx.actions and dispatch them as a single batch.

This middleware allows the user to override the default key provided to every pipeline function and instead use whatever they want.

This middleware will catch any errors in the pipeline and console.error the context object.

This middleware is a composition of other middleware required to use window.fetch https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API with createApi

This middleware will retry failed Fetch request if response.ok is false. It accepts a backoff function to determine how long to continue retrying. The default is an exponential backoff backoffExp where the minimum is 1sec between attempts and it'll reach 4s between attempts at the end with a max of 5 attempts.

Automatically sets content-type to application/json when that header is not already present.

This middleware takes the ctx.response and sets ctx.json to the body representation requested. It uses the ctx.bodyType property to determine how to represent the body. The default is set to json which calls Response.json().

This middleware converts the name provided to createApi into url and method for the fetch request.

If there's a slug inside the ctx.name (which is the URL segement in this case) and there is not a corresponding truthy value in the payload, then that means the user has an empty value (e.g. empty string) which means we want to abort the fetch request.

This middleware will add performance.now() before and after your middleware pipeline.

This middleware will only be activated if predicate is true.

This middleware sets up the context object with some values that are necessary for createApi to work properly.