Class Rest

The Rest service provides functionality for interacting with the FakeYou API and handles authentication.

Constructors

Properties

Accessors

Methods

Constructors

Properties

#cookie?: string = process.env.FAKEYOU_COOKIE

Accessors

  • set cookie(cookie): void
  • Set the cookie to use for authentication.

    Parameters

    • cookie: undefined | string

    Returns void

  • get isAuthenticated(): boolean
  • Authentication status.

    Returns boolean

    Whether or not the user is authenticated.

Methods

  • Download a file from the given URL.

    Parameters

    • url: string

      The URL to download from.

    • mime: string

      The mime type of the file.

    Returns Promise<undefined | Buffer>

  • Light wrapper over fetch, provides authentication and logging automatically. The correct headers are automatically set to comply with the FakeYou API.

    Note: If FAKEYOU_COOKIE environment variable is set, it will be used for authentication.

    Parameters

    • url: string

      The URL to send the request to.

    • Optional request: RequestInit

      The request options to send.

    Returns Promise<Response>

  • Upload a file to the given URL.

    Parameters

    • url: string

      The URL to upload to.

    • data: Buffer

      The data to upload as a buffer.

    • mime: string

      The mime type of the file.

    Returns Promise<Response>

    The response from the server.

Generated using TypeDoc