Jobs
Execute a specific job (task) when your application starts.
In Epic API, jobs allow developers to register various services, schedule tasks, or modify server instances on a global level of the application.
You can execute the following command to create a job:
# Execute the built-in Deno task
deno task create:module -t job -n createDefaultUser --template blank.ts
This command is going to generate the following code:
import { Application } from "oak";
// If the sequence of the execution doesn't matter, you can also write your code here in this scope...
// But it is recommended to write the code in the following default function if the sequence does matter:
export default async (app: Application) => {
// Write the logic to execute on app start (before server starts listening)...
return async () => {
// This code executes when the app receives "SIGINT" | "SIGTERM" | "SIGBREAK" signal.
// Your optional cleanup code here...
};
};
Use the following command to delete the job:
Warning! You cannot undo the following command, which can lead to a code deletion! Be careful when using this command during a real development.
# Execute the built-in Deno task
deno task delete:module -t job -n createDefaultUser.ts
Last updated
Was this helpful?