Task Runner
This is a feature of the arkfire project. Find out more here
The task runner is a simple service made for scheduling http requests. You may pass the scheduled time and within +- 5 minutes of that time, your endpoint will be hit.
The request object includes a url, method and data object. At the scheduled time your http request will be made, hitting your server endpoint to perform your task.
Getting Started
Make sure to pass a valid task-runner api key in your env. Becuase the task runner api is bolted into Arkform nuxt module it injects some server endpoints to pick up your task-runner env keys. Making the api available client side.
ARKFIRE_TASK_RUNNER_API_KEY="..."And also make sure you have arkform installed as a nuxt module.
Usage
You can simply schedule a task by calling this function:
$tasks.create({
performAt: Date.now() + 1000 * 60 * 60,
// This is forming the request the task will perform.
request: {
url: "https://myUrl.com",
method: "post",
params: {
anyParam: "here",
},
headers: {
Authorization: "Bearer ...",
},
body: {
myData: "hello",
},
},
})
// schedule tasks using a chron timer
$tasks.schedule("* * * * *", {
request: {
url: "https://myUrl.com",
method: "post",
params: {
anyParam: "here",
},
headers: {
Authorization: "Bearer ...",
},
body: {
myData: "hello",
},
},
})
// You can only remove pending tasks.
$tasks.delete(id)
// You can only update pending tasks.
$tasks.update(id, {
performAt: serverTimestamp() + 100_000,
})
const tasks = $tasks.read(id)Alternatively hit the endpoints.