3.1.7 • Published 3 months ago

cftools-sdk v3.1.7

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

cftools-sdk

npm Discord

This library provides convenient methods to work with the CFTools Cloud API from a nodejs/JavaScript project.

Installation

Install via npm:

npm install cftools-sdk

Usage

The main piece you will work with is the CFToolsClient. It provides methods to interact with the API actions of CFTools Cloud and are documented in the corresponding interface.

Create a new instance of the client with the builder as shown in this example:

import {CFToolsClientBuilder, SteamId64} from 'cftools-sdk';

const client = new CFToolsClientBuilder()
    .withServerApiId('your-server-api-id')
    .withCredentials('your-application-id', 'your-secret')
    .build();

client.getPriorityQueue(SteamId64.of('a-steam-id')).then((item: PriorityQueueItem) => {
    // Do something
});

API Reference

You can find the API reference for the SDK in the documentation page.

Caching

When using the SDK for a component that acts directly upon user interactions, consider that the CFTools Cloud API utilises a rate limit to protect for unusual load and abusive behaviour. This SDK provides a way to circumvent a user issuing more requests to your program then the CFTools Cloud API allows you to do against a specific endpoint. Enabling caching for the CFToolsClient will cache successful responses from the CFTools Cloud API with a provided Cache and will hold this information up to the configured expiration time. The SDK ships with one Cache, which holds responses in-memory.

You can enable caching with the builder:

import {CFToolsClientBuilder, SteamId64} from 'cftools-sdk';

const client = new CFToolsClientBuilder()
    .withCache()
    .withServerApiId('your-server-api-id')
    .withCredentials('your-application-id', 'your-secret')
    .build();

client.getPriorityQueue(SteamId64.of('a-steam-id')).then((item: PriorityQueueItem) => {
    // Do something
});

Note, that mutable operations (like adding a priority queue entry) will never be cached.

Enterprise API

By default, the cftools-sdk uses the general purpose Data API. In addition to that, the enterprise API is supported as well, which is a special-built API with some restrictions of the Data API lifted.

You can setup the SDK to use the Enterprise API with the builder:

import {CFToolsClientBuilder, SteamId64} from 'cftools-sdk';

const client = new CFToolsClientBuilder()
    .withServerApiId('your-server-api-id')
    .withCredentials('your-application-id', 'your-secret')
    .withEnterpriseApi('your-enterprise-api-key')
    .build();

client.getPriorityQueue(SteamId64.of('a-steam-id')).then((item: PriorityQueueItem) => {
    // Do something
});

Contribution

This library is not complete yet and needs your help: What methods and features are missing? How can the documentation be improved? Simply create an issue in the Github repository with as much details as possible.

Pull requests are welcome as well :)

3.1.7

3 months ago

3.1.6

4 months ago

3.1.5

5 months ago

3.1.3

5 months ago

3.1.4

5 months ago

2.2.0

9 months ago

3.1.1

6 months ago

3.1.0

6 months ago

3.0.0

6 months ago

3.0.0-alpha1

8 months ago

2.1.2

11 months ago

2.1.1

11 months ago

2.1.0

12 months ago

2.0.0

1 year ago

1.9.0

2 years ago

1.8.1

2 years ago

1.8.0

2 years ago

1.7.0

2 years ago

1.6.4

3 years ago

1.6.3

3 years ago

1.6.2

3 years ago

1.6.1

3 years ago

1.6.0

3 years ago

1.5.0

3 years ago

1.4.0

3 years ago

1.2.0

3 years ago

1.1.1

3 years ago

1.3.2

3 years ago

1.3.1

3 years ago

1.1.3

3 years ago

1.3.0

3 years ago

1.1.2

3 years ago

1.1.0

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago