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 🙏

© 2025 – Pkg Stats / Ryan Hefner

rapid-responder

v1.0.5

Published

Provides a comprehensive utility for handling responses across multiple communication protocols (HTTP, IPC, and Socket).

Readme

Adaptive Response Handler

A versatile JavaScript library designed for adaptive response handling across multiple communication protocols, including HTTP, IPC, and SOCKET. This library supports stream processing, MIME type detection, and advanced error handling to provide a robust solution for server-side or middleware applications.


Features

  • Protocol Support: Handles HTTP, IPC, and SOCKET responses seamlessly.
  • Stream Processing: Detects and processes various stream types with built-in destruction and timeout handling.
  • MIME Type Detection: Automatically identifies content types for responses.
  • Error Handling: Customizable error handling with fallback mechanisms.
  • Status Management: Built-in support for standard HTTP status codes.

Installation

To install this package, use:

npm install rapid-responder

Usage

Importing the Module

const { ResponseHandler, STATUS_CODES, PROTOCOLS, httpResponder, ipcResponder, socketResponder } = require('rapid-responder');

Example: HTTP Responder

// Send an HTTP 200 OK response
httpResponder.ok({ message: 'Success' }, { headers: { 'Content-Type': 'application/json' } });

// Send an HTTP 404 Not Found response
httpResponder.notFound({ error: 'Resource not found' });

Example: IPC Responder

// Send an IPC 201 Created response
ipcResponder.created({ id: 12345 });

// Send an IPC 500 Internal Server Error response
ipcResponder.internalServerError({ error: 'Unexpected error occurred' });

Example: SOCKET Responder

// Send a SOCKET 503 Service Unavailable response
socketResponder.serviceUnavailable({ message: 'Service is temporarily down' });

Creating a Response Handler

const handler = new ResponseHandler({
  protocol: PROTOCOLS.HTTP,
  headers: { 'Content-Type': 'application/json' },
  streamTimeout: 30000,
  maxStreamSize: 50 * 1024 * 1024,
});

Setting Status Code

handler.status(STATUS_CODES.ok);

Handling Responses

Non-Stream Response

const response = handler.send({ message: 'Hello, World!' });
console.log(response);

Stream Response

const fs = require('fs');
const readableStream = fs.createReadStream('./example.txt');

handler.send(readableStream).then(data => {
  console.log(data);
}).catch(error => {
  console.error(error);
});

API Reference

Classes

ResponseHandler

Constructor
new ResponseHandler(options)
  • options: Configuration object with the following properties:
    • protocol (string): Communication protocol (default: PROTOCOLS.HTTP).
    • headers (object): Response headers.
    • streamTimeout (number): Timeout for stream processing (default: 30000ms).
    • maxStreamSize (number): Maximum allowable size for streams (default: 50MB).
Methods
  • status(code)

    • Sets the HTTP status code for the response.
    • Returns the ResponseHandler instance for chaining.
  • send(body)

    • Processes the response body and returns a formatted object or Promise.

Contributing

Contributions are welcome! Please follow the guidelines:

  1. Fork the repository.
  2. Create a feature branch.
  3. Submit a pull request with a detailed description of your changes.

License

This project is licensed under the MIT License. See the LICENSE file for details.


Acknowledgments

  • Built with ❤️ for the JavaScript community.
  • Inspired by common challenges in handling adaptive responses.

Contact

For issues or inquiries, contact the maintainer at [email protected].