Iskra API Reference
    Preparing search index...

    Interface ResponseContract

    The shape of every response: set once (KernelConfig.contract, or WebPlugin's) and followed by the Kernel's error handler, its 404, the validation middlewares, the features that refuse a request (auth, API keys, rate limit, CSRF, uploads) and the ok(), list() and fail() helpers.

    interface ResponseContract {
        schemas?: ContractSchemas;
        validationDetails?: ValidationDetails;
        error(problem: Problem, c: Context, error: unknown): unknown;
        list?(page: NormalizedPage, c: Context): unknown;
        log?(problem: Problem, c: Context, error: unknown): void;
        success?(data: unknown, c: Context, options: OkOptions): unknown;
        toProblem?(error: unknown, c: Context): Problem | undefined;
    }
    Index
    schemas?: ContractSchemas

    Its bodies' JSON Schemas, for the responses in OpenAPIFeature's spec.

    validationDetails?: ValidationDetails

    The details of a failed validation (validate(), bindBody(), bindQuery()): 'flatten' (the default), 'issues', 'fields' or a function of the issues.

    • The body of an error response, or a Response to send as is. A HEAD request gets no body (nor content type) whatever it returns.

      Parameters

      • problem: Problem
      • c: Context
      • error: unknown

      Returns unknown

    • The body of list(c, page). Default { success: true, data: items, meta }.

      Parameters

      Returns unknown

    • Logs every problem, instead of the Kernel logging the errors thrown (a 5xx at error, a 4xx at debug); it also sees the ones a feature or a validation answers without throwing.

      Parameters

      • problem: Problem
      • c: Context
      • error: unknown

      Returns void

    • The body of ok(c, data). Default { success: true, data, message? }.

      Parameters

      Returns unknown

    • The problem for an error the app throws, to recognize its own error classes; undefined leaves the error to Iskra's mapping.

      Parameters

      • error: unknown
      • c: Context

      Returns Problem | undefined