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

kuzzle-sdk

v7.14.0

Published

Official Javascript SDK for Kuzzle

Downloads

6,757

Readme

About

Kuzzle Javascript SDK

This is the official Javascript SDK for the free and open-source backend Kuzzle. It provides a way to dial with a Kuzzle server from Javascript applications using protocols.

Multiprotocols

Currently, the SDK provides 2 protocols: Http and WebSocket. WebSocket protocol implement the whole Kuzzle API, while the HTTP protocol does not implement realtime features (rooms and subscriptions).

Promises based

All SDK methods return a promise resolving the result part of Kuzzle API responses. If an error occurs, the promise is rejected with an Error object embedding the error part of the API response.
For example, for the action create of the controller collection (collection:create), the property result contains { "acknowledged": true } . This is therefore what will be returned by the SDK method if successful.
Any error must be caught either at the end of the Promise chain, or by using async/await and a try...catch.

Kuzzle

Kuzzle is an open-source backend that includes a scalable server, a multiprotocol API, an administration console and a set of plugins that provide advanced functionalities like real-time pub/sub, blazing fast search and geofencing.

Get trained by the creators of Kuzzle :zap:

Train yourself and your teams to use Kuzzle to maximize its potential and accelerate the development of your projects.
Our teams will be able to meet your needs in terms of expertise and multi-technology support for IoT, mobile/web, backend/frontend, devops.
:point_right: Get a quote

Usage

Compatibility matrix

| Kuzzle Version | SDK Version | | -------------- | ----------- | | 1.x.x | 5.x.x | | 1.x.x | 6.x.x | | 2.x.x | 7.x.x |

Getting started :point_right:

Installation

This SDK can be used either in NodeJS or in a browser.

Node.js

npm install kuzzle-sdk

Browser

To run the SDK in the browser, you have to build it yourself by cloning this repository and running

$ npm install
$ npm run build

A dist directory will be created, containing a browser version of this SDK.

<script type="text/javascript" src="dist/kuzzle.min.js"></script>

or use the CDN:

<script
  type="text/javascript"
  src="https://cdn.jsdelivr.net/npm/kuzzle-sdk@latest/dist/kuzzle.min.js"
></script>

Then the Kuzzle SDK will be available under the KuzzleSDK variable:

<script>
  const kuzzle = new KuzzleSDK.Kuzzle(new KuzzleSDK.WebSocket("localhost"));
  // ...
</script>

Browser with Webpack

If you use Webpack, you'll likely use the NPM-packaged version of the SDK (like in Node)

npm install kuzzle-sdk

But you'll still need to pick the built version (which ships with the package).

// with the classic require...
const { Kuzzle } = require("kuzzle-sdk");
// ... or with the new import directive.
import { Kuzzle } from "kuzzle-sdk";

Example

The SDK supports different protocols. When instantiating, you must choose the protocol to use and fill in the different options needed to connect to Kuzzle.

const { Kuzzle, WebSocket } = require("kuzzle-sdk");
const kuzzle = new Kuzzle(new WebSocket("localhost", { port: 7512 }));

try {
  await kuzzle.connect();
  const serverTime = await kuzzle.server.now();
  console.log(serverTime);
} catch (error) {
  console.error(error);
}