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

@flancer32/teq-web

v0.3.1

Published

Node.js web plugin supporting Express and Fastify integration, with built-in server for standalone operation

Readme

@flancer32/teq-web

@flancer32/teq-web is a modular request dispatcher and web server for Node.js applications.
It follows the principles of the TeqFW architecture but works independently and can be integrated into any Node.js project.
The plugin offers a flexible, pluggable HTTP/2-capable server with three-stage handler processing and dependency-driven execution order.


Overview

This package provides:

  • A dispatcher that processes HTTP requests in three well-defined stages: pre, process, post.
  • A handler interface for modular request handling across plugins or components.
  • A built-in server based on Node.js libraries (http, http2), supporting TLS via http2.createSecureServer().
  • Support for relative handler ordering using before / after declarations and topological sorting.
  • Compatibility with external servers like Express/Fastify by using the dispatcher as middleware.
  • Minimal dependencies and full support for dependency injection via @teqfw/di.

Architecture

The dispatcher runs HTTP requests through a consistent three-phase pipeline:

  1. Pre-processing (pre) — All handlers are executed in a defined order (e.g., logging, authentication).
  2. Processing (process) — Handlers are checked sequentially until one returns true (request handled).
  3. Post-processing (post) — All handlers are executed unconditionally, even after errors.

Each handler provides its registration metadata via the getRegistrationInfo() method. Execution order is resolved with a built-in implementation of Kahn's algorithm.

Example handler definition:

const My_Handler = {
    getRegistrationInfo: () => Object.freeze({
        name: 'My_Handler',
        stage: 'process', // can be 'pre', 'process', or 'post'
        before: [],
        after: [],
    }),

    handle: async (req, res) => {
        res.writeHead(200, {'Content-Type': 'text/plain'});
        res.end('Hello from My_Handler!');
        return true;
    },
};

export default My_Handler;

Usage

This example shows how to create a minimal application that:

  • Registers two handlers: a logger and a static file server
  • Starts a secure HTTPS server using built-in components

The static handler reads from one or more sources described by the Handler_Source DTO. To expose selected files from node_modules, create a source with root: 'node_modules' and pass it to Handler_Static during initialization.

import Container from '@teqfw/di';
import {readFileSync} from 'node:fs';
import {join, resolve} from 'node:path';
import {fileURLToPath} from 'node:url';

// Resolve working directory
const __filename = fileURLToPath(import.meta.url);
const __dirname = resolve(__filename, '..');
const webRoot = join(__dirname, 'web');
const certs = join(__dirname, 'certs');

// DI container setup
const container = new Container();
const resolver = container.getResolver();
resolver.addNamespaceRoot('Fl32_Web_', './node_modules/@flancer32/teq-web/src');

// Get and configure built-in handlers
const logHandler = await container.get('Fl32_Web_Back_Handler_Pre_Log$');
const staticHandler = await container.get('Fl32_Web_Back_Handler_Static$');
const SourceCfg = await container.get('Fl32_Web_Back_Dto_Handler_Source$');
const srcNpm = SourceCfg.create({
    root: 'node_modules',
    prefix: '/node_modules/',
    allow: {
        vue: ['dist/vue.global.prod.js'],
        '@teqfw/di': ['src/Container.js'],
    }
});
const srcWeb = SourceCfg.create({ root: webRoot, prefix: '/' });
await staticHandler.init({sources: [srcNpm, srcWeb]});

// Register handlers
const dispatcher = await container.get('Fl32_Web_Back_Dispatcher$');
dispatcher.addHandler(logHandler);
dispatcher.addHandler(staticHandler);

// Create and start the server
const server = await container.get('Fl32_Web_Back_Server$');
await server.start({
    port: 3443,
    type: 'https',
    tls: {
        key: readFileSync(join(certs, 'key.pem'), 'utf8'),
        cert: readFileSync(join(certs, 'cert.pem'), 'utf8'),
        ca: readFileSync(join(certs, 'ca.pem'), 'utf8'),
    }
});

This will start an HTTPS server on port 3443 with:

  • Fl32_Web_Back_Handler_Pre_Log logging each request method and URL;
  • Fl32_Web_Back_Handler_Static serving files from node_modules and the /web folder.

Using with Express or Fastify

The dispatcher can be connected to external web frameworks instead of the built-in server.

// Express
const app = Express();
app.use(async (req, res) => {
    await dispatcher.onEventRequest(req, res);
});
app.listen(3000);

// Fastify
const fastify = Fastify();
fastify.all('*', async (request, reply) => {
    const req = request.raw;
    const res = reply.raw;
    await dispatcher.onEventRequest(req, res);
});
await fastify.listen({port: 3000});

Installation

npm install @flancer32/teq-web

This plugin requires a configured @teqfw/di container and optionally integrates with TeqFW-based apps.


Status

This package is under active development and already used in real-world applications. Documentation is built using the 3DP method (Dialog-Driven Development Process) and evolves alongside actual use cases.