Custom Adapter
Create your own custom cron adapter for VitNode.
VitNode supports custom cron adapters, allowing you to integrate with various scheduling libraries or services.
Usage
Create your custom adapter
As an example we will create a custom adapter using the popular node-cron library.
import { schedule } from "node-cron";
import { type CronAdapter, handleCronJobs } from "@/api/lib/cron";
export const NodeCronAdapter = (): CronAdapter => {
return {
schedule() {
schedule("*/1 * * * *", async () => {
await handleCronJobs();
});
},
};
};Integrate the adapter into your application
import { NodeCronAdapter } from "./path/to/your/custom/node-cron.adapter";
export const vitNodeApiConfig = buildApiConfig({
cronAdapter: NodeCronAdapter(),
});Restart server
After making these changes, stop your server (if it's running) and restart it to apply the new configuration.
bun devpnpm devnpm run devThat's it — your app now has a built-in task scheduler, ready to handle cron jobs with standard cron expressions.
Check Your Cron Jobs
You can check your cron jobs in AdminCP under Core => Advanced => Cron Jobs.