Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
@getjoystick/joystick-js
Advanced tools
This is the library that simplifies the way how you can communicate with Joystick API.
NodeJS 16 and later
You can install the package via npm:
npm install @getjoystick/joystick-js
To use the client, import the package.
import { Joystick } from "@getjoystick/joystick-js";
Simple usage looks like this:
const client = new Joystick({
apiKey: process.env.JOYSTICK_API_KEY,
});
client
.getContents(["content-id1", "content-id2"])
.then((getContentsResponse) => {
console.log(getContentsResponse["content-id1"].myProperty1);
console.log(getContentsResponse["content-id2"].myProperty2);
});
client
.getContent("content-id1")
.then((getContentResponse) => console.log(getContentResponse.myProperty1));
When creating the Joystick
object, you can specify additional parameters which will be used
by all API calls from the client, for more details see
API documentation:
const client = new Joystick({
apiKey: process.env.JOYSTICK_API_KEY,
semVer: "0.0.1",
userId: "user-id-1",
params: {
param1: "value1",
param2: "value2"
},
options: {
cacheExpirationSeconds: 600, // 10 mins
serialized: true
}
});
fullResponse
In most of the cases you will be not interested in the full response from the API, but if you're you can specify
fullResponse
option to the client methods. The client will return you raw API response:
client
.getContent("content-id1", { fullResponse: true })
.then((getContentResponse) => console.log(getContentResponse));
// OR
client
.getContents(["content-id1", "content-id2"], { fullResponse: true })
.then((getContentsResponse) => console.log(getContentsResponse));
serialized
When true
, we will pass query parameter responseType=serialized
to Joystick API.
client
.getContent("content-id1", { serialized: true })
.then((getContentResponse) => console.log(getContentResponse));
// OR
client
.getContents(["content-id1", "content-id2"], { serialized: true })
.then((getContentsResponse) => console.log(getContentsResponse));
refresh
If you want to ignore existing cache and request the new config – pass this option as true
.
client
.getContent("content-id1", { refresh: true })
.then((getContentResponse) => console.log(getContentResponse));
// OR
client
.getContents(["content-id1", "content-id2"], { refresh: true })
.then((getContentsResponse) => console.log(getContentsResponse));
This option can be set for every API call from the client by setting setSerialized(true)
:
const client = new Joystick({
apiKey: process.env.JOYSTICK_API_KEY,
options: {
serialized: true
}
});
// OR
client.setSerialized(true);
By default, the client uses InMemoryCache, based on Map, which means the cache will be erased after application restart.
You can specify your cache implementation by implementing the interface SdkCache.
See examples/typescript/node-cache
or examples/typescript/redis-cache
for more details.
If you want to clear the cache – run:
client.clearCache().then(() => console.log("Cache cleared!"));
If you want to provide custom HTTP client, which may be useful for use-cases like specifying custom proxy, collecting detailed metrics about HTTP requests,
You can your HTTP client implementation by implementing the interface HttpClient.
See src/internals/client/axios-client
for more details.
To run unit tests, just run:
npm test
If you discover any security related issues, please email letsgo@getjoystick.com instead of using the issue tracker.
The MIT. Please see License File for more information.
FAQs
Javascript SDK for Joystick
The npm package @getjoystick/joystick-js receives a total of 78 weekly downloads. As such, @getjoystick/joystick-js popularity was classified as not popular.
We found that @getjoystick/joystick-js demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.