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

@norniras/service-agent

v0.2.6

Published

Service agent made for handling incoming data and commands.

Readme

Service Agent for NodeJS

An agent should be used by the service owners for handling (send/receive) the data and commands.

Installation

npm

npm i @norniras/service-agent

yarn

yarn add @norniras/service-agent

pnpm

pnpm add @norniras/service-agent

How to

Initialize the agent

import { ServiceAgent } from '@norniras/service-agent';

const agent = new ServiceAgent({
  serviceUrl: 'https://demo.cioty.com/service', // service URL
  token: 'aToken', // token
  ghostId: '0', // ghost id
  restartStream: true // Optional, default is true.
});

Agent - listen

Takes callback as an argument that will handle incoming data and commands. This is where all logic should be defined.

agent.listen(({ data, command }) => {
  if (typeof data !== 'undefined') {
    // DATA HANDLER
    console.log(data);
  }

  if (typeof command !== 'undefined') {
    // COMMAND HANDLER
    console.log(command);
  }
});

Agent - send data

The service owner can send data to any ghost of his service.

agent.sendData({
  ghostId: 'id', // Ghost ID where you want to send data
  dataString: 'key=value&key1=value1' // data is sent as query string
});

Agent - send command

The service owner can send commands only to the service he is linking to. Command schema defined by the service owner and can be found on micropage. We send to turn on lamp id 5 with a red color to a lamp service. The service agent of lamp service should handle this command.

agent.sendCommand({
  targetUrl: 'https://demo.cioty.com/lamp', // service URL
  commandString: 'action=on&id=5&color=red'
});

Agent - get query string from an object

From the examples above you can see that both data and commands should be sent as a query string. The method will convert objects into a query string.

const command = {
  action: 'on',
  id: 5,
  color: 'red'
};
const commandString = agent.getQueryStringFromObject(command);

// commandString // action=on&id=5&color=red

agent.sendCommand({
  targetUrl: 'https://demo.cioty.com/lamp', // service URL
  commandString
});

For developers

  1. Clone repo on GitHub
  2. Inside src/config folder create .env and copy from example.env
  3. Fill up .env file
  4. Run pnpm dev to start an agent
  5. Using CURLs u can send some data to your agent and see how does it work