A simple background job scheduler for the Mann-Conomy project.
Using npm:
$ npm install @mann-conomy/job-schedulerUsing yarn:
$ yarn add @mann-conomy/job-schedulerUsing npm:
$ npm testUsing yarn:
$ yarn testFetching the full Team Fortress 2 item schema from the Steam Web API every day at 04:05.
import { randomUUID } from "crypto";
import { SchemaClient } from "@mann-conomy/tf-schema";
import { JobScheduler, JobEvent } from "@mann-conomy/job-scheduler";
const client = new SchemaClient(process.env.STEAM_WEB_API_KEY!);
const scheduler = new JobScheduler("Europe/Copenhagen");
scheduler.on(JobEvent.Created, (id: string) => {
scheduler.start(id);
});
const uuid = randomUUID();
try {
scheduler.schedule(uuid, "5 4 * * *", async () => await client.getItemSchema());
} catch(error) {
if (error instanceof Error) {
console.error("Error scheduling job", error.message);
}
}Some more examples are available in the examples and test directories.
See the Wiki pages for further documentation.
Copyright 2025, The Mann-Conomy Project