TinyJobs

TinyJobs is tiny user-friendly background jobs framework for JavaScript runtimes.

Downloads
208
Stars
2

TinyJobs

TinyJobs is tiny user-friendly background jobs framework for JavaScript runtimes.

What's inside?

This repo includes the following packages/apps:

Apps and Packages

CLI

Install and use the TinyJobs CLI to manage TinyJobs in your project.

npm i -G @tinyjobs/cli
tinyjobs

Usage

Instantiate a new TinyJobs instance and add the job:

import TinyJobs from 'tinyjobs';

const tinyJobs = new TinyJobs();

// Load jobs from the jobs directory
await tinyJobs.loadJobs();

// Invoke the job to run in the background
await tinyJobs.invoke('exampleJob', { name: 'world' });

Creating a Job

Your First Job

Let's create a new job in the jobs directory:

import { Job } from 'tinyjobs';

export default class FirstJob extends Job {
  constructor() {
    super({
        name: "firstJob",
    });
  }

  async run({ name }: { name: string }) {
    console.log(`Hello, ${data.name}!`);
  }
}

Roadmap

TinyJobs is not feature complete and still in early stages, you can refer to the roadmap for the list of currently planend features and their progress here.

Develop

To develop all apps and packages, run the following command:

bun run dev:packages # run watch modeon packages
bun run dev:apps # run watch mode on example app