Socket
Socket
Sign inDemoInstall

@jup-ag/notification-sdk

Package Overview
Dependencies
4
Maintainers
6
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @jup-ag/notification-sdk

### Install ``` npm i @jup-ag/notification-sdk ```


Version published
Weekly downloads
724
decreased by-48.76%
Maintainers
6
Install size
157 kB
Created
Weekly downloads
 

Readme

Source

Notification SDK

Install

npm i @jup-ag/notification-sdk

Subscribing to message updates

import { CreateNotificationClient, Status } from "@jup-ag/notification-sdk";

const workerEndpoint = "http://127.0.0.1:8787"

function handler(key: string, status: Status, code: string, description: string) {
  console.log(`Got new message for ${key}; Status: ${status}; Code: ${code}; Description: ${description}`)
}

function main() {
  const notificationClient = CreateNotificationClient(workerEndpoint)
  const key = "SomePositionRequestPubKeyBase58"
  notificationClient.onUpdate(key, handler)
}

Set new message

import { CreateNotificationClient, Status, Message } from "@jup-ag/notification-sdk";

const workerEndpoint = "http://127.0.0.1:8787"

async function main() {
  const notificationClient = CreateNotificationClient(workerEndpoint)
  const key = "SomePositionRequestPubKeyBase58"

  const message: Message = {
    status: Status.Error,
    code: "6001",
    description: "Something went wrong"
  }

  const ok = await notificationClient.updateMessage(key, message)

  if (!ok) {
    throw new Error("Failed to update status")
  }

  const res = await notificationClient.getMessage(key)
  console.log({ res })
}

About Message

Message is a JSON serializable object containing 3 properties

  • status: status is an enum with 4 possibilities -> Pending, Error, Success, Failed
  • code: this can be an error code as a string ie '6001' or 'MAX_ATTEMPTS'
  • description: this can be a user friendlier description of the error code

About Status

While you can use it very flexibly, this is how we intend to use it:

  • Status.Pending -> indicate that it is still in process
  • Status.Error -> error messages but might not indicate finality aka retries might be on the way
  • Status.Failed -> this indicate finality. no more retries
  • Status.Success -> everything is good

FAQs

Last updated on 31 May 2023

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc