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

ht-web-framework

v3.0.1

Published

HT Webserver Framework, now as a centralized module

Downloads

33

Readme

ht-web-framework

A modular, extensible Express.js-based web server framework for Node.js, designed for rapid development of web applications with flexible routing, templating, and security features.

Features

  • Express.js core with easy configuration
  • Automatic route generation from a pagemap (JSONC)
  • Multiple template engine support: Mustache, EJS, Handlebars
  • Static file serving (customizable)
  • Security headers and real IP detection (supports proxies and Cloudflare)
  • Custom error handling with verbose/debug options
  • Flexible middleware and script hooks for routes
  • Built-in logging (console and file)

Installation

Add to your project (as a dependency):

npm install ht-web-framework --registry https://repo.ht-dev.de

Or, if using as a local dependency (see package.json):

npm install /path/to/ht-web-framework
"dependencies": {
  "ht-web-framework": "file:/path/to/ht-web-framework"
}

Usage

1. Import and Initialize

import { Server } from 'ht-web-framework';

// Load your config and pagemap (JSONC or JSON)
const config = {
  port: 8080,
  views: 'views',
  static: 'public',
  logging: true,
  logFile: 'logs/server.log',
  trustedProxies: ['127.0.0.1'],
  verboseErrors: true,
  // ...other options
};

const pagemap = `
{
  // Example pagemap structure
  "settings": {
    "title": "My App",
    "scripts": []
  },
  "navpages": [
    { "url": "/", "title": "Home" }
  ],
  "paths": {
    "get": {
      "/": { 
        "file": "index",
        "settings": {
            "type": "mustache"
        }
      }
    }
  }
}
`;

const server = new Server(config, pagemap);

2. Generate Routes

server.generateRoutes();

3. Start the Server

server.start(8080); // or omit to use config.port

Configuration

  • config: Main server configuration object.

    • port: Port to listen on.
    • views: Directory for view templates.
    • static: Directory for static files.
    • logging: Enable/disable file logging.
    • logFile: Path to log file.
    • trustedProxies: Array of trusted proxy IPs.
    • verboseErrors: Show detailed error messages.
    • embedSite: (Optional) Allow embedding from a specific site via CORS.
  • pagemap: JSON or JSONC string/object describing navigation, routes, and settings.

    • settings: Global settings (title, scripts, etc).
    • navpages: Array of navigation pages.
    • paths: Object mapping HTTP methods to route definitions.

Template Engines

  • Mustache (.mustache)
  • EJS (.ejs)
  • Handlebars (.handlebars)

Set the type property in your pagemap route to select the engine.

Any other static file can also be served with the type static, file or image.


Static Files

  • /static/builtin serves built-in assets.
  • /static serves your configured static directory.

Error Handling

  • Custom error pages for HTML and JSON requests.
  • Verbose stack traces if verboseErrors is enabled.

Security

  • Sets strict security headers by default.
  • Real IP detection supports proxies and Cloudflare.
  • Referrer, feature, and frame policies included.

Example

import { Server } from 'ht-web-framework';

const config = {
  port: 3000,
  views: 'views',
  static: 'public',
  logging: false,
  trustedProxies: ['127.0.0.1'],
  verboseErrors: true,
};

const pagemap = `
{
  "settings": { "title": "Demo", "scripts": [] },
  "navpages": [{ "url": "/", "title": "Home" }],
  "paths": {
    "get": {
      "/": { 
        "file": "index",
        "settings": {
            "type": "mustache"
        }
      }
    }
  }
}
`;

const server = new Server(config, pagemap);
server.generateRoutes().start();

License

MIT


See Also