mwg API
    Preparing search index...

    Class NewsClient

    The constructor validation and timeout-wrapped fetch shared by every injectable HTTPS transport here (FeedbackClient, NewsClient, SaveSyncClient, TelemetryClient) - each one is a plain request/response against a game's own endpoint, differing only in what they send and expect back, not in how the endpoint/timeout/fetch options are validated or how a request is aborted after timeoutMs. label names the concrete client in its own error messages ("feedback endpoint is required", not a generic one that would leave a game guessing which of several clients threw).

    import { HttpTransport, type HttpTransportOptions } from '@datamoc/mwg/core';

    class ScoreClient extends HttpTransport {
    constructor(options: HttpTransportOptions) {
    super(options, 'score');
    }
    }

    const client = new ScoreClient({ endpoint: 'https://example.com/scores' });
    console.log(client instanceof HttpTransport); // true

    Hierarchy (View Summary)

    Index
    endpoint: string
    fetchFn: {
        (input: URL | RequestInfo, init?: RequestInit): Promise<Response>;
        (input: string | URL | Request, init?: RequestInit): Promise<Response>;
    }

    Type Declaration

      • (input: URL | RequestInfo, init?: RequestInit): Promise<Response>
      • Parameters

        • input: URL | RequestInfo
        • Optionalinit: RequestInit

        Returns Promise<Response>

      • (input: string | URL | Request, init?: RequestInit): Promise<Response>
      • Parameters

        • input: string | URL | Request
        • Optionalinit: RequestInit

        Returns Promise<Response>

    maxResponseBytes: number
    timeoutMs: number
    • Fetches and validates the feed; a malformed item throws rather than reaching a game as trusted data. The response is read as text and run through sanitizeInboundText (a size cap, no embedded control characters) before JSON.parse ever sees it, ahead of normalizeItem's own per-field shape check below.

      Returns Promise<NewsItem[]>

    • the response body as text, refused as soon as it passes maxResponseBytes rather than after it is all in memory

      Parameters

      • response: Response

      Returns Promise<string>