0.1.11 • Published 1 year ago

@starecase/nest-cron-monitor v0.1.11

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

This is a NestJS module designed for monitoring cron jobs through Starecase.io

Installation

npm install @starecase/nest-cron-monitor
OR
yarn add @starecase/nest-cron-monitor

Prerequisite

You will need to:

  • Fill the form to get API Key: URL btw it's Free to use 🎉
  • Own a Starecase account
  • Create a Starecase API Key

Environment Variables

We recommend using environment variables for storing your API Key. To set values for these variables, use the following variable names:

  • STARECASE_API_KEY: To store the API Key.

Quick Start

Register module

Just register this module:

@Module({
    imports: [
        StarecaseModule.forRoot({
            apiKey: `YOUR_API_KEY_GOES_HERE`,
        }) as DynamicModule,
    ],
})
class AppModule {
}

Quite often you might want to asynchronously pass module options instead of passing them beforehand. In such case, use forRootAsync() method like many other Nest.js libraries.

  • Use factory
StarecaseModule.forRootAsync({
    imports: [ConfigModule],
    useFactory: async (configService: ConfigService) => {
        return {
            apiKey: configService.get<string>("STARECASE_API_KEY")
        };
    },
    inject: [ConfigService],
}) as DynamicModule

Decorate methods

You need to add the @CronMonitor decorator to your @Cron or any other monitoring method you are using. Below is an example using @nestjs/schedule:

import {CronMonitor} from "@starecase/nest-cron-monitor";

@Injectable()
export class AppController {

    @Cron('45 * * * * *')
    @CronMonitor({jobName: "Job Name", jobGroup: "Job Group", expression: '45 * * * * *', debug: true})
    handleCron() {
        console.log('Called when the current second is 45');
    }
}

License

This project is licensed under the terms of the MIT license.

0.1.11

1 year ago

0.1.10

1 year ago

0.1.9

1 year ago

0.1.8

1 year ago

0.1.7

1 year ago

0.1.6

1 year ago

0.1.5

1 year ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago