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

exhandlers

v1.1.5

Published

Utility middlewares for working with ExpressJs

Readme

exhandlers

exhandlers is a comprehensive collection of middleware and handler functions designed to streamline backend development in Express.js. It provides pre-built utilities for handling databases, WebSocket connections, AMQP connections, logging, and various other essential middleware functionalities.

By integrating exhandlers, developers can eliminate the need to write common handlers from scratch, thereby reducing development overhead and ensuring a cleaner, more maintainable codebase.

Documentation

exhandlers Documentation

Available Handlers

Core Middleware

  • Asynchronous Handler – Simplifies error handling in async functions.
  • Authentication Handler – Manages authentication and authorization mechanisms.
  • CORS Handler – Configures Cross-Origin Resource Sharing (CORS) policies.
  • Error Handler – Centralized error handling middleware.
  • Not Found Handler – Handles 404 (Not Found) errors.
  • Logs Handler – Structured logging for application monitoring.
  • Rate Limiting Handler – Protects APIs from excessive requests.
  • Password Handler – Utility functions for password hashing and validation.
  • Token Handler – Utility function for password hashing and validation.

Database Handlers

  • MongoDB Handler – Provides a streamlined connection and query interface for MongoDB.
  • PostgreSQL Handler – Manages PostgreSQL database connections and queries.
  • Redis Handler – Integrates Redis for caching and session management.

Additional Handlers

  • Upload Handler – Manages file uploads efficiently.
  • Socket Handler – Handles WebSocket connections for real-time data exchange.
  • AMQP Handler – Facilitates message queue communication using AMQP (e.g., RabbitMQ).

Installation

To integrate exhandlers into your project, install the package using npm:

npm install exhandlers

Usage

To use exhandlers in your Express application, import the required handlers using require.

const {
  asyncHandler,
  errorHandler,
  notFoundHandler,
  corsHandler,
  rateLimitHandler,
} = require("exhandlers");

const express = require("express");

const app = express();

// Apply CORS middleware
app.use(corsHandler());

// Apply rate limiting middleware
app.use(rateLimitHandler({ windowMs: 15 * 60 * 1000, limit: 100 })); // 100 requests per 15 minutes

// Define an asynchronous route using asyncHandler
app.get(
  "/data",
  asyncHandler(async (req, res) => {
    const data = await fetchDataFromDB(); // Simulated database call
    res.json({ success: true, data });
  }),
);

// Handle 404 errors
app.use(notFoundHandler());

// Centralized error handling middleware
app.use(errorHandler());

// Start the server
const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
  console.log(`Server is running on port ${PORT}`);
});

// Sample function simulating database fetch
async function fetchDataFromDB() {
  return { message: "Hello from the database!" };
}

This setup ensures your Express server is optimized for security, error handling, and performance.

License

This project is licensed under the MIT License.