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

@hmv007/chat-api-server

v1.0.4

Published

Server for ready-to-go socket-chat-api

Downloads

6

Readme

chat-api-server

An easy-to-use and ready-to-go chat-api-server in NodeJS.

Inspired by a freelance project I was working on where I had to use Firebase just to have a chat feature in my app and the deadline was quite near to implement my own in NodeJS. Hence, we had to use Realtime database provided by Firebase. In practise, implementing a Socket.io server is not tough but a little lengthy so here it is, a out-of-the-box socket server which can get your chat backend up-and-running within 10 secs.

Documentation

  1. Prerequisites
  2. Usage
  3. Conclusion

Prerequisites

A MongoDB database is needed to save user sessions and messages. MongoDB Atlas is preferred.

Usage

  1. Initializing the Server The chat-api-server uses an express server internally to run the server. Pass a PORT number and MongoDB Database URL in the initServer Function.
const  initServer = require('@hmv007/chat-api-server');

// PORT = 5000
initServer(PORT, dbURL);
  1. Server logs Check the logs on the console. Server should be running on the given port and database must be connected. Check the logs for any errors.
  1. Server is up and running If no errors are found in the console your chat-api-server should be up-and-running!

Pre-defined Events

Emitting Events

  • joinRoom - Fire this event on the client side to join a room. room_id and user_id must be provided in the payload.
  • sendMessage - Fire this event on client side to send a message. Payload must contain a "senderID" and "message".

Catching Events

  • userOnline - Event fired when a user successfully joins the room. This event is broadcasted, i.e. all the users except the current user receive this event.
  • inRoom - Event fired when a user successfully joins the room. The current user only will receive this event on successfull joining of the room.
  • message - Event fired when a message was sent to the room and has been saved successfully. This event is broadcasted.
  • messageSaveSuccess - Event fired when a message was sent to the room and has been saved successfully. This event if for the current user.
  • messageSaveError - Event fired when a message was sent to the room but there was an error in saving the message to the database. Logs can be checked for exact error. Client side should handle the error accordingly.

Error event

  • exception - Event is fired whenever an error occurs in socket requests. The payload is the error from MongoDB or custom error. The event should be catched while connecting to the socket server otherwise no errors will be visible on the client side. Server logs can also be checked for exact error.

Conclusion

This is an initial build and subsequent builds will have new and improved features with the ability to login a user, authenticated socket routes, socket namespace, sending and receiving media files etc. These are just at the top of my head. Write me at [email protected] for suggestions and critics.

Happy to help!