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

rtlayer-node

v1.0.2

Published

Send updates to your users in realtime in just few lines of code and you don't even have to think about the infrastructure.

Downloads

317

Readme

Overview

rtlayer-node is a Node.js library that provides an easy-to-use interface for interacting with the RTLayer API. RTLayer is a real-time messaging platform that enables you to integrate real-time functionality into your applications.

This documentation will guide you through the installation process, initialization of the RTLayer client, and demonstrate how to send messages using the library.

Installation

To install the rtlayer-node package, use npm:

npm install rtlayer-node

Usage

Importing the RTLayer module

const RTLayer = require('rtlayer-node').default;

Initializing RTLayer

To use the RTLayer API, you need to initialize an instance of the RTLayer class with your API key. You can obtain an API key by signing up for an RTLayer account.

const rtlayer = new RTLayer("your-api-key");

Sending Messages

Use the message method to send real-time messages. The method takes two parameters:

  • message (string or object): The content of the message, which can be either a string or a JSON object.
  • options (object): An optional parameter with the following properties:
    • ttl (number): Time to live for the message in seconds (optional).
    • channel (string): The channel on which to send the message (optional).
// Sending a string message
rtlayer.message("Welcome to MARS!",{
	ttl: 60, // Optional: Time to live for the message in seconds
  channel: "user-id" // // Optional: Channel on which to send the message
});

// Sending a JSON message
rtlayer.message({ headline: "AI Revolution: How Artificial Intelligence is Transforming the Job Market" }, {
    channel: "news"
});

Note: Make sure to replace "your-api-key" with your actual RTLayer API key.

Example

Here is a complete example of using rtlayer-node to send a real-time message:

const RTLayer = require('rtlayer-node').default;

// Replace "your-api-key" with your actual RTLayer API key
const rtlayer = new RTLayer("your-api-key");

// Sending a string message with a personal touch
const personalMessage = "Hello Developers! Just wanted to remind you to take a break and stay hydrated. Happy coding! 😊";

rtlayer.message(personalMessage, {
    ttl: 1,         // Optional: Time to live for the message in seconds
    channel: "devs" // Optional: Channel on which to send the message
});

// Sending a JSON message for a more structured update
const jsonMessage = {
    update: "New version of your favorite programming language released!",
    version: "v3.0.0",
    details: "This release includes exciting new features and performance improvements. Check the documentation for more information."
};

rtlayer.message(jsonMessage, {
    ttl: 1,
    channel: "devs"
});

Conclusion

Experience real-time communication effortlessly with RTLayer. In just 30 minutes, transform your application into a dynamic, engaging experience without the hassle of managing infrastructure.