Socket
Socket
Sign inDemoInstall

@nestjs/schedule

Package Overview
Dependencies
210
Maintainers
2
Versions
32
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @nestjs/schedule

Nest - modern, fast, powerful node.js web framework (@schedule)


Version published
Weekly downloads
865K
increased by2.97%
Maintainers
2
Created
Weekly downloads
 

Package description

What is @nestjs/schedule?

@nestjs/schedule is a scheduling module for NestJS applications that allows you to easily create and manage scheduled tasks. It provides decorators and utilities to define cron jobs, timeouts, and intervals in a declarative way.

What are @nestjs/schedule's main functionalities?

Cron Jobs

This feature allows you to define cron jobs using the @Cron decorator. The example demonstrates a task that runs every 10 seconds.

```typescript
import { Injectable } from '@nestjs/common';
import { Cron, CronExpression } from '@nestjs/schedule';

@Injectable()
export class TasksService {
  @Cron(CronExpression.EVERY_10_SECONDS)
  handleCron() {
    console.log('Called every 10 seconds');
  }
}
```

Timeouts

This feature allows you to define one-time tasks that execute after a specified delay using the @Timeout decorator. The example demonstrates a task that runs once after 5 seconds.

```typescript
import { Injectable } from '@nestjs/common';
import { Timeout } from '@nestjs/schedule';

@Injectable()
export class TasksService {
  @Timeout(5000)
  handleTimeout() {
    console.log('Called once after 5 seconds');
  }
}
```

Intervals

This feature allows you to define recurring tasks that execute at specified intervals using the @Interval decorator. The example demonstrates a task that runs every 10 seconds.

```typescript
import { Injectable } from '@nestjs/common';
import { Interval } from '@nestjs/schedule';

@Injectable()
export class TasksService {
  @Interval(10000)
  handleInterval() {
    console.log('Called every 10 seconds');
  }
}
```

Other packages similar to @nestjs/schedule

Readme

Source

Nest Logo

A progressive Node.js framework for building efficient and scalable server-side applications.

NPM Version Package License NPM Downloads Coverage Discord Backers on Open Collective Sponsors on Open Collective

Description

Schedule module for Nest based on the cron package.

Installation

$ npm install --save @nestjs/schedule
$ npm install --save-dev @types/cron

Quick Start

Overview & Tutorial

Support

Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please read more here.

Stay in touch

License

Nest is MIT licensed.

FAQs

Last updated on 17 May 2023

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc