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

@fuguejs/pg

v0.5.1

Published

PostgreSQL capability adapter for Fugue workflows.

Readme

@fuguejs/pg

PostgreSQL capability adapter for Fugue workflows.

Installation

bun add @fuguejs/pg pg zod

pg and zod are peer dependencies — pg provides the connection pool, zod the schemas every query/queryOne call validates against.

Usage

Register with the host

import { createPgAdapter } from "@fuguejs/pg";

const pgHandle = createPgAdapter({
  connectionString: process.env.DATABASE_URL!,
  poolSize: 20,
  statementTimeoutMs: 15_000,
});

// Pass to SharedInfra capabilities:
const sharedInfra = {
  // ... other infra ...
  capabilities: [pgHandle],
};

Use in a node

import { createFetchNode } from "@fuguejs/framework";
import { z } from "zod";

const UserSchema = z.object({
  id: z.string(),
  name: z.string(),
  email: z.string().email(),
});

const fetchUser = createFetchNode({
  id: "fetch-user",
  inputSchema: z.object({ userId: z.string() }),
  outputSchema: UserSchema,
  requires: ["db"] as const,
  fetch: async (input, ctx) => {
    // ctx.db is typed as PgCapability — non-null, schema-validated
    return ctx.db.queryOne(
      UserSchema,
      "SELECT id, name, email FROM users WHERE id = $1",
      [input.userId],
    );
  },
});

Testing with the fake

import { createFakePgCapability } from "@fuguejs/pg";

const fakeDb = createFakePgCapability({
  "SELECT * FROM users WHERE id": [
    { id: "1", name: "Alice", email: "[email protected]" },
  ],
  "INSERT INTO orders": { rowCount: 1 },
});

// Use in tests via makeNodeContext:
const ctx = makeNodeContext({
  runId: "test-run",
  dagId: "test-dag",
  capabilities: { db: fakeDb.client },
});

API

PgCapability

| Method | Description | |--------|-------------| | query<T>(schema, sql, params?) | Execute query, validate all rows against Zod schema | | queryOne<T>(schema, sql, params?) | Execute query, validate first row (or null) | | execute(sql, params?) | Execute write, return { rowCount } | | queryRaw(sql, params?) | Escape hatch: raw unknown[] rows, no validation — prefer query with a schema |

All methods return Result<T, FrameworkError> — no exceptions escape.

createPgAdapter(config)

Creates a CapabilityHandle<"db"> with lifecycle management:

  • connect(): validates connectivity with SELECT 1
  • close(): drains the connection pool
  • healthCheck(): SELECT 1, racing a 5s timeout (a hung pool reports unhealthy)

Config options: poolSize (default 10), statementTimeoutMs (default 30000, applied as the pool's statement_timeout), connectionTimeoutMs (default 5000), idleTimeoutMs (default 10000).

createFakePgCapability(routes)

In-memory fake for testing. Routes are matched by exact SQL or longest prefix match.