🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

@starecase/nest-cron-monitor

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@starecase/nest-cron-monitor

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

0.1.11
latest
npm
Version published
Weekly downloads
2
-50%
Maintainers
1
Weekly downloads
 
Created
Source

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.

Keywords

nestjs

FAQs

Package last updated on 24 May 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts