1.2.2 • Published 1 year ago

therungg v1.2.2

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

therungg

Node wrapper for therun.gg's API

TheRun is a service which is still early in development, so breaking changes should be expected. ReadTheDocs coming soon.

Basic Installation and Usage

Install this package by running npm install therungg.

HTTP API

Get front page data:

import { getFrontPageData } from 'therungg';

const frontPageData = await getFrontPageData();
console.log(frontPageData);

Get list of games supported by TheRun:

import { getAllGames } from 'therungg';

const games = await getAllGames();
console.log(games);

Live WebSocket API

You can listen to all the events sent from the Live API via:

import { LiveWebSocket } from 'therungg';

const ws = new LiveWebSocket(); // Will listen to ALL Live events

ws.onOpen = () => {
  console.log("Opened connection");
}

ws.onMessage = (data) => {
  console.log(data.user);
}

To listen to events only for a specific user, pass a username to the LiveWebSocket constructor.

const ws = new LiveWebSocket("cheese051"); // Will listen to live events for only this user

Notes

Error handling

The HTTP functionality of this API expects that you will try-catch any calls you make. This means that errors are thrown in an ungraceful manner.

There are three scenarios in which this occurs:

  • HTTP 404 error (Not Found)
  • HTTP 429 error (Rate Limited)
  • HTTP 500 error (Bad Request)

Compatibility

This package uses fetch, which has been built into Node without the need for polyfills since version 17.5. By now if you are starting a new project, you should be using the latest LTS version of Node (v18 at time of writing) which supports fetch.

For WebSocket functionality, this package makes use of isomorphic-ws to ensure compatibility in both browser and Node environments.

Roadmap

  • Live API WebSocket support
  • Marathon API support
  • Better test coverage
1.2.0

1 year ago

1.2.2

1 year ago

1.1.3

1 year ago

1.2.1

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.0

1 year ago