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

fluxion-ts

v0.0.12

Published

Fluxion is able to start a server that can dynamically load routers and js files. It is designed to be used to replace PHP

Readme

Fluxion

npm version npm downloads License: MIT

Fluxion is a filesystem-routing dynamic server for Node.js.

  • Use .mjs files directly as route handlers
  • Run handlers inside worker runtime isolation
  • Inject any npm module into handler context via modules
  • If a handler returns a value, Fluxion auto-responds with 200 + JSON

Install

npm install fluxion

Quick Start

1) Start the server

Create server.mjs:

import { fluxion } from 'fluxion';

fluxion({
  dir: './dynamicDirectory',
  host: '127.0.0.1',
  port: 3000,
});

2) Create a route handler

Create dynamicDirectory/hello.mjs:

export default function handler(_req, _res, context) {
  return {
    message: 'hello fluxion',
    workerId: context.worker.id,
  };
}

Run:

node server.mjs

Test:

curl http://127.0.0.1:3000/hello

You will get a JSON response with status 200.

Routing Rules

  • dynamicDirectory/index.mjs -> /
  • dynamicDirectory/user.mjs -> /user
  • dynamicDirectory/user/index.mjs -> /user
  • Non-.mjs files are served as static files (GET/HEAD)
  • Directories/files starting with _ are private and not routable

Handler Styles

Function export

export default function handler(req, res, context) {
  return { ok: true };
}

Object export (with modules)

export default {
  modules: [
    {
      module: 'node:crypto',
      injectKey: 'crypto',
      factory: (cryptoModule) => cryptoModule,
    },
  ],
  handler(_req, _res, context) {
    return {
      hash: context.crypto.createHash('sha1').update('abc').digest('hex'),
    };
  },
};

Automatic JSON Response

If a handler return value is not undefined and you do not manually call res.end(), Fluxion will automatically:

  • set status to 200
  • set content-type to application/json; charset=utf-8 (if missing)
  • serialize the return value with JSON.stringify(...)

Recommended pattern per handler:

  1. Return data directly (recommended)
  2. Or fully control res manually (streaming, file download, etc.)

Module Injection (Recommended)

Fluxion does not bundle database drivers. Install app dependencies yourself.

For example, to use MySQL in handlers:

npm install mysql2
export default {
  modules: [
    {
      module: 'mysql2/promise',
      injectKey: 'mydb',
      options: {
        host: '127.0.0.1',
        user: 'root',
        password: '***',
        database: 'demo',
      },
      factory: (mysql2, options) => mysql2.createPool(options),
    },
  ],
  async handler(_req, _res, context) {
    const [rows] = await context.mydb.query('select 1 as ok');
    return rows;
  },
};

modules fields

  • module: module id used by dynamic import()
  • injectKey: target key in context[injectKey]
  • options: custom config passed into factory
  • factory: (importedModule, options, runtime) => injectedValue

factory runs inside the worker and is restored from source text. Keep it self-contained (do not depend on outer closures).

Each worker keeps its own module instances. On worker shutdown, Fluxion will attempt dispose/close/end/destroy if present.

Common Options

Main fluxion({...}) options:

  • dir: dynamic directory (handler root)
  • host: listen host
  • port: listen port
  • metaPort: primary meta API port (defaults to port + 1)
  • maxRequestBytes: max request body size (returns 413 when exceeded)
  • logger: one-line / json-line / custom function

Meta APIs

Meta APIs are served by the primary process on metaPort:

  • GET /_fluxion/healthz
  • GET /_fluxion/workers (worker status + cpu/memory stats)

Important

Legacy handler-level db declarations are removed:

export default {
  // db: ['main'] // no longer supported
  modules: [],
  handler() {},
};

Use modules for dependency injection.