Skip to content
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
42aa651
refactor: convert codebase to typescript
davbrito Oct 26, 2025
08f913d
refactor: add types to library
davbrito Oct 26, 2025
e4915ff
refactor: add type annotations for states and policies in PgBoss class
davbrito Oct 26, 2025
9a3ee92
fix: type errors
davbrito Oct 26, 2025
4abf7ce
feat: build esm only
davbrito Oct 26, 2025
3350785
feat: add package.json#files
davbrito Oct 26, 2025
6ee790e
fix tests coverage
davbrito Oct 27, 2025
886954a
chore: improve test coverage
davbrito Oct 28, 2025
d7ef97f
Merge pull request #623 from davbrito/ts-rewrite
timgit Nov 5, 2025
ac72121
updates
timgit Nov 5, 2025
9fda7f1
consolidate config to package json
timgit Nov 5, 2025
584b89b
align startAfter types
timgit Nov 5, 2025
a3e0d1c
updated examples
timgit Nov 5, 2025
6c1450a
restored readme example with require
timgit Nov 5, 2025
bdfe536
experimental cjs exports
timgit Nov 5, 2025
b857ce1
update tests and types
timgit Nov 6, 2025
eabf583
allowing npx mocha cli for single files
timgit Nov 7, 2025
c6f5c45
simplify async assertion rejects
timgit Nov 7, 2025
6111529
updates the cjs shim comment
timgit Nov 7, 2025
2c9009f
consolidate to named exports
timgit Nov 7, 2025
36e8f6f
updates
timgit Nov 7, 2025
9c43d9b
docs [skip ci]
timgit Nov 7, 2025
e3ce039
updates
timgit Nov 7, 2025
24d6c09
tests
timgit Nov 8, 2025
ff03173
tests
timgit Nov 8, 2025
4cbc4e8
deps
timgit Nov 8, 2025
7c50523
deps fix
timgit Nov 8, 2025
b9a8c0d
tests
timgit Nov 8, 2025
1f0d0e1
update exports
timgit Nov 9, 2025
c6f0cf6
actions step names
timgit Nov 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ node_modules
.vscode
*.tgz
*.log
coverage
coverage

dist
10 changes: 0 additions & 10 deletions .npmignore

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Queueing jobs in Postgres from Node.js like a boss.

```js
async function readme() {
const PgBoss = require('pg-boss');
const { PgBoss } = require('pg-boss');
const boss = new PgBoss('postgres://user:pass@host/database');

boss.on('error', console.error)
Expand Down Expand Up @@ -53,7 +53,7 @@ This will likely cater the most to teams already familiar with the simplicity of
* Multi-master compatible (for example, in a Kubernetes ReplicaSet)

## Requirements
* Node 22 or higher
* Node 22.12 or higher for CommonJS's require(esm)
* PostgreSQL 13 or higher

## Installation
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ services:
- POSTGRES_NAME=pgboss
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
command: -c 'max_connections=400'

volumes:
db_volume:
4 changes: 2 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Queueing jobs in Postgres from Node.js like a boss.

```js
async function readme() {
const PgBoss = require('pg-boss');
const { PgBoss } = require('pg-boss');
const boss = new PgBoss('postgres://user:pass@host/database');

boss.on('error', console.error)
Expand Down Expand Up @@ -53,7 +53,7 @@ This will likely cater the most to teams already familiar with the simplicity of
* Multi-master compatible (for example, in a Kubernetes ReplicaSet)

## Requirements
* Node 22 or higher
* Node 22.12 or higher for CommonJS's require(esm)
* PostgreSQL 13 or higher

## Installation
Expand Down
2 changes: 1 addition & 1 deletion docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pg-boss will automatically create a dedicated schema (`pgboss` is the default na
GRANT CREATE ON DATABASE db1 TO leastprivuser;
```

If the CREATE privilege is not available or desired, you can use the included [static functions](#static-functions) to export the SQL commands to manually create or upgrade the required database schema. **This means you will also need to monitor future releases for schema changes** (the schema property in [version.json](../version.json)) so they can be applied manually.
If the CREATE privilege is not available or desired, you can use the included [static functions](#static-functions) to export the SQL commands to manually create or upgrade the required database schema. **This means you will also need to monitor future releases for schema changes**.

NOTE: Using an existing schema is supported for advanced use cases **but discouraged**, as this opens up the possibility that creation will fail on an object name collision, and it will add more steps to the uninstallation process.

Expand Down
12 changes: 0 additions & 12 deletions eslint.config.js

This file was deleted.

15 changes: 15 additions & 0 deletions eslint.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import neostandard from 'neostandard'
import { defineConfig } from 'eslint/config'

const config = neostandard({
ts: true,
env: ['mocha'],
ignores: neostandard.resolveIgnoresFromGitignore(),
noJsx: true,
})

export default defineConfig(config, {
languageOptions: {
ecmaVersion: 2025,
},
})
10 changes: 5 additions & 5 deletions examples/load/index.js → examples/load/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const helper = require('../../test/testHelper')
const { delay } = require('../../src/tools')
const PgBoss = require('../../src')
import { PgBoss } from '../../dist/index.mjs'
import * as helper from '../../test/testHelper.js'
import { delay } from '../../src/tools.ts'

const SCHEMA_COUNT = 60
const QUEUE_COUNT = 200
Expand All @@ -19,7 +19,7 @@ async function loadTest () {
}
}

async function init (schema) {
async function init (schema: string) {
const config = helper.getConfig()
const boss = new PgBoss({ ...config, schema, supervise: false, schedule: false })

Expand All @@ -34,7 +34,7 @@ async function init (schema) {
for (const queue of queues) {
console.log(`creating queue ${schema}.${queue}`)
await boss.createQueue(queue)
await boss.work(queue, () => {})
await boss.work(queue, async () => {})
}

console.log('created queues')
Expand Down
5 changes: 2 additions & 3 deletions examples/readme.js → examples/readme.cjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
const helper = require('../test/testHelper')
const { PgBoss } = require('../')

async function readme () {
const PgBoss = require('../src')
const boss = new PgBoss(helper.getConnectionString())
const boss = new PgBoss('postgres://postgres:postgres@localhost/pgboss')

boss.on('error', console.error)

Expand Down
27 changes: 27 additions & 0 deletions examples/readme.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { PgBoss } from '../dist/index.mjs'

async function readme () {
const boss = new PgBoss('postgres://postgres:postgres@localhost/pgboss')

boss.on('error', console.error)

await boss.start()

const queue = 'readme-queue'

await boss.createQueue(queue)

const id = await boss.send(queue, { arg1: 'read me' })

console.log(`created job ${id} in queue ${queue}`)

await boss.work(queue, async ([job]) => {
console.log(`received job ${job.id} with data ${JSON.stringify(job.data)}`)
})
}

readme()
.catch(err => {
console.log(err)
process.exit(1)
})
4 changes: 2 additions & 2 deletions examples/schedule.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const helper = require('../test/testHelper')
import { PgBoss } from '../dist/index.mjs'
import * as helper from '../test/testHelper.js'

async function schedule () {
const PgBoss = require('../src')
const boss = new PgBoss(helper.getConnectionString())

boss.on('error', console.error)
Expand Down
Loading