nestjs-rmq-test
TypeScript icon, indicating that this package has built-in type declarations

1.0.11 • Public • Published

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.

Package Sidebar

Install

npm i nestjs-rmq-test

Weekly Downloads

3

Version

1.0.11

License

MIT

Unpacked Size

25.6 kB

Total Files

28

Last publish

Collaborators

  • automamanpm