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

@faapi/task-pgboss

v6.12.0

Published

pg-boss task queue driver for faapi — persistent queue on PostgreSQL

Readme

@faapi/task-pgboss

faapi 任务子系统的 pg-boss 驱动(PostgreSQL 持久化队列)。

基于 PostgreSQL 的任务队列——任务不丢(持久化)、多实例天然防重跑(worker 领取制)、cron 重复投递由 pg-boss 消费语义兜底。复用业务方已有的 Postgres,不引入 Redis。

安装

pnpm add @faapi/task-pgboss pgboss

使用

任务定义不变(主包文件约定 src/tasks/<name>/task.ts),只切驱动:

// faapi.config.ts
import type { FaapiConfig } from '@faapi/faapi';

export default {
  task: {
    driver: 'pgboss',
    pgboss: { connectionString: 'postgres://localhost:5432/app' }, // 透传给 new PgBoss(...)
  },
} satisfies FaapiConfig;
// handler 里用法完全不变
export function POST(body, tasks) {
  return tasks.enqueue('send-email', { to: body.email });
}

语义映射

| faapi 驱动接口 | pg-boss | | --- | --- | | enqueue(name, payload, { retries, delayMs }) | 幂等 createQueue(name)(每任务名每进程一次,缓存短路)→ boss.send(name, payload, { retryLimit, retryDelay: 1, retryBackoff: true, startAfter }) | | startWorker(name, { concurrency, process }) | 幂等 createQueue(name)boss.work(name, { batchSize: concurrency }, handler) | | stop(timeoutMs) | 停 work + boss.stop({ close: true, timeout }) | | stopWorkers() | offWork()(不断开连接,dev 热替换重注册用) | | 失败重试 | pg-boss 侧执行(retryLimit + retryBackoff 指数退避) |

注意:pg-boss v10 不再隐式建队列(send() 对未创建队列静默返回 null)——驱动在投递/注册 worker 前自动幂等建队列,业务方无需预建;pg-boss 也不提供执行中任务的取消信号——runtaskCtx.signal 永不 abort,长任务请自行做超时控制。

License

MIT