Last active
October 20, 2021 23:19
-
-
Save Yazan98/b2f0e8de0b4d41939e1c49bae11745eb to your computer and use it in GitHub Desktop.
Cron Job Scheduler in NestJs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from "@nestjs/common"; | |
import { Cron, CronExpression } from "@nestjs/schedule"; | |
@Injectable() | |
export class TasksService { | |
@Cron(CronExpression.EVERY_DAY_AT_1AM, { | |
name: "dependencies" | |
}) | |
handleCron() { | |
// Handle Libraries Checks | |
} | |
} | |
// Now Declare this TaskService inside your App Module | |
import { Module } from '@nestjs/common'; | |
import { AppController } from './app.controller'; | |
import { AppService } from './app.service'; | |
import { ScheduleModule } from '@nestjs/schedule'; | |
import { TasksService } from "./task/TasksService"; | |
@Module({ | |
imports: [ScheduleModule.forRoot()], | |
controllers: [AppController], | |
providers: [AppService, TasksService], | |
}) | |
export class AppModule {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment