1.0.4 • Published 4 years ago

nestjs-cron-test v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

NestJS cron Module

NestJS cron package allows you easily setup cron for your controllers or services.

npm i nestjs-cron

Then register module in your root app.module

import { CronModule } from 'nestjs-cron';

@Module({
	imports: [
		// ...
		CronModule.forRoot(),
	],
})
export class AppModule {}

To use cron, decorate your class with @Scheduled() and method with @Cron()

import { Cron, Scheduled } from 'nestjs-cron';

@Scheduled()
export class MyClass {
	@Cron('* * * * * *')
	async myMethod() {
		//...
	}
}

'* * * * * *' - is a standart cron notation. In this example it will be triggered every second. Additionaly you can use options:

@Cron('* * * * * *', {
	launchOnInit: true,
	sync: true,
})
  • launchOnInit - Launch job one time right after start
  • sync - Wait for method to finish before launching next tick if your function takes more time then cron.
1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago