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

1.0.0 • 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('* * * * * *')

To use ConfigService in any service or controller just inject it with @ConfigInjection decorator in the constructor:

import { ConfigService, ConfigInjection } from 'nestjs-dotenv';
 
constructor(
    @ConfigInjection() private readonly configService: ConfigService
) {}

To get a value from .env file just call get() method:

this.configService.get('JIRA_TOKEN');
  • JIRA_TOKEN - name of your key in .env file:
JIRA_TOKEN=0000000000000

Package Sidebar

Install

npm i nestjs-cronjob

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

12.8 kB

Total Files

26

Last publish

Collaborators

  • alaricode