Skip to content

Commit

Permalink
added readme convenience script
Browse files Browse the repository at this point in the history
  • Loading branch information
timgit committed Feb 3, 2023
1 parent 4b3b46f commit a15aaaa
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -32,7 +32,8 @@
"export-schema": "node ./scripts/construct.js",
"export-migration": "node ./scripts/migrate.js",
"export-rollback": "node ./scripts/rollback.js",
"tsc": "tsc --noEmit types.d.ts"
"tsc": "tsc --noEmit types.d.ts",
"readme": "node ./test/readme.js"
},
"mocha": {
"timeout": 10000,
Expand Down
26 changes: 26 additions & 0 deletions test/readme.js
@@ -0,0 +1,26 @@
const helper = require('./testHelper')

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

boss.on('error', error => {
console.error(error)
})

await boss.start()

const queue = 'some-queue'

await boss.schedule(queue, '* * * * *')

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

await boss.work(queue, someAsyncJobHandler)
}

async function someAsyncJobHandler (job) {
console.log(`running job ${job.id}`)
}

readme()

0 comments on commit a15aaaa

Please sign in to comment.