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

pq-befu

v0.1.0

Published

Node.js SDK for the PQ Platform — error tracking, feedback, and ticketing. Works with Express, Fastify, Koa, NestJS, or any Node.js app.

Readme

PQ SDK

Node.js SDK for the PQ Platform — error tracking, feedback, and ticketing.

Zero runtime dependencies (uses only Node's built-in http/https). Works with Express, Fastify, Koa, NestJS, Electron, or any Node.js app.

The JS counterpart of the Python pq-befu package.

Install

npm install pq-befu

Framework adapters are optional — install what you use:

npm install express       # if using Express
npm install fastify       # if using Fastify
npm install koa           # if using Koa
npm install @nestjs/common rxjs   # if using NestJS
npm install electron      # if using Electron

Quick Start

const { PQClient } = require("pq-befu");

const pq = new PQClient({
  apiKey: "your_api_key",
  baseUrl: "http://localhost:8000",
});

// Report an error
await pq.captureError({ message: "Something broke", errorType: "TypeError" });

// Report a caught error
try {
  JSON.parse("{oops");
} catch (err) {
  await pq.captureException(err);
}

// Submit feedback
await pq.sendFeedback({ rating: 5, comment: "Great product!" });

// Create a ticket
await pq.createTicket({
  title: "Bug report",
  description: "Login fails on mobile",
  ticketType: "bug",
});

// Ensure all async requests complete before the process exits
await pq.flush();

Auto-Capture

Run a function, capture on failure

const { captureExceptions } = require("pq-befu");

await captureExceptions(pq, async () => {
  await doSomethingRisky();
}, { environment: "production" });

Wrap a function (decorator style)

const { autoCapture } = require("pq-befu");

const safe = autoCapture(pq, { environment: "production" })(async function myJob() {
  // exceptions here are auto-reported, then re-thrown
});

Global hooks (uncaught exceptions & unhandled rejections)

const { installHooks } = require("pq-befu");

const pq = new PQClient({ apiKey: "...", baseUrl: "..." });
const uninstall = installHooks(pq, { environment: "production" });

// Later: uninstall()

Framework Integrations

Express

const express = require("express");
const { PQClient } = require("pq-befu");
const { pqExpress } = require("pq-befu/integrations/express");

const app = express();
const pq = new PQClient({ apiKey: "your_key", baseUrl: "http://localhost:8000" });

const { middleware, errorHandler } = pqExpress({ client: pq, environment: "production" });
app.use(middleware);

// ...your routes...

app.use(errorHandler); // must be after routes

Or use the two middlewares independently:

const { pqErrorHandler, pqResponseHandler } = require("pq-befu/integrations/express");

app.use(pqResponseHandler(pq));   // captures 5xx responses
// routes...
app.use(pqErrorHandler(pq));      // captures thrown exceptions

Fastify

const fastify = require("fastify");
const { PQClient } = require("pq-befu");
const { pqFastify } = require("pq-befu/integrations/fastify");

const app = fastify();
const pq = new PQClient({ apiKey: "your_key", baseUrl: "http://localhost:8000" });

await app.register(pqFastify, { client: pq, environment: "production" });
// Fastify's default error handling is preserved; only 5xx errors are reported.

Koa

const Koa = require("koa");
const { PQClient } = require("pq-befu");
const { pqKoa } = require("pq-befu/integrations/koa");

const app = new Koa();
const pq = new PQClient({ apiKey: "your_key", baseUrl: "http://localhost:8000" });

app.use(pqKoa(pq, { environment: "production" }));
// routes...
// Errors are re-thrown so Koa's default error handler still responds.

NestJS

// main.ts
import { PqInterceptor } from "pq-befu/integrations/nestjs";
import { PQClient } from "pq-befu";

const app = await NestFactory.create(AppModule);
const pq = new PQClient({ apiKey: "your_key", baseUrl: "http://localhost:8000" });
app.useGlobalInterceptors(new PqInterceptor(pq, { environment: "production" }));

Or with DI:

import { Module } from "@nestjs/common";
import { PqSdkModule } from "pq-befu/integrations/nestjs";

@Module({
  imports: [PqSdkModule.forRoot({ apiKey: "your_key", baseUrl: "http://localhost:8000" })],
})
export class AppModule {}

Electron

Covers the main process (uncaught exceptions, unhandled rejections, renderer crashes, unresponsive renderers, child/GPU process crashes) and the renderer via an IPC bridge.

Main process

const { app, BrowserWindow } = require("electron");
const { PQClient } = require("pq-befu");
const { pqElectronMain } = require("pq-befu/integrations/electron");

const pq = new PQClient({ apiKey: "your_key", baseUrl: "http://localhost:8000" });
pqElectronMain(pq, { environment: "production" });

function createWindow() {
  const win = new BrowserWindow({
    webPreferences: {
      preload: require.resolve("pq-befu/preload"), // works in sandboxed renderers
    },
  });
  win.loadURL("https://example.com");
}

Renderer process (sandboxed is fine) — window.pq is exposed by the preload:

window.pq.captureError({ message: "renderer boom" });
window.pq.captureException(err, { environment: "production" });
window.pq.sendFeedback({ rating: 5, comment: "Great!" });
window.pq.createTicket({ title: "Bug report", description: "..." });

Renderer with direct network access (no IPC) — use the fetch-based client:

const { PQBrowserClient } = require("pq-befu/browser");
const pq = new PQBrowserClient({ apiKey: "your_key", baseUrl: "http://localhost:8000" });
await pq.captureException(err);

PQBrowserClient has the same API as PQClient and also works in the browser, web workers, or Deno.

Configuration

| Option | Default | Description | |------------|----------------------------|-------------------------------------------| | apiKey | (required) | API key from your product settings | | baseUrl | http://localhost:8000 | Your PQ Platform URL | | timeout | 5000 | HTTP timeout in milliseconds | | asyncSend| true | Send reports without blocking the request |

All payload keys are camelCase in JS and converted to the platform's snake_case fields (userRef → user_ref, requestPayload → request_payload, …) automatically.

API

PQClient

| Method | Description | |--------|-------------| | captureError({ message, errorType, stacktrace, ...extra }) | Report an error. Extra fields: environment, version, page, userRef, device, os, browser, requestPayload, extra. | | captureException(err, options) | Report a caught error, deriving message/type/stack from the Error. | | sendFeedback({ rating, comment, userRef, ...extra }) | Submit feedback (rating 1–5). Extra: version, screenshotUrl. | | createTicket({ title, description, ticketType, userRef, ...extra }) | Create a ticket (bug | feature | question). Extra: externalId, metadata. | | flush() | Wait for all pending async sends to complete. |

PQBrowserClient (pq-befu/browser) exposes the same methods but sends via global fetch — for Electron renderers, browsers, workers, and Deno.

Hooks

| Function | Description | |----------|-------------| | captureExceptions(client, fn, defaults?) | Run fn; auto-report exceptions, then re-throw. | | autoCapture(client, defaults?) | Wrap a function; auto-report its exceptions. | | installHooks(client, defaults?) | Global uncaughtException / unhandledRejection capture. |

Development

cd pq-sdk-js
npm install
npm test

License

MIT