# jobify

> Right way to work with jobs

Latest version **0.1.6** (published 2024-12-04) · 0 weekly downloads

## Install

```sh
npm install jobify
pnpm add jobify
yarn add jobify
bun add jobify
```

## Health

**Score 35/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.6 |
| Published | 2024-12-04 |
| First published | 2024-09-24 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 8.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | skravets |
| Keywords | jobs, queue, bullmq, bull, pg-boss |

## Links

- npm: https://www.npmjs.com/package/jobify
- npm.io page: https://npm.io/package/jobify

## Alternatives

- [cron](https://npm.io/package/cron.md) — 4.9M weekly downloads
- [@vercel/queue](https://npm.io/package/@vercel/queue.md) — 731.6K weekly downloads
- [create-sonicjs](https://npm.io/package/create-sonicjs.md) — 1.6K weekly downloads
- [@exellix/jobs-api](https://npm.io/package/@exellix/jobs-api.md) — 941 weekly downloads
- [@forwardimpact/libskill](https://npm.io/package/@forwardimpact/libskill.md) — 575 weekly downloads

## Recent versions

- 0.1.6 (latest) — 2024-12-04
- 0.1.5 — 2024-12-04
- 0.1.4 — 2024-12-04
- 0.1.3 — 2024-12-03
- 0.1.2 — 2024-11-22
- 0.1.1 — 2024-11-11
- 0.1.0 — 2024-10-25
- 0.0.2 — 2024-10-23
- 0.0.1 — 2024-09-24

## README

# jobify

<div align="center">

[![npm](https://img.shields.io/npm/v/jobify?logo=npm&style=flat&labelColor=000&color=3b82f6)](https://www.npmjs.org/package/jobify)
[![npm downloads](https://img.shields.io/npm/dw/jobify?logo=npm&style=flat&labelColor=000&color=3b82f6)](https://www.npmjs.org/package/jobify)
[![JSR](https://jsr.io/badges/@kravets/jobify)](https://jsr.io/@kravets/jobify)
[![JSR Score](https://jsr.io/badges/@kravets/jobify/score)](https://jsr.io/@kravets/jobify)

</div>

Type-safe and much simpler wrapper for the [BullMQ](https://bullmq.io/) library.

> [!WARNING]
> This project is in the `MVP` state and the API may still change a lot. At the moment, the project fits the
> requirements of the project rather than general purpose

# Usage

```ts
import { initJobify } from "jobify";
import IORedis from "ioredis";

const redis = new IORedis({
    maxRetriesPerRequest: null,
});

const defineJob = initJobify(redis);

const job1 = defineJob("some", {
    queue: {
        defaultJobOptions: {
            delay: 100,
        },
    },
})
    .input<{ date: string }>()
    // WORKER OPTIONS
    .options({
        limiter: {
            max: 10,
            duration: 1000,
        },
    })
    .action(async (job) => {
        console.log("running", job.data.date);
        //       ^?
    });

await job1.add(
    "some",
    { date: new Date().toISOString() },
    {
        delay: 5000,
    }
);

const job2 = await defineJob("some-cron")
    .input<{ date: string }>()
    .options({
        limiter: {
            max: 10,
            duration: 1000,
        },
    })
    .action(async (job) => {
        console.log("running", job.data.date);
        //       ^?
    })
    // it will run every minute and will not be duplicated during reboots.
    .repeatable({
        every: 60 * 1000,
    });
```

## Workers defaults

We add some options by default to Workers

```ts
{
    removeOnComplete: {
		count: 20,
	},
	removeOnFail: {
		age: 24 * 3600,
		count: 1000,
    }
}
```

We add it because it recommended in [`going to production`](https://docs.bullmq.io/guide/going-to-production#auto-job-removal)

### TODO:

-   maybe [pg-boss](https://github.com/timgit/pg-boss) adapter?
-   hooks?
-   make job title optional?
-   guide with [bull-board](https://github.com/felixmosh/bull-board) and some improves for usage

---
_Source: https://npm.io/package/jobify · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
