npm.io
2.3.29 • Published 5d ago

rotacloud

Licence
MIT
Version
2.3.29
Deps
2
Size
277 kB
Vulns
0
Weekly
0
Stars
1

RotaCloud Node SDK

Getting started

To use this SDK you'll need to npm install rotacloud. This will ensure you're ready to start working with the SDK in your project.

Contributing

Please ensure you perform the npm run version:bump command before commiting and pushing your changes to the remote branch.

Local development

When making changes to the SDK and testing them locally with the web app (rotacloud-app), follow these steps, provided you have already followed the above ones:

Initial setup

1.Build the SDK:

npm run build -- --watch

2.Link in the web app: / cd rotacloud-app

npm link rotacloud

3.Verify the link is correct:

npm ls rotacloud

Expected output:

└── rotacloud@x.x.x -> ./../rotacloud-node

The version displayed is the bumped version you are linking the app to.

Once you are sure you have the web app linked to the correct version of the package, you can start up the app and test your changes:

npm run start

Configuration

Configuration is simple, import the createRotaCloudClient function from the SDK and supply your API key:

import { createRotaCloudClient } from 'rotacloud';

const client = createRotaCloudClient({
  apiKey: 'YOUR_API_KEY',
});

Auto paging

Our SDK supports auto pagination as a way for developers to quickly consume list based endpoints. You will find a list() method on most services within the SDK which can be consumed using for await of. Please ensure you are catching errors in your implementation.

const client = createRotaCloudClient({...})

try {
  for await (const user of client.user.list()) {
    console.log(user);
  }
} catch (e) {
  console.log(e);
}

Retry Policies

Our SDK supports both basic and customisable retry polices. Both can be easily configured in the SDKConfig object at time of instantiation. Both exponential and static value based back offs are supported.

Only idempotent requests will be retried.

import { createRotaCloudClient } from 'rotacloud';

const client = createRotaCloudClient({
  apiKey: 'YOUR_API_KEY',
  retry: 'expo' | 'static',
});

If more granular control is required of the internal retry policy values, an object of retry configuration can be passed through to the retry field instead.

import { createRotaCloudClient } from 'rotacloud';

const client = createRotaCloudClient({
  apiKey: 'YOUR_API_KEY',
  retry: { delay: 2000, exponential: false, maxRetries: 10 },
});