New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

@encephalon/sdk

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@encephalon/sdk

javascript sdk for encephalon api

latest
Source
npmnpm
Version
0.0.1
Version published
Maintainers
1
Created
Source

Universal JavaScript SDK for the Encephalon Engine API

This client is a thin wrapper for the Encephalon API to use in Node.js and the browser.

Install

npm install @encephalon/sdk

Usage

encephalon exposes a single function that takes a single options object for configuration and returns the client

options

token string

The access token. You can find or create one in your dashboard

cache (optional)

Allows custom cache implementation, defaults to memory

ttl integer (optional)

A cache entry's time to live in ms, defaults to 3600000

maxRetries integer (optional)

Number of attempts to retry a request if an error occurs, defaults to 2

timeout integer (optional)

How long before the request aborts in ms, defaults to 5000

concurrency integer (optional)

Max concurrent requests, defaults to 3

interval integer (optional)

Duration of delay between requests to avoid API rate limits, defaults to 16

Example

// require encephalon
import encephalon from '@encephalon/sdk';

// create a client with your access token
const client = encephalon({
  token: '{YOUR_ACCESS_TOKEN}',
});

// make requests
await client.get(`experiences/${id}`);

await client.post(`experiences/${id}`)
  .send({ name: 'hello' });
  
await client.delete(`experiences/${id}`);

Methods

all, get, post, put, patch, delete

All requests take a string for the API path and return a thenable superagent object. See the Example section above.

await client.all(`experiences`);
await client.get(`experiences/${id}`);
await client.post(`experiences/${id}`)
  .send({ name: 'hello' });
await client.delete(`experiences/${id}`);

cachebust

Ignores the cache and cachebusts the URL

await client.get(`experiences/${id}`)
  .cachebust();

page

For pagination, sets the page number

await client.all(`experiences`)
  .page(2);

perPage

For pagination, sets quantity per page

await client.all(`experiences`)
  .perPage(5);

token

Sets the token with the passed value. Can also be used as a getter.

client.token('{TOKEN}'); // sets token

const tkn = client.token(); // gets token

Cache

Documentation is a WIP

Testing

To run the test suite:

  • Open a terminal and navigate to the project
  • run npm install
  • run npm test

Please see the package.json engines for supported environments

Keywords

encephalon

FAQs

Package last updated on 09 Jan 2020

Did you know?

Socket

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.

Install

Related posts