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

@kromi77/express-rh

v0.0.2-alpha.3

Published

Self created routes handler for express.js

Readme

@kromi77/express-rh

Table of contents

☕️ About ERH

The package was created from a spontaneous idea that came up while my friends and I were working on a joint project (a social platform) for a university course. Since we used Express to build the backend for our project, I took on the task of creating a route handler, which became the foundation of the current state of the package you see here. I really liked Next.js and the way it handles routing, so I wanted this handler to closely replicate that behavior.

📀 Requirements

Express.JS Node.JS or Bun

🔧 Installation

For npm:

npm i @kromi77/express-rh

For bun:

bun add @kromi77/express-rh

🚀 Quick start

ESM

//index.ts
import ERH from "@kromi77/express-rh";
import express from "express";
import path from "path";
const routes = new ERH({
	app: express(),
	endpointsFolder: path.join(__dirname, "endpoints"),
	useParentPath: true,
	baseRoute: "/api/v1/",
});
// endpoints/get/users.ts
import { Response, Request } from "express";
export default {
	callback: (req: Request, res: Response) => {
		res.send("Hello from GET/users.js!");
	},
};

CJS

//index.js
const { ERH } = require("@kromi77/express-rh");
//OR
//const ERH = require('@kromi77/express-rh').default;
const express = require("express");
const path = require("path");
const routes = new ERH({
	app: express(),
	endpointsFolder: path.join(__dirname, "endpoints"),
	useParentPath: true,
	baseRoute: "/api/v1/",
});
// endpoints/get/users.js
module.exports = {
	callback: (req, res) => {
		res.send("Hello from GET/users.js!");
	},
};

📖 Documentation

ERH Options

| Option | Type | Required | Default | Description | | :------------------------: | :-----------------: | :----------: | :-------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------: | | app | express.Application | ✅ | - | Instance of express application | | endpointsFolder | string | ✅ | - | Path to folder with endpoints. Inside this folder remember to create folders that will match naming of methods like GET, POST, PUT etc. | | host | string | ❌ | localhost | Host to listen on | | port | number | ❌ | 3000 for public 8080 or 0 for dev | Port to listen on | | baseRoute | string | ❌ | / | Base api route that will be added before endpoint ex. /api/v1/ then endpoint will look like /api/v1/yourendpoint | | devMode | boolean | ❌ | false | If dev server should be created | | devModeRoute | string | ❌ | /dev | You route that will be added before dev endpoint ex. /dev/v2 then endpoint will look like /dev/v2/yourendpoint | | useBuiltInLogger | boolean | ❌ | true | Whether you want to use built in logger to log every endpoint call | | useBuiltInRateLimiter | boolean | ❌ | true | Whether you want to use built in rate limiter that using express-rate-limit with values described in usage section | | useBuiltInCors | boolean | ❌ | true | Whether you want to use built in cors from cors package | | useBuiltInJsonParser | boolean | ❌ | true | Whether you want to use built in json parser from express | | useBuiltInUrlEncodedParser | boolean | ❌ | true | Whether you want to use built in url encoded parser from express | | useParentPath | boolean | ❌ | false | Whether to use directory structure as base path for endpoints | | middlewareFolder | string | ❌ | - | Folder with middlewares | | staticFolders | string[] | ❌ | - | List of folders with static content | | staticBasePath | string | ❌ | /static | Base api route for static files | | startCallback | function | ❌ | simple log | Whether you want to overwrite base server start callback |

Interface IMiddlewareModule

| Property | Type | Required | Default | Description | | :----------: | :---------------: | :----------: | :---------: | :---------------------------------------------------: | | callback | function | ✅ | - | Callback function with functionality of middleware | | name | string | ❌ | - | Name of middleware module | | global | boolean | ❌ | true | Whether middleware should be used among all endpoints | | matcher | string[] (RegExp) | ❌ | - | Whether middleware should be used matched paths | | ignore | boolean | ❌ | false | Whether middleware should be ignored from setting up |

Interface IEndpointModule

| Property | Type | Required | Default | Description | | :----------: | :------------------: | :----------: | :---------: | :-------------------------------------------: | | path | string | ❌ | - | Override the default path of the endpoint | | middlewares | IMiddlewareModule [] | ❌ | [] | Define middleware to run on endpoint call | | callback | Function | ✅ | - | Callback function with endpoint functionality |

🔍 Good to know

  • If you use one of --public, -p, --host, -h flags then handler will try to host your app publicly

  • Adding . in name of your endpoint file will extend a path eg. products.list.js will result path: basepath/products/list

  • Using [id] as your folder name will result dynamic path it's same as using :id

🚨 Issues

If you see any improvements to make or found a bug feel free to open an issue with this template

Type: Issue | Improvement
Description of issue or improvement:
Express version:
NodeJS version:
ERH version:
Additional info: