I'm trying to create a "worker" for NestJS, which basically aggregate data from multiple datasources.
Since I'm deploying this worker into into a Kubernetes Cluster, I don't need to start the NestJS inner HTTP server, however, the scheduler don't run without app.listen.
main.ts:
async function bootstrap() {
const app = await NestFactory.create(WorkerModule);
await app.listen(3030); // <-- I would like to delete this
}
bootstrap();
worker.module.ts
@Module({
imports: [
ScheduleModule.forRoot(),
],
providers: [
// Scrappers
DataScrapper,
],
})
export class WorkerModule {}
data.scrapper.ts
@Injectable()
export class DataScrapper {
@Interval(1000)
async sync() {
console.log('fetching...');
}
}