
Security News
Open Source Maintainers Feeling the Weight of the EU’s Cyber Resilience Act
The EU Cyber Resilience Act is prompting compliance requests that open source maintainers may not be obligated or equipped to handle.
@cemusta/nestjs-pulse
Advanced tools
The modern MongoDB-powered scheduling library pulse for NestJS
The modern MongoDB-powered scheduling library for NestJS
Semantic version commits are used to keep track of changes in the library. If you don't use correct commits, release wont be triggered.
npm install --save @pulsecron/nestjs-pulse @pulsecron/pulse
// src/app.module.ts
import { Module } from '@nestjs/common';
import { PulseModule } from '@pulsecron/nestjs-pulse';
import { NotificationsModule } from './notification/notification.module';
@Module({
imports: [
PulseModule.forRoot({
db: {
address: 'mongodb://localhost:27017/pulse',
},
}),
NotificationsModule,
],
providers: [],
})
export class AppModule {}
// src/notification/notification.module.ts
import { Module } from '@nestjs/common';
import { PulseModule } from '@pulsecron/nestjs-pulse';
import { NotificationsQueue } from './notification.processor';
@Module({
imports: [
PulseModule.registerQueue('notifications', {
processEvery: '1 minutes',
autoStart: false, // default: true
}),
],
providers: [NotificationsQueue],
exports: [],
})
export class NotificationsModule {}
// src/notification/notification.processor.ts
import { Job } from '@pulsecron/pulse';
import { Every, Queue, Define, Schedule } from '@pulsecron/nestjs-pulse';
@Queue('notifications')
export class NotificationsQueue {
@Every({ name: 'send notifications', interval: '1 minutes' })
async sendNotifications(job: Job) {
console.log('Sending notifications[1]');
}
@Schedule({ name: 'send notifications', when: 'tomorrow at noon' })
async sendNotifications(job: Job) {
console.log('Sending notifications[2]');
}
@Now()
async sendNotifications(job: Job) {
console.log('Sending notifications[3]');
}
@Define({ name: 'emailJob' })
async test(job: Job) {
console.log('Sending email to:', job.data.to);
}
}
import { Inject, Injectable } from '@nestjs/common';
import { Pulse } from '@pulsecron/pulse';
@Injectable()
export class NotificationService {
constructor(@Inject('notifications') private pulse: Pulse) {}
async scheduleEmail(email: string) {
const emailJob = this.pulse.create('emailJob', { to: email });
emailJob.unique(
{
'data.to': email,
},
{
insertOnly: true,
}
);
emailJob.schedule('5 seconds').save();
}
}
Contributions are welcome! Here are several ways you can contribute:
pulse
project.Fork the Repository: Start by forking the project repository to your github account.
Clone Locally: Clone the forked repository to your local machine using a git client.
git clone https://github.com/pulsecron/nestjs-pulse
Create a New Branch: Always work on a new branch, giving it a descriptive name.
git checkout -b new-feature-x
Make Your Changes: Develop and test your changes locally.
Commit Your Changes: Commit with a clear message describing your updates.
git commit -m 'Implemented new feature x.'
Push to github: Push the changes to your forked repository.
git push origin new-feature-x
Submit a Pull Request: Create a PR against the original project repository. Clearly describe the changes and their motivations.
Review: Once your PR is reviewed and approved, it will be merged into the main branch. Congratulations on your contribution!
This project is protected under the MIT License. For more details, refer to the LICENSE file.
FAQs
The modern MongoDB-powered scheduling library pulse for NestJS
The npm package @cemusta/nestjs-pulse receives a total of 0 weekly downloads. As such, @cemusta/nestjs-pulse popularity was classified as not popular.
We found that @cemusta/nestjs-pulse demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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 EU Cyber Resilience Act is prompting compliance requests that open source maintainers may not be obligated or equipped to handle.
Security News
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.