Options
All
  • Public
  • Public/Protected
  • All
Menu

The client for requesting, with some API utilities.

Hierarchy

  • default

Index

Constructors

constructor

Properties

Private backendURI

backendURI: string = "https://api.csc.deershark.com/api"

The backend API url to request.

Static Private instance

instance: null | default = null

Accessors

BackendURI

  • get BackendURI(): string
  • set BackendURI(uri: string): void

Methods

baseFetcher

  • baseFetcher(method: string, __namedParameters?: RequestInit): Promise<Response>
  • A basic fetcher for this SDK and Vercel SWR.

    Parameters

    • method: string

      The method to call. For example, /auth/user.

    • __namedParameters: RequestInit = ...

    Returns Promise<Response>

jsonFetcher

  • jsonFetcher(method: string, init: RequestInit): Promise<{ data: unknown; statusCode: number }>
  • The JSON fetcher.

    see

    Client.baseFetcher

    Parameters

    • method: string
    • init: RequestInit

    Returns Promise<{ data: unknown; statusCode: number }>

textFetcher

  • textFetcher(method: string, init: RequestInit): Promise<{ data: unknown; statusCode: number }>
  • The text fetcher.

    see

    Client.baseFetcher

    Parameters

    • method: string
    • init: RequestInit

    Returns Promise<{ data: unknown; statusCode: number }>

Static authRequest

  • authRequest(auth: default, __namedParameters?: RequestInit): Promise<RequestInit>
  • Create the header for an authenticated request.

    Parameters

    • auth: default

      -> CSCAuth

    • __namedParameters: RequestInit = ...

    Returns Promise<RequestInit>

Static getInstance

Static isResponseOk

  • isResponseOk(statusCode: number): boolean
  • This method emulated what response.ok does.

    Parameters

    • statusCode: number

    Returns boolean

Static postJsonRequest

  • postJsonRequest(data: unknown, __namedParameters?: RequestInit): RequestInit
  • Create the header for an POST (application/json) request.

    Parameters

    • data: unknown

      The request object. We will serialize this data with JSON.stringify().

    • __namedParameters: RequestInit = ...

    Returns RequestInit

Static responseParser

  • responseParser<T>(response: unknown, schema: T): Infer<T>
  • Parse the response.

    throws

    ValidationError

    Type parameters

    • T: Type<any, T>

    Parameters

    • response: unknown

      The response.

    • schema: T

      The response schema built with myzod.

    Returns Infer<T>

Generated using TypeDoc