Security News
vlt Debuts New JavaScript Package Manager and Serverless Registry at NodeConf EU
vlt introduced its new package manager and a serverless registry this week, innovating in a space where npm has stagnated.
@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, heavily inspired by Angular.
Schedule module for Nest based on the cron package.
$ npm i --save @nestjs/schedule
TBD
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 447,880 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
vlt introduced its new package manager and a serverless registry this week, innovating in a space where npm has stagnated.
Security News
Research
The Socket Research Team uncovered a malicious Python package typosquatting the popular 'fabric' SSH library, silently exfiltrating AWS credentials from unsuspecting developers.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.