@norvento/taskmaster_client
v0.1.1
Published
This library is intended to use with TaskMaster app.
Downloads
100
Keywords
Readme
TaskMaster client
This library is intended to use with TaskMaster app.
How to use the library
- Create a class that extends the
Task
class. - Call the super() constuctor with the TaskMaster task id and taskmaster url
- Implement your task logic in the
performTask
method. - You can send your logs and parameters to TaskMaster using the context provided in the performTask method.
- Implement a REST endpoint and call your class.
Example
import { Injectable } from "@nestjs/common";
import { Task } from "@norvento/taskmaster_client";
import { TaskLogger } from "@norvento/taskmaster_client/dist/TaskLogger";
import { TaskParamsHandler } from "@norvento/taskmaster_client/dist/TaskParamsHandler";
@Injectable()
export class ExampleTask extends Task<{ "parameter1": string }> {
constructor() {
super("1", "https://localhost:8443");
}
protected async performTask(taskContext: { logger: TaskLogger; paramsHandler: TaskParamsHandler; }): Promise<void> {
await taskContext.logger.info("test log");
await taskContext.logger.warn("test log warn");
console.log(taskContext.paramsHandler.getParam("a"));
console.log(taskContext.paramsHandler.getParam("b"));
}
}