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

eefp

v0.0.23

Published

eefp turns your Express app into a real-time powerhouse with instant WebSocket and SSE support🚀

Readme

🚀 eefp – Express Extended For Protocols

eefp is a lightweight utility that extends an existing Express app with built-in support for:

✅ WebSocket routes (WS)

✅ Server-Sent Events (SSE)

✅ Middleware support for both

✅ Client management utilities

It works like a plugin: pass your Express app into eefp(app) and your app instantly gains new protocol features.

 

📦 Installation

bash

Copy

npm install eefp

 

⚡ Quick Usage

js

Copy

const express = require("express")

const eefp = require("eefp")

const app = express()

eefp(app) // extend express with WS + SSE

app.get("/", (req, res) => {

  res.send("HTTP Working")

})

app.listen(3000, () => {

  console.log("Server running on port 3000")

})

 

🌐 WebSocket Support

eefp adds WebSocket routing directly to your Express app.

➤ Create WebSocket Routes

js

Copy

// Exact route

app.ws("/ws", (ws, req) => {

  ws.send("Connected!")

})

// Parameterized route

app.ws("/chat/:roomId", (ws, req) => {

  console.log("Room ID:", req.params.roomId)

  ws.send(Welcome to room ${req.params.roomId})

})

// Wildcard route

app.ws("/news/*", (ws) => {

  ws.send("This matches any /news/... path")

})

➤ Middleware Support

js

Copy

app.ws("/secure",

  (req, res, next) => {

  console.log("Middleware executed")

  next()

  },

  (ws, req) => {

  ws.send("Secure connection established")

  }

)

➤ Error Handling

Middleware or handler errors are automatically propagated to Express. Handle them like normal Express errors:

js

Copy

app.use((err, req, res, next) => {

  console.error("WebSocket error:", err)

})

 

🧠 WebSocket Utilities

eefp exposes helpful WebSocket helpers:

🔹 Get WebSocket Server

js

Copy

const wss = app.getWss()

🔹 Get All Connected Clients

js

Copy

const clients = app.getAllClients()

console.log("Total clients:", clients.size)

🔹 Close All Clients

js

Copy

app.closeAllClients(1000, "Server shutting down")

 

📡 Server-Sent Events (SSE) Support

eefp makes SSE endpoints easy.

➤ Create an SSE Route

js

Copy

app.sse("/events", (req, res) => {

  res.write("data: Connected to SSE\n\n")

})

Clients can connect using:

js

Copy

const es = new EventSource("/events")

es.onmessage = e => console.log(e.data)

➤ Broadcast SSE Messages

js

Copy

app.broadcastSse("Hello all clients!")

👥 Get All SSE Clients

js

Copy

const clients = app.getAllSseClients()

console.log("SSE clients:", clients.size)

 

🔁 Router Support

eefp works with Express Routers for both WebSocket and SSE.

➤ WebSocket Routes in Router

js

Copy

const express = require("express")

const router = express.Router()

// Parameterized WS route

router.ws("/room/:roomId", (ws, req) => {

  console.log("Room ID:", req.params.roomId)

  ws.send(Welcome to room ${req.params.roomId})

})

// WS route with middleware

router.ws("/secure",

  (req, res, next) => {

  console.log("Router middleware executed")

  next()

  },

  (ws, req) => {

  ws.send("Secure WS connection established in router")

  }

)

app.use("/api", router)

// Now WS routes are /api/room/:roomId and /api/secure

➤ SSE Routes in Router

js

Copy

const router = express.Router()

router.sse("/stream", (req, res) => {

  res.write("data: Router SSE Connected\n\n")

})

app.use("/api", router)

// SSE endpoint is /api/stream

Notes:

Route parameters (:param) and wildcards (*) work inside routers.

Middleware in routers executes for WS and SSE routes.

Express-style error handling works across routers.

 

🎯 How It Works

eefp(app) internally:

Adds WebSocket support using ws

Adds SSE support using native HTTP streams

Overrides app.listen() to attach protocol servers automatically

Keeps track of connected clients

Supports advanced WS routing with parameters, wildcards, middleware, and Express-style error handling

No extra configuration required.

 

📄 API Summary

WebSocket

Method

Description

app.ws(path, ...handlers)

Create WebSocket route (supports middleware, params, wildcards)

app.getWss()

Get WebSocketServer instance

app.getAllClients()

Get all connected WS clients

app.closeAllClients(code, msg)

Close all WS clients

Copy table

SSE

Method

Description

app.sse(path, ...handlers)

Create SSE route

app.broadcastSse(message)

Send message to all SSE clients

app.getAllSseClients()

Get all connected SSE clients

Copy table

🛡️ Requirements

Node.js 16+

Express

ws