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

@generata/serve

v0.2.0

Published

HTTP server for Generata workflow handlers - auto-discovers user scripts and runs them with Bearer auth and disk-persisted run state.

Downloads

75

Readme

@generata/serve

HTTP server for Generata workflow handlers. Auto-discovers user-authored handler scripts under serve/, mounts each at POST /<route>, and runs them in-process with Bearer auth, async run lifecycle (202 + status URL), and disk-persisted run state.

Install

pnpm add @generata/serve

Quickstart

  1. Drop a handler script under serve/ in your project:
// serve/review.ts
import type { Handler } from "@generata/serve";
import { reviewWorkflow } from "../workflows/review.ts";

const handler: Handler = async ({ body, runAsync }) => {
  return runAsync(reviewWorkflow, { pr: String(body.pr_number) });
};

export default handler;
  1. Set the auth token and start the server:
export GENERATA_SERVE_TOKEN=$(openssl rand -hex 32)
pnpm generata-serve --port 3000
  1. Fire a request:
curl -X POST http://127.0.0.1:3000/review \
  -H "Authorization: Bearer $GENERATA_SERVE_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"pr_number": 123}'
# → 202 with { "runId": "..." } and Location: /runs/<id>

curl http://127.0.0.1:3000/runs/<id> \
  -H "Authorization: Bearer $GENERATA_SERVE_TOKEN"
# → { "runId": "...", "status": "pending"|"completed"|"failed", ... }

Handler shapes

Sync (200 response, blocks until done):

import type { Handler } from "@generata/serve";

const handler: Handler = async ({ body, runWorkflow }) => {
  const result = await runWorkflow(myWorkflow, { input: String(body.input) });
  return { ok: true, summary: result.steps.summary?.output };
};
export default handler;

Async (202 response, run continues in background):

import type { Handler } from "@generata/serve";

const handler: Handler = async ({ body, runAsync }) => {
  return runAsync(myWorkflow, { input: String(body.input) });
};
export default handler;

runAsync takes (workflow, args, options?) matching runWorkflow's 3-arg signature.

CLI

generata-serve [options]

  --port <number>          Listen port (default 3000)
  --host <string>          Listen host (default 127.0.0.1)
  --serve-dir <path>       Override serveDir from config
  --token-env <name>       Env var name for the auth token (default GENERATA_SERVE_TOKEN)
  --shutdown-timeout <s>   Drain timeout on SIGTERM (default 30)
  --help                   Show help

Config

generata.config.ts:

import { defineConfig } from "@generata/core";

export default defineConfig({
  serve: {
    serveDir: "serve",
    port: 3000,
    host: "127.0.0.1",
    tokenEnv: "GENERATA_SERVE_TOKEN",
    bodyLimitBytes: 1024 * 1024,
    shutdownTimeoutSec: 30,
    runStoreDir: ".generata/runs",
  },
});

CLI flags override config; config overrides built-in defaults.

Webhook signature verification

Built-in HMAC verification (GitHub, Slack, Stripe, etc.) is intentionally out of scope for v1. Two recommended patterns:

Reverse-proxy (Caddy example for GitHub):

example.com {
  reverse_proxy /webhook 127.0.0.1:3000 {
    header_up Authorization "Bearer {env.GENERATA_SERVE_TOKEN}"
  }
}

(Pair with a Caddy plugin or sidecar that verifies X-Hub-Signature-256 before forwarding.)

In-handler verification: do it inside the handler itself by reading the relevant header from body (after JSON-parsing) plus a known secret. Note that body is parsed from the request - if you need byte-level signature verification you'll want a reverse proxy in front.

Limitations

  • v1 is single-process and in-memory + disk-persisted. No multi-tenant isolation, no rate limiting.
  • Handlers run in the daemon's Node process; one bad handler can affect concurrent requests in the same process.
  • Token rotation requires daemon restart.
  • Run state is never auto-evicted (infinite TTL by design - delete files under .generata/runs/ to reclaim disk).