23min

NodeJS Client πŸš€

This hyper client is an opinionated client that provides a wrapper for data, cache and search apis. The api takes an app name, key name, secret, and url for your hyper service. The app name is passed as the sub in the generated access token, which will show through on the logs.

Install

ο»Ώ

In your API project directory run npm install

Shell
|

For best results, we recommend you consider using crocks as a per utility library with the client. The client currently return the Async data type when you make calls for extensibility.

NOTE: If you prefer async/await or promise patterns, you can simply use the toPromise() method to return a promise instead of an Async.

Usage

ο»Ώ

Configuration

When creating the client you need to supply the client with four parameters:

  • URL - the url to the hyper service
  • APP_NAME - the name of the app
  • SECRET - the shared secret used to generate the JWT Tokens for accessing the service.
  • KEY_NAME - this key name is the name of the data store, cache store and search store.

Example

JS
|
TIP: your key name is the name of the store, cache, and index, you can name it differently for each environment, like stuff-dev, stuff-test, stuff-prod.

Setup

ο»Ώ

When using the client you will want to make sure your data, cache and search stores are setup.

JS
|

These commands are idempotent which means that the first time they run they will create the data, cache, and search containers, but if the containers already exist then they will simply return an ok. This way you can init your containers every time your service is launched and you don't have to worry about it.

Data Methods πŸ“¦

  • data.create - creates a new document in the data store
  • data.get - retrieves a document from the data store
  • data.update - updates a document in the data store
  • data.remove - removes a document in the data store
  • data. query - runs a query against the data in the store
  • data.list - lists the data in the store

Coming soon

  • data.bulk - bulk insert./update documents in store

Cache Methods πŸ’²

  • cache.post - caches a new document
  • cache.get - gets a document from the cache
  • cache.put - updates a document
  • cache.query - returns a list of documents based on a pattern matcher
  • cache.remove - removes a document from the cache

Search Methods πŸ”

  • search.create - indexes a search document
  • search.remove - removes a search document
  • search.query - runs a search and returns matches

Source Code πŸ’»

Need specific help? you can always reach out to our support team for any additional assistance at checkout our help deskο»Ώ

ο»Ώ

Updated 15 Mar 2022
Did this page help?
Yes
No