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

@commt/node-sdk

v0.1.0

Published

Ultimate chat kit nodejs sdk for web services

Downloads

5

Readme

COMMT: Chat SDK for NodeJS

npm npm NPM

Welcome to Commt's NodeJS package – the heart of secure chat functionalities for your NodeJS applications! Commt is a versatile chat plugin designed to seamlessly integrate secure and customizable chat functionalities into your applications. Commt ensures a secure and reliable real-time communication experience for your users.

Features

  • Written in TypeScript
  • Fully customizable pre-build components with plugins
  • Multiple projects support with only one client configuration
  • AES encryption as default and end-to-end (E2E) support
  • Webhooks usage flexibility
  • Customizable and easy to manage system messages
  • Typing, user online and message read indicators
  • Emoji keyboard and all emoji types support with plugins
  • Hooks usage flexibility

Installation

  • NPM: npm i -S @commt/node-sdk
  • Yarn: yarn add @commt/node-sdk

For detailed installation instructions and configuration options, please refer to our documentation.

Usage

Get started with Commt in just a few steps:

  • Initialize Commt: Import the Commt module and init it in index file of your application then you can have a global instance of it by using with method.
  • Access From Everywhere: Define once in the beginning of your application and set it as global to access all over the files of your application.
  • Implement Secure Chat: Decrypt messages in your codebase, since Commt sends messages with encrypted format!

Check out our documentation for comprehensive usage examples and API reference.

Example

You can get client configs info from Commt Dashboard

index.ts

import { Commt } from "@commt/node-sdk";

// Initiate Commt in your app/index file
Commt.init({
  apiKey: "123456789?",
  projectId: "0987654321?",
  secret: "4k4hum6rfuvxorul94zimh55", // Must to be 16, 24 or 32 bytes
});

global.commt = Commt.with(); // Define it as a global variable

chat.js

router.post('/save-message', async (req, res) => {
    try {
        // Get encrypted message from req.body
        const { message: cipher, iv } = req.body;

        // Decrypt it by using commt and parse it to object
        const result = JSON.parse(commt.decrypt({ cipher, iv }));

        // Get required parameters from decrypted result
        const {roomId, message} = result;


        // Save message to your database
        await MessageModel.create({
            roomId,
            type: message.type,
            senderId: message.senderId,
            createdAt: message.createdAt,
            message: message.text,
        });

        // Return 200 status code
        res.status(200).send();
    } catch (err) {
        res.status(500).send(err.message);
    }
});

room.ts

router.post('/create-room', async (req, res) => {
    try {
        // Get array of string participants
        const { participants } = req.body;

        // Inform commt for newly created room by passing array of chatAuthIds of the users and get chatRoomAuthId field in return
        const chatRoomAuthId = commt.createRoom(participants.chatAuthIds);

        // Create new room with given data
        await RoomModel.create({
            roomId,
            chatRoomAuthId,
            participants: participants.ids,
            ...(communityAvatar && communityName && { communityAvatar, communityName})
        });

        // Return 200 status code
        res.status(200).send();
    } catch (err) {
        res.status(500).send(err.message);
    }
});

Compatibility

Commt is compatible with:

Support and Feedback

For any questions, feedback or issues, feel free to reach out to us via [email protected].

License

MIT