@bossbench/core

中文文档
1.1.1发布于 2026/08/12MITTypeScriptES Module构建来源已验证近 30 天下载 2341

Core API, repository, actions, and bundled UI for Bossbench.

原始使用文档
文档目录6 节
  1. Adapter matrix
  2. CLI setup
  3. Core API
  4. Options
  5. Alerting
  6. Security

@bossbench/core

Core package for Bossbench. It contains the pg-boss/Postgres repository, action service, API routes, and bundled dashboard UI.

Adapter matrix

PackageFrameworkMount style
@bossbench/honoHonoapp.route()
@bossbench/h3h3 / Nitrohandler wrapper
@bossbench/nuxtNuxt / Nitroroute module
@bossbench/adonisAdonisJSrouter mount
@bossbench/tanstack-startTanStack Startroute handlers
@bossbench/expressExpressapp.use()
@bossbench/fastifyFastifyplugin
@bossbench/elysiaElysiaplugin
@bossbench/nestjsNestJScontroller/module
@bossbench/nextNext.jsroute handlers

CLI setup

npx @bossbench/cli init

The CLI detects Hono, h3, Nuxt/Nitro, AdonisJS, TanStack Start, Express, Fastify, Elysia, NestJS, and Next.js projects.

Core API

import PgBoss from "pg-boss";
import { Hono } from "hono";
import { bossbench } from "@bossbench/hono";

const boss = new PgBoss({ connectionString: process.env.DATABASE_URL!, schema: "pgboss" });
await boss.start();

const app = new Hono();
app.route(
  "/jobs",
  bossbench({
    boss,
    db: process.env.DATABASE_URL!,
    basePath: "/jobs",
    auth: {
      username: process.env.BOSSBENCH_USER!,
      password: process.env.BOSSBENCH_PASS!,
    },
  }),
);

Options

OptionDescription
bossOptional PgBoss instance. Required for mutations.
dbPostgres connection string, Pool, or Client. Required for reads unless your adapter passes a compatible connection.
schemapg-boss schema. Defaults to pgboss.
authBasic auth credentials. Required unless allowUnauthenticated: true.
allowUnauthenticatedExplicitly allow unprotected browsing. Defaults to false.
readonlyDisable all mutations. Defaults to true without auth, false with auth.
allowManualEnqueueEnable manual enqueue and enqueue-copy actions. Defaults to false.
allowQueueCleanEnable queue clean preview only. Requires boss, writable mode, and route protection. Defaults to false.
allowQueueCleanDeleteEnable irreversible queue clean deletion. Requires exact confirmation, direct SQL safety, and route protection. Defaults to false.
alertsOptional config-driven alert rules and contact points. Evaluation is read-only; delivery runners are opt-in.
tagsFields from job.data that can be used as filters.

Alerting

Alerting is configured in BossbenchOptions, evaluated from pg-boss/Postgres data, and surfaced through the bundled Alerts page plus /api/alerts.

bossbench({
  db: process.env.DATABASE_URL!,
  auth: {
    username: process.env.BOSSBENCH_USER!,
    password: process.env.BOSSBENCH_PASS!,
  },
  alerts: {
    enabled: true,
    rules: [
      {
        id: "critical-failures",
        name: "Critical failures",
        type: "failed_count",
        windowMinutes: 10,
        threshold: 5,
        severity: "critical",
        cooldownMinutes: 30,
        contactPointIds: ["ops"],
      },
    ],
    contactPoints: [
      { id: "ops", name: "Ops", type: "discord", urlEnv: "OPS_DISCORD_WEBHOOK" },
    ],
  },
});

Rules support failed_count, dead_letter_count, retry_backlog_count, oldest_created_age, avg_wait_ms, avg_duration_ms, and warning_count. oldest_created_age thresholds are seconds; wait and duration thresholds are milliseconds. Contact points can be webhook, slack, or discord. Prefer urlEnv or server-only config for webhook URLs; the dashboard only receives masked contact point summaries.

AlertRunner is exported for server-side delivery. It does not start timers automatically; call runOnce() from one process or your own scheduler. In replicated deployments, run a single alert worker or add deployment-level locking before enabling delivery.

Security

Bossbench requires non-empty auth by default. Use allowUnauthenticated: true only for local development or when another middleware protects the route. Without auth, Bossbench defaults to read-only mode.

Queue clean is split into preview and delete. allowQueueClean enables preview, and allowQueueCleanDelete enables irreversible deletion only when preview is also allowed. Exact confirmation text is required before deletion runs. Queue clean targets pg-boss storage directly, so failed deletion removes the underlying dead-letter/retry evidence. It is batch-limited; repeat it while hasMore is true when draining large queues.

版本与发布记录

@bossbench/core 共发布 3 个版本,首次发布于 2026/08/11;过去 12 个月发布了 3 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.1.1latest2026/08/122 个月前
1.1.02026/08/112 个月前
1.0.02026/08/112 个月前

关于 @bossbench/core 的常见问题

@bossbench/core 是什么?

Core API, repository, actions, and bundled UI for Bossbench.

如何安装 @bossbench/core?

在项目目录运行 npm install @bossbench/core,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:pg(>=8.0.0)、pg-boss(>=12.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@bossbench/core 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@bossbench/core 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@bossbench/core 可以商用吗?

@bossbench/core 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@bossbench/core 的下载量有多少?

根据 npm 官方下载统计,@bossbench/core 在 2026/10/09 – 2026/11/07 这 30 天内被下载 2,341 次,日均约 78 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@bossbench/core 还在维护吗?

最新版本 1.1.1 发布于 2026/08/12(2 个月前);至今共发布 3 个版本,其中过去 12 个月发布了 3 个;首次发布于 2026/08/11。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。