[]previous and next page

ImagesOptions

Options of the image endpoint.

Options of the image endpoint.

Import#

ts
import type { ImagesOptions } from "@shadow-js/dusk/server";

Signature#

ts
interface ImagesOptions {
  /** Reads a local file for a path (`/hero.png`). Default: none, so a local path is 404. */
  readonly source?: (path: string) => Promise<ImageSource | undefined>;
  /** Origins (`https://cdn.example`) an absolute `url` may point at. Default: none. */
  readonly remotePatterns?: readonly string[];
  /** The transform. Default {@link passthroughProcessor}. */
  readonly processor?: ImageProcessor;
  /**
   * The widths served: the device and small lists `imageProps` snaps to (see {@link ImageWidths}). Default: the
   * framework's lists, the same ones `<Image>` uses. Any other `w` is a `400`.
   */
  readonly widths?: ImageWidths;
  /** Largest width served. Default: the largest of `widths` (3840 with the defaults). */
  readonly maxWidth?: number;
  /** Largest source read, in bytes. Default 8 MiB. */
  readonly maxSourceBytes?: number;
  /** `Cache-Control` of an answer. Default `public, max-age=86400`. */
  readonly cacheControl?: string;
  /** Timeout of a remote fetch, in milliseconds. Default 10 000. */
  readonly timeoutMs?: number;
  /** The `fetch` for remote sources. Default: the global one. */
  readonly fetch?: typeof fetch;
  /** The formats a request may ask for (`original` is the source's own). Default: all of them. */
  readonly formats?: readonly ImageFormat[];
  /**
   * The qualities a request may ask for. Default `[75]`, the `imageProps` default, so the number of variants an image can
   * have stays bounded; list the others here to serve them.
   */
  readonly qualities?: readonly number[];
  /**
   * Most source reads (a local `source` call or a remote fetch, and the processing of what it returned) in flight at the
   * same time over all clients. A request over the cap is answered `503` with `Retry-After` and its source is not read.
   * Default 32.
   */
  readonly maxConcurrentFetches?: number;
  /**
   * Most source reads in flight for one client address (the same address and `/64` IPv6 grouping the rate limiter keys on,
   * so `security.trustProxy` applies). A request over the cap is answered `429` with `Retry-After`. A request with no
   * client address is held to the global cap only. Default 16.
   */
  readonly maxConcurrentFetchesPerClient?: number;
}

Members#

Name Type Description
source? readonly source?: (path: string) => Promise<ImageSource | undefined> Reads a local file for a path (/hero.png). Default: none, so a local path is 404.
remotePatterns? readonly remotePatterns?: readonly string[] Origins (https://cdn.example) an absolute url may point at. Default: none.
processor? readonly processor?: ImageProcessor The transform. Default passthroughProcessor.
widths? readonly widths?: ImageWidths The widths served: the device and small lists imageProps snaps to (see ImageWidths). Default: the framework's lists, the same ones <Image> uses. Any other w is a 400.
maxWidth? readonly maxWidth?: number Largest width served. Default: the largest of widths (3840 with the defaults).
maxSourceBytes? readonly maxSourceBytes?: number Largest source read, in bytes. Default 8 MiB.
cacheControl? readonly cacheControl?: string Cache-Control of an answer. Default public, max-age=86400.
timeoutMs? readonly timeoutMs?: number Timeout of a remote fetch, in milliseconds. Default 10 000.
fetch? readonly fetch?: typeof fetch The fetch for remote sources. Default: the global one.
formats? readonly formats?: readonly ImageFormat[] The formats a request may ask for (original is the source's own). Default: all of them.
qualities? readonly qualities?: readonly number[] The qualities a request may ask for. Default [75], the imageProps default, so the number of variants an image can have stays bounded; list the others here to serve them.
maxConcurrentFetches? readonly maxConcurrentFetches?: number Most source reads (a local source call or a remote fetch, and the processing of what it returned) in flight at the same time over all clients. A request over the cap is answered 503 with Retry-After and its source is not read. Default 32.
maxConcurrentFetchesPerClient? readonly maxConcurrentFetchesPerClient?: number Most source reads in flight for one client address (the same address and /64 IPv6 grouping the rate limiter keys on, so security.trustProxy applies). A request over the cap is answered 429 with Retry-After. A request with no client address is held to the global cap only. Default 16.