nestjs-cronjob
v1.0.0
Published
NestJS cron config Module
Downloads
114
Maintainers
Readme
NestJS cron Module
NestJS cron package allows you easily setup cron for your controllers or services.
npm i nestjs-cronThen 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
.envfile:
JIRA_TOKEN=0000000000000