
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
@commt/node-sdk
Advanced tools
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.
Typing
, user online
and message read
indicatorsnpm i -S @commt/node-sdk
yarn add @commt/node-sdk
For detailed installation instructions and configuration options, please refer to our documentation.
Get started with Commt in just a few steps:
with
method.Check out our documentation for comprehensive usage examples and API reference.
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);
}
});
Commt is compatible with:
For any questions, feedback or issues, feel free to reach out to us via contact@commt.co.
FAQs
Ultimate chat kit nodejs sdk for web services
The npm package @commt/node-sdk receives a total of 0 weekly downloads. As such, @commt/node-sdk popularity was classified as not popular.
We found that @commt/node-sdk demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
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.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.