0

I have two questions. 1.How to run cron job locally in loopback framework? 2.How to inject a class in a service file and then use the class's method?

For example I have code like

import {CronController} from "../CronController" ;
import cron from "node-cron";

export class LiveUpdate() {
constructor(protected cronController: CronController){} 
async start(){
this.cronJob()
}

private async cronJob(){
cron.schedule("59 23 * * *",async () => {
//... calls function here
});
}
}

Now consider I have a service class, MyService.
And I want to call the start() function of LiveUpdate in this service class. How do I inject it, so I can use the start() function in this class?

I have not tried anything as I was unable to find anything.

0 Answers0