This repo includes the following packages/apps:
tinyjobs
: TinyJobs core package that provides the framework for creating and running background jobs.@tinyjobs/cli
: CLI for managing TinyJobs in your project.@example/app
: Example app that demonstrates how to use TinyJobs.@tinyjobs/eslint-config
:eslint
configurations (includeseslint-config-next
andeslint-config-prettier
)@tinyjobs/typescript-config
:tsconfig.json
s used throughout the monorepo
Install and use the TinyJobs CLI to manage TinyJobs in your project.
npm i -G @tinyjobs/cli
tinyjobs
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' });
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}!`);
}
}
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.
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