Security News
Introducing the Socket Python SDK
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
@nestjs/schedule
Advanced tools
@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.
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');
}
}
```
node-cron is a lightweight npm package for scheduling tasks in Node.js using cron syntax. It is not specific to any framework and can be used in any Node.js application. Compared to @nestjs/schedule, node-cron provides a more general-purpose solution but lacks the integration and decorators provided by NestJS.
Agenda is a job scheduling package for Node.js with MongoDB as a backend. It provides a more feature-rich solution for job scheduling, including job persistence, retries, and job prioritization. Compared to @nestjs/schedule, Agenda offers more advanced features but requires additional setup and configuration.
Bull is a Redis-based queue system for Node.js that supports job scheduling, retries, and concurrency. It is designed for handling background jobs and tasks. Compared to @nestjs/schedule, Bull is more suitable for complex job processing scenarios and provides more control over job execution and management.
A progressive Node.js framework for building efficient and scalable server-side applications.
Schedule module for Nest based on the cron package.
$ npm install --save @nestjs/schedule
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.
Nest is MIT licensed.
FAQs
Nest - modern, fast, powerful node.js web framework (@schedule)
The npm package @nestjs/schedule receives a total of 767,958 weekly downloads. As such, @nestjs/schedule popularity was classified as popular.
We found that @nestjs/schedule demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
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.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.
Security News
A new Rust RFC proposes "Trusted Publishing" for Crates.io, introducing short-lived access tokens via OIDC to improve security and reduce risks associated with long-lived API tokens.