npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cftools-sdk

v3.5.0

Published

An easy to use JavaScript implementation to talk with the CFTools Cloud API from your JavaScript project.

Downloads

1,876

Readme

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 :)