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

halofx

v0.0.3

Published

A better TypeScript webapp framework

Readme

HALO - Framework Documentation

A lightweight TypeScript web framework with routing, middleware, and React server-side rendering support.

Features

  • Flexible routing system with wildcards and parameter capture
  • Middleware pipeline for request processing
  • Action results with content negotiation
  • React server-side rendering support
  • TypeScript-first development

Usage

Install the package from npm:

npm install halo

Create a new application with a routing table and start the server:

import React from 'react';
import { Application } from 'halo';
import { json, redirect, stringResult } from 'halo/results';

// 1. Create application instance
const app = new Application();

// 2. Define routes
app.configuration.router
  // Basic string response
  .get('/', async (ctx) => stringResult('Welcome to HALO!'))

  // Return objects with content negotiation - JSON by default
  .get('/api/users/{id}', async (ctx) => {
    const { id } = ctx.params;
    return { id, name: 'John Doe' };
  })

  // React component rendering
  .get('/profile', ProfileComponent)

  // Error handling
  .get('/error', async () => {
    throw new Error('Something went wrong');
  })

  // Wildcard routing
  .get('/files/{path:*}', async (ctx) => {
    const { path } = ctx.params;
    const contents = await readFile(path + '.txt', 'utf8');
    return content(contents, 'text/plain');
  });

// 3. Start the server
app.listen(3000);

// React component example
function ProfileComponent(props: Context) {
  return (
    <div>
      <h1>Profile Page</h1>
      <p>Method: {props.request.method}</p>
    </div>
  );
}

Routing

Basic routing is handled through the RouteTable class:

const app = new Application();
app.configuration.router
  .get('/hello', async (ctx) => 'Hello World!')
  .post('/api/items', async (ctx) => json({ success: true }))
  .get('/users/{id}', async (ctx) => `User ${ctx.params.id}`);

Route Parameters and Wildcards

The routing system supports wildcards and parameter capture:

// Wildcard capture
.get('/files/{path:*}', ctx => stringResult(ctx.params.path))

// Parameter with regex constraint
.get('/users/{id:[0-9]+}', ctx => stringResult(ctx.params.id))

// Multiple parameters
.get('/posts/{year}/{month}/{slug}', ctx => stringResult(ctx.params.slug))

// Wildcard without capture
.get('/static/*', ctx => stringResult('Static files'))

Middleware

Middleware executes in a chain before and after route handling:

new Application({
  middleware: [
    LoggingMiddleware,
    ErrorHandlingMiddleware,
    // RouterMiddleware is automatically added last
  ]
});

You can create your own middleware by implementing the IMiddleware interface:

class LoggingMiddleware implements IMiddleware {
  async execute(ctx: Context, next: NextFunction) {
    console.log(`Request: ${ctx.request.url}`);
    await next();
    console.log(`Response: ${ctx.response.statusCode}`);
  }
}

Action Results

Action Results control response generation:

// Built-in results
return json({ data: 'value' });
return stringResult('Hello');
return redirect('/login');
return notFound();
return xml({ root: 'value' });
return statusCode(404);
return empty();

ActionResults are responsible for formatting response data for the output stream.

Adding Custom Action Results

Create a class implementing IActionResult:

class CustomJsonResult implements IActionResult {
  constructor(private data: any) {}
  
  executeResult(output: IOutputChannel) {
    output.writeHeaders(200, {'Content-Type': 'application/custom'});
    output.writeBody(JSON.stringify(this.data));
    output.end();
  }
}

Content Negotiation

The framework automatically handles content negotiation based on Accept headers whenever you return an object from a route handler:

// Returns JSON or XML based on Accept header
return { data: 'value' };

// Force JSON response - no negotiation
return json({ data: 'value' });

Content negotiation will be bypassed if you return an IActionResult directly.

React Server Rendering

Three ways to use React components:

// Pass component directly
.get('/page1', MyComponent)

// Return from handler
.get('/page2', async (ctx) => <MyComponent {...ctx} />)

// Pass pre-rendered element
.get('/page3', <MyComponent />)

Components receive the Context object as props:

function MyComponent(props: Context) {
  return <div>Method: {props.request.method}</div>;
}