Skip to main content

Functions

withMiddleware

function withMiddleware(middlewares: RequestMiddleware[]): RequestMiddleware
Setup a execution chain of middleware functions.
ParameterTypeDescription
middlewaresRequestMiddleware[]one or more middleware functions.
Returns: RequestMiddleware

withProxy

function withProxy(config: RequestProxyConfig): RequestMiddleware
ParameterTypeDescription
configRequestProxyConfig-
Returns: RequestMiddleware

Types

RequestConfig

type RequestConfig = {
  url: string;
  method: string;
  headers?: Record<string, string | string[]>;
}
A request configuration object. Note: This is a simplified version of the RequestConfig type from the fetch API. It contains only the properties that are relevant for the fal client. It also works around the fact that the fetch API Request does not support mutability, its clone method has critical limitations to our use case.

RequestMiddleware

type RequestMiddleware = (
  request: RequestConfig,
) => Promise<RequestConfig>

RequestProxyConfig

type RequestProxyConfig = {
  targetUrl: string;
}