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

jaseci-web-client

v0.1.0

Published

A simple and customizable client for interacting with Jaseci's walker endpoints via HTTP requests. The client handles sending requests and managing authorization tokens with ease.

Downloads

74

Readme

Jaseci Web Client

A simple and customizable client for interacting with Jaseci's walker endpoints via HTTP requests. The client handles sending requests and managing authorization tokens with ease.

Installation

You can install the package using npm:

npm install jaseci-web-client

Or using Yarn:

yarn add jaseci-web-client

Usage

import { JaseciWebClient } from "jaseci-web-client";

const client = new JaseciWebClient({
  baseUrl: "https://your-jaseci-server.com", // Required: The base URL of the Jaseci API.
  token: "your-auth-token", // Optional: Your authentication token for the API.
  timeout: 5000, // Optional: Timeout for requests in milliseconds (default is 10000).
});

client
  .call("walker_name", {
    payload: { key: "value" }, // Required: Payload to send with the walker request.
    jid: "optional-jid", // Optional: Provide a job ID if needed.
    authorize: true, // Optional: Defaults to true, pass false to skip authorization.
  })
  .then((response) => {
    console.log(response);
  })
  .catch((error) => {
    console.error(error);
  });

API

JaseciWebClient Constructor

Creates a new instance of the JaseciWebClient.

const client = new JaseciWebClient(options);

Options

Options

| Option | Type | Description | Required | | ------- | ------ | ------------------------------------------------------------------------------- | -------- | | baseUrl | string | The base URL of the Jaseci server (e.g., https://your-jaseci-server.com). | Yes | | timeout | number | Timeout for the HTTP requests, in milliseconds. Defaults to 10000 (10 seconds). | No | | token | string | Optional authentication token for authorized requests (usually a Bearer token). | No |

call Method

Send a request to a specific walker.

client.call(walker_name, options);

Parameters

Parameters

| Parameter | Type | Description | Required | | ----------- | ----------- | ------------------------------------------------------------------------------ | -------- | | walker_name | string | The name of the walker to call (the endpoint will be /walker/{walker_name}). | Yes | | options | CallOptions | The options for the call, including payload, job ID, and authorization toggle. | Yes |

CallOptions

| Option | Type | Description | Required | | --------- | ------------------- | ------------------------------------------------------------------ | -------- | | payload | Record<string, any> | The payload (data) to send to the walker. | Yes | | jid | string | Optional job ID for the request. | No | | authorize | boolean | Whether to include authorization in the request. Defaults to true. | No |

setToken Method

Update or set the authorization token after the client is initialized.

client.setToken("new-token");

Response Format

The response for the call method will always include a status object and an array of reports. Example response format:

{
  "status":  200,
  "reports": [
    {
      "some_key": "some_value"
    }
  ]
}

Example Response Handling

client
  .call("walker_name", { payload: { key: "value" } })
  .then((response) => {
    console.log("Status:", response.status);
    console.log("Reports:", response.reports);
  })
  .catch((error) => {
    console.error("Error:", error);
  });

Customization and Extensibility

You can extend the client by adding additional request options like headers, interceptors, or specific API routes if needed.

Contributing

If you have any suggestions, ideas, or issues, feel free to open an issue or submit a pull request on GitHub.

License

This project is licensed under the MIT License.

Building the Library

Make sure you build the library before publishing so that everything is compiled into the dist/ folder:

npm run build