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

recketjs

v0.1.1-beta

Published

Powerful event-driven WebSocket server framework with structured namespaces, event middleware, and HTTP-style communication.

Readme

🚀 RecketJS Server

RecketJS is a lightweight, scalable WebSocket server library that brings Socket.IO-like features with a modular, low-level control approach. It supports:

  • 🔌 Namespaces
  • 🧠 Middleware (connection & event-level)
  • 📩 Custom request-response handling
  • 🏠 Room-based broadcasting
  • 🔒 Server-to-client and client-to-server secure request support

Event-driven WebSockets with built-in request-response and no compromise


📢 Notice: Beta Release

This package is currently in active development and is released under a beta version.
While it's functional, some APIs may change and issues may arise.
Please use it, test it, and report any bugs or suggestions on the GitHub Issues page.

Contributions are welcome in the form of feedback or issue reports — code-level contributions are currently restricted while the core API is being finalized.


📦 Installation

NPM

npm install recketjs

Yarn

yarn add recketjs

📄 License

This project is licensed under the Apache License 2.0 © 2025 jafferkazmi572.

🧪 Getting Started

Basic Setup

import { RecketServer } from "recketjs";
import http from "http";

const server = http.createServer();
const io = new RecketServer({server, path: "/recket" });

const chatNamespace = io.of("/chat");

chatNamespace.on("connection", (socket) => {
  console.log("✅ Client connected to /chat");

  socket.on("say_hello", (data) => {
    console.log("Client says:", data);
    socket.emit("server_greet", { message: "Hello from server!" });
  });

  socket.onRequest("get_user", async (data, response) => {
    if(data.userId)
      response( { id: data.userId, name: "Ali" });
    else
      response(null,{code:401,message:'unauthorized'})
  });
});

server.listen(3000, () => {
  console.log("🚀 Server listening on port 3000");
});

🧠 Features

✅ Namespaces

const chat = io.of("/chat");
const admin = io.of("/admin");

🔗 Middleware Support

Connection Middleware

chat.useConnection(async (socket, next) => {
  const token = socket.query.token;
  if (token !== "xyz") return next(new Error("Unauthorized"));
  next();
});

Event-Level Middleware

chat.use("say_hello", async (socket, data, next) => {
  if (!data.name) return next("Missing name");
  next();
});

🔁 Request-Response System

Client Request → Server Response

  • Below is server declaration
socket.onRequest("get_user", async (data, response) => {
    if(data.userId)
      response( { id: data.userId, name: "Ali" });
    else
      response(null,{code:401,message:'unauthorized'})
  });
  • Below is client requesting
await socket.request("get_user", { time: Date.now() });

Server Request → Client Response

  • Below is client declaration
socket.onRequest("ping", async (data, response) => {
   response({ message: 'I am Here...' });
});
  • Below is server requesting
await socket.request("ping", { time: Date.now() });
  • The client must explicitly enable handling of server-initiated requests.

🔐 Secure Server-to-Client Requests

To prevent abuse, the server can only request the client if:

  • The server is running on localhost, or
  • Clients must explicitly enable handling of server-initiated requests using .enableServerRequests().

This means the client needs to call .enableServerRequests() before the server can request any data from the client.

🏠 Room-based Broadcasting

socket.join("room1"); // Join a room
chatNamespace.to("room1").emit("room_message", { msg: "Hello Room!" }); // Broadcast to all sockets in the room

📄 Query Parameters

  • Client can connect with query:
ws://localhost:3000/recket/chat?token=xyz
  • Accessible via:
socket.query.token;

🧰 API Overview

RecketServer

let rs = new RecketServer({server:httpServer, path: "/recket" });
rs.of("/namespace");

RecketNamespace

namespace.useConnection(fn);
namespace.use("event", fn);
namespace.on("connection", (socket) => {});
namespace.to("room").emit(...);

RecketSocket

socket.id
socket.emit("event", data);
socket.on("event", handler);
socket.onRequest("endpoint", async (data,respond) => {});
socket.request("endpoint", data);
socket.join("room");
socket.leave("room");

🧑‍💻 Dev Notes

  • Compatible with any Node HTTP server

  • Use structured namespaces for scaling

  • Built for full control over WebSocket behavior

🧠 Author

Crafted with 💙 for devs who love event-driven systems and want the power of WebSockets with better control.