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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@telegraph-notify/backend-sdk

v1.0.2

Published

Telegraph Backend SDK

Downloads

6

Readme

Telegraph Node.js SDK

The Node.js SDK for Telegraph is used for sending notifications to users, and also for managing user-related data on the Telegraph database.

Table of Contents

Quick Start

Install the SDK from npm.

$ npm i @telegraph-notify/backend-sdk

Then import the SDK for use in the application code.

import Telegraph from "@telegraph-notify/backend-sdk";
const telegraph = new Telegraph(secretKey, httpGateway);

Enter your secretKey and httpGateway from the Telegraph CLI deployment.

Usage

All telegraph methods return a Promise that will resolve to the response.

Send a Notification

telegraph.send({
  user_id,
  channels: {
    in_app?: {
      message
    },
    email?: {
      subject,
      message,
    },
    slack?: {
      message,
    },
  },
});
  • user_id (string, required): The unique identifier of the user receiving the notification.
  • channels.in_app.message (string, optional): The in_app message to be sent to the user.
  • channels.email.subject (string, optional): The email subject to be sent to the user.
  • channels.email.message (string, optional): The email message to be sent to the user.
  • channels.slack.message (string, optional): The email message to be sent to the user.

Response:

  • Success (200 OK): Returns a JSON object with the status code and response message.
    • Example:
      {
        "status": 200,
        "body": [
          {
            "channel": "in_app",
            "notification_id": "1865d4a8-94cb-4a4b-bfef-35942abadf18"
          },
          {
            "channel": "email",
            "notification_id": "27149fcf-1e8d-47f7-b240-6c7db899f861"
          }
        ]
      }
  • Error (500 Internal Server Error): Returns an error message if the request fails.
    • Example:
      {
        "status": 500,
        "body": "Internal Server Error"
      }

Generate Client HMAC

telegraph.generateHMAC(user_id);
  • user_id (string, required): The unique identifier of the user.

Response:

  • Success: Returns the client HMAC as a string with base64 encoding.
    • Example:
      "BojdvcqEyK4CHwQ=";

Add User

telegraph.addUser(id, name, email, slack);
  • id (string, required): The unique identifier of the user.
  • name (string, required): The full name of the user.
  • email (string, required): The email address of the user.
  • slack (string, optional): The Slack webhook of the user.

Response:

  • Success (200 OK): Returns a JSON object with the status code and a success message.
    • Example:
      {
        "status": 200,
        "body": "User added successfully"
      }
  • Error (500 Internal Server Error): Returns an error message if the request fails.
    • Example:
      {
        "status": 500,
        "body": "Internal Server Error"
      }

Edit User

telegraph.editUser(id, name, email, slack);
  • id (string, required): The unique identifier of the user.
  • name (string, required): The updated full name of the user.
  • email (string, required): The updated email address of the user.
  • slack (string, optional): The Slack webhook of the user.

Response:

  • Success (200 OK): Returns a JSON object with the status code and a success message.
    • Example:
      {
        "status": 200,
        "body": "User edited"
      }
  • Error (500 Internal Server Error): Returns an error message if the request fails.
    • Example:
      {
        "status": 500,
        "body": "Internal Server Error"
      }

Delete User

telegraph.deleteUser(id);
  • id (string, required): The unique identifier of the user to be deleted.

Response:

  • Success (200 OK): Returns a JSON object with the status code and a success message.
    • Example:
      {
        "status": 200,
        "body": "User deleted successfully"
      }
  • Error (404 Not Found): Returns an error message if the user does not exist.
    • Example:
      {
        "status": 404,
        "body": "User does not exist"
      }
  • Error (500 Internal Server Error): Returns an error message if the request fails.
    • Example:
      {
        "status": 500,
        "body": "Internal Server Error"
      }

Get User

telegraph.getUser(id);
  • id (string, required): The unique identifier of the user to retrieve.

Response:

  • Success (200 OK): Returns a JSON object containing the user's details.
    • Example:
      {
        "status": 200,
        "body": {
          "id": "bob",
          "name": "bob smith",
          "email": "[email protected]",
          "last_seen": "2024-11-14T04:38:58.598Z",
          "created_at": "2024-11-14T04:38:55.278Z",
          "last_notified": "2024-11-14T04:52:26.662Z",
          "preferences": {
            "email": true,
            "in_app": true,
            "slack": false
          }
        }
      }
  • Error (404 Not Found): If the user is not found.
    • Example:
      {
        "status": 404,
        "body": "User not found"
      }
  • Error (500 Internal Server Error): If there is an error with the request.
    • Example:
      {
        "status": 500,
        "body": "Internal Server Error"
      }

Get All Users

telegraph.getAllUsers();

Response:

  • Success (200 OK): Returns a JSON object with the status code and response message.
    • Example:
      {
        "status": 200,
        "body": [
          {
            "last_seen": "2024-11-14T04:38:58.598Z",
            "created_at": "2024-11-14T04:38:55.278Z",
            "last_notified": "2024-11-14T04:52:26.662Z",
            "email": "[email protected]",
            "id": "bob",
            "name": "bob",
            "preferences": {
              "email": true,
              "in_app": true,
              "slack": false
            }
          },
          {
            "last_seen": "2024-11-14T04:30:55.046Z",
            "created_at": "2024-11-14T04:29:10.277Z",
            "last_notified": "2024-11-14T04:30:58.141Z",
            "email": "[email protected]",
            "id": "alice",
            "name": "alice",
            "preferences": {
              "email": true,
              "in_app": true,
              "slack": false
            }
          }
        ]
      }
  • Error (500 Internal Server Error): If there is an error with the request.
    • Example:
      {
        "status": 500,
        "body": "Internal Server Error"
      }

Get Notification Logs

telegraph.getNotificationLogs();

Response:

  • Success (200 OK): Returns an array of notification logs.
    • Example:
      [
        {
          "user_id": "bob",
          "created_at": "2024-11-10T03:02:25.494Z",
          "status": "notification request received",
          "notification_id": "d19e2ff9-7dce-48ec-9368-f6344ac0e2d9",
          "log_id": "cc6a2f8c-3885-45d5-9800-a57f74dd9b16",
          "ttl": 1733799745,
          "message": "hi",
          "channel": "in_app"
        }
      ]
  • Error: If there is an error with the request.
    • Example:
      Error fetching notification logs: Error: HTTP error: 404