2.0.4 • Published 2 years ago

@agent-ly/nestjs-agenda v2.0.4

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

nestjs-agenda

The Agenda module you've been looking for

I've always wanted a module similar to @nestjs/schedule & @nestjs/bull but for agenda, the mongoose task scheduling library. Stay tuned for a BullMQ nestjs module as well, because they sure as hell won't do it.

Installation

yarn add @agent-ly/nestjs-agenda agenda
# npm install ...

Usage

app.processor.ts

import { Processor, Define, Every, Schedule } from "@agent-ly/nestjs-agenda";
import { Job } from "agenda";

interface ISayYourName {
  name: string;
}

@Processor()
export class AppProcessor {
  @Define('Say "Hello world!"')
  @Every('30 seconds')
  sayHelloWorld() {
    console.log("Hello world!");
  }

  @Define('Say "Goodbye world!"')
  @Schedule('in 1 minute')
  sayGoodbyeWorld() {
    console.log("Goodbye world!")
  }

  @Define('Say your name')
  sayYourName(job: Job<ISayYourName>) {
    console.log(`Your name is ${job.attrs.data.name}`);
  }
}

app.service.ts

...
import { AgendaService } from "@agent-ly/nestjs-agenda";
@Injectable()
export class AppService {
  constructor(
    // AgendaService is an instance of Agenda
    private readonly agendaService: AgendaService,
  )
  
  sayYourName(name: string) {
    agendaService.now('Say your name', { name })
  }
}

app.module.ts

...
import { AgendaModule } from "@agent-ly/nestjs-agenda";
import { AppProcessor } from "./app.processor";

@Module({
  imports: [
    AgendaModule.forRoot({
      db: { 
        address: ... // Enter MongoDB URI Connection
      }
    })
  ],
  providers: [AppProcessor]
})
export class AppModule {}
2.0.3

2 years ago

2.0.2

2 years ago

2.0.4

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.2.0

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago