@mann-conomy/job-scheduler
v1.0.0
Published
A simple background job scheduler for the Mann-Conomy project.
Maintainers
Readme
job-scheduler
A simple background job scheduler for the Mann-Conomy project.
Installation
Using npm:
$ npm install @mann-conomy/job-schedulerUsing yarn:
$ yarn add @mann-conomy/job-schedulerTesting
Using npm:
$ npm testUsing yarn:
$ yarn testExamples
Fetching 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.
Documentation
See the Wiki pages for further documentation.
License
Copyright 2025, The Mann-Conomy Project
