Skip to content
This repository was archived by the owner on Jun 15, 2022. It is now read-only.

WazZro/nestjs-task-module

Repository files navigation

Description

Task Module for NestJS using Cron

Installation

$ npm install nest-task-module

Import task module to AppModule

import { Module } from '@nestjs/common';
import { TaskModule } from 'nest-task-module';
import { TaskName } from './tasks';

@Module({
  imports: [
    TaskModule.register({
      controller: true,
      tasks: [ TaskName ],
    }),
  ],
})
export class AppModule {}

API

TaskModule

  • register
    • controller - enable controller
    • tasks - [REQUIRED] array of tasks implementing CronJobParameter
    • instanceble - provider to determine the master instance
  • registerAsync
    • controller - enable controller
    • tasks - [REQUIRED] array of tasks implementing CronJobParameter
    • instanceble - [PROMISE] provider to determine the master instance

CronJobParameter

import { CronJobParameters } from 'cron';

interface CronJobParameter extends CronJobParameters {
  name: string;
}

Task

class Task extends CronJob {
  public name: string;

  get isRunning(): boolean;
  get cronSourceTime(): string;
  get cronTimeZone(): string;
  get nextRunDate(): Date;
  get lastRunDate(): Date;

  constructor(task: CronJobParameter);
}

About

Task module for NestJS

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published