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

express-route-forge

v0.4.0

Published

Express JS router builder

Readme

Documentation in progress

Express router forge

Large utils package to build easily an Express JS application. Flexibility to create routers, include middlewares, handle errors and create the express app.

Create the app

You can create an App class and extends of ExpressApp.

// src/App.ts

import express from 'express';
import { AppConfig, ExpressApp } from 'express-route-forge';
import dotenv from 'dotenv';
import { resolve } from 'path';

// For env File | if you need it
dotenv.config();

export default class App extends ExpressApp {
  /**
   * Port to listen the server
   */
  public port: string = process.env.PORT || '8000';

  /**
   * Create Server instance
   *
   * @returns App instance
   */
  static getInstance(): ExpressApp {
    /* Path to load all your controllers | will take a look in a moment */
    const absolutePath = resolve(__dirname, '../controllers');
    const config: AppConfig = {
      autoLoad: {
        paths: [absolutePath],
        exclude: ['tests'],
      },
      cors: true,
      morgan: true,
      bodyParser: true,
    };

    return ExpressApp.initInstance(express(), config);
  }
}

Start the server

// src/index.ts

import App from './App';

const app = App.getInstance();
app.port = process.env.PORT || '8000';

app.start(() => {
  console.info(`Server is Fire at http://localhost:${app.port}`);
});

Create first controller

Les't create a basic class HomeController.

// src/controllers/HomeController.ts

import {
  CoreController,
  CoreRouter,
  CoreRouterUtil,
  RouteConfig,
} from 'express-route-forge';
import RootRouterUtil from '@app/server/routers/RootRouterUtil';

export default class HomeController extends CoreController {
  async index() {
    this.response.success({
      name: 'Restful API',
    });
  }
}

const config: RouteConfig<HomeController> = {
  handler: 'index',
  method: Method.GET,
  path: '',
  controller: HomeController,
}
const rootRouter = new CoreRouter<HomeController>();
CoreRouterUtil.single(config, rootRouter);

Start the server

Create a dev script command. The script should be something like

{
  "scripts":{
    "dev": "nodemon ./src/index.ts",
  }
}

Now just run yarn dev

[nodemon] 3.1.7
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): src\**\*
[nodemon] watching extensions: ts,json
[nodemon] starting `ts-node -r tsconfig-paths/register ./src/index.ts`
⚓ Router [GET] / added
Server is Fire at http://localhost:8000

This is the basic configuration, but you can also create your own CoreRouter to encapsulate router behaviors, register middlewares, and create custom main controllers to manage authorizations and more.

Authentication

Auth is pluggable and optional. The barrel exports a generic middleware plus the provider contract; concrete providers live in opt-in adapters so their dependencies are only needed if you use them.

import { authenticate, AuthProvider } from 'express-route-forge';

const myProvider: AuthProvider = {
  async authenticate(req) {
    const token = req.headers.authorization?.split(' ')[1];
    if (!token) return null;                    // 401 (unless optional)
    const user = await verifySomehow(token);    // throw => 401 with message
    return { id: user.id, claims: user };
  },
};

// Identity is stored in res.locals.authUser (configurable via localsKey)
router.single({ ..., middlewares: [authenticate(myProvider)] });

Firebase adapter

Requires firebase-admin (optional peer, loaded lazily).

import { authenticateFirebase, firebaseAuthProvider, initWithServiceAccount }
  from 'express-route-forge/adapters/firebase';

// Back-compat with 0.3.x: identity in res.locals.firebaseUser
app.use(authenticateFirebase());

WorkOS adapter

Requires @workos-inc/node and jose (optional peers, loaded lazily). Supports AuthKit Bearer access tokens (verified against the WorkOS JWKS) and sealed session cookies (needs a cookie parser upstream).

import { authenticateWorkos } from 'express-route-forge/adapters/workos';

app.use(authenticateWorkos({
  apiKey: process.env.WORKOS_API_KEY!,
  clientId: process.env.WORKOS_CLIENT_ID!,
  cookiePassword: process.env.WORKOS_COOKIE_PASSWORD, // for sealed sessions
}));

Migrating from 0.3.x

authenticateFirebase moved out of the barrel — one line to migrate:

- import { authenticateFirebase } from 'express-route-forge';
+ import { authenticateFirebase } from 'express-route-forge/adapters/firebase';

res.locals.firebaseUser is preserved, but it is now a normalized AuthIdentity ({ id, claims, raw }); the decoded Firebase token is at firebaseUser.claims. See CHANGELOG.md for details.

TODOs

[ ] Finish README.md [ ] Test coverage for all modules [ ] Minimum project setup