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

@flowlib/http

v0.0.7

Published

Framework-agnostic HTTP route registry shared by Flowlib's Express, NestJS, and Next.js adapters. Walk `allFirstPartyEndpoints` to build a custom adapter (Hono, Fastify, etc.) without re-implementing route logic.

Downloads

232

Readme


Every first-party Flowlib HTTP route — /flows/*, /flow-runs/*, /credentials/*, /triggers/*, /chat/*, /oauth2/*, /dashboard/*, /agent/*, /nodes/*, /node-data/*, /actions/* — is declared once in this package as a FlowlibHttpEndpoint and consumed by every adapter (@flowlib/express, @flowlib/nestjs, @flowlib/nextjs).

If you're running Flowlib on an officially-supported framework, you don't import this package directly. It exists for custom adapter authors: walk allFirstPartyEndpoints, translate each FlowlibHttpResult to your host framework's response, and you have a complete fourth adapter — Hono, Fastify, Bun.serve, Cloudflare Workers, Deno — without re-implementing any route logic.

Install

npm install @flowlib/http @flowlib/core

Building a custom adapter

import { Hono } from 'hono';
import { createFlowlib } from '@flowlib/core';
import {
  allFirstPartyEndpoints,
  runEndpoint,
  matchHttpEndpoint,
  type FlowlibHttpResult,
} from '@flowlib/http';

const flowlib = await createFlowlib({
  /* config */
});

const app = new Hono();

app.all('/api/flowlib/*', async (c) => {
  const url = new URL(c.req.url);
  const path = url.pathname.replace(/^\/api\/flowlib/, '');

  const matched = matchHttpEndpoint(allFirstPartyEndpoints, c.req.method, path);
  if (!matched) {
    return c.json({ error: 'not_found' }, 404);
  }

  const result: FlowlibHttpResult = await runEndpoint({
    endpoint: matched.endpoint,
    pathParams: matched.pathParams,
    request: c.req.raw, // standard Web Request
    flowlib,
    identity: null, // populate from your auth layer
  });

  return new Response(result.body, {
    status: result.status,
    headers: result.headers,
  });
});

Each endpoint declares its method, path, auth, parsing, and handler — the registry is the single source of truth. The first-party adapters are a few dozen lines of glue on top of this; see pkg/express/src/mount-endpoints.ts and pkg/nextjs/src/index.ts in the Flowlib repo.

What's exported

  • allFirstPartyEndpoints — canonical ordered registry array.
  • Per-slice exports: flowsEndpoints, flowRunsEndpoints, triggersEndpoints, credentialsEndpoints, oauth2Endpoints, chatEndpoints, agentEndpoints, dashboardEndpoints, flowExecutionEndpoints, runEventsEndpoints, nodeDataEndpoints, nodesEndpoints.
  • defineEndpoint, runEndpoint, matchHttpEndpoint — for declaring your own slices.
  • dispatchPluginEndpoint, matchPluginEndpoint — plugin endpoint pipeline (separate from first-party routes).
  • Express bridge (toWebRequestFromExpress, writeFlowlibHttpResultToExpress, writeWebResponseToExpress) — convert between Express's req/res and Web standards. Useful if your custom adapter wraps Express.
  • Shared parsers (parseJsonQueryParam, parsePagination, parseBooleanQueryParam, coerceSingleQueryValue) and the error classifier (classifyHttpError).
  • Authorization helper (authorizeEndpoint) — runs the same plugin-driven onAuthorize pipeline the first-party adapters use.

Notes for adapter authors

  • Endpoints that stream (SSE) return a FlowlibHttpResult whose body is a ReadableStream. The adapter is responsible for piping it back to the client; the Express bridge in this package does it for that adapter.
  • Endpoints set their own Set-Cookie headers (e.g., the OAuth2 callback). Adapters must propagate every header — don't JSON.stringify the result and lose them.
  • The plugin endpoint dispatcher (dispatchPluginEndpoint) is a separate pipeline from runEndpoint. Match /plugins/* first; everything else flows through matchHttpEndpoint(allFirstPartyEndpoints, …).
  • The package depends on @flowlib/core for endpoint handlers — handlers call into flowlib.flows.*, flowlib.runs.*, etc. You can't use @flowlib/http without an FlowlibInstance.

License

MIT