New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

nest-bull-jobs

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nest-bull-jobs

Bull tasks wrapper for NestJS framework

  • 2.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-66.67%
Maintainers
1
Weekly downloads
 
Created
Source

Nest Logo

Description

This is a Bull task wrapper module for Nest.

Installation

$ npm i --save nest-bull-jobs bull
$ npm i --save-dev @types/bull

Quick Start

import { Injectable } from '@nestjs/common';
import Bull = require('bull');
import { Task } from '../lib';

@Injectable()
export class AppTasks {
    @Task({ name: 'justATest' })
    justATest(job: Bull.Job, done: Bull.DoneCallback) {
        const result: number = (job.data || []).reduce((a, b) => a + b);

        setTimeout(() => {
            done(null, result);
        }, 900);
    }
}

import { Controller, Get } from '@nestjs/common';
import * as Bull from 'bull';
import { BullService } from '../lib';
import { AppTasks } from './app.tasks';

@Controller('app')
export class AppController {
    constructor(
        private readonly bullService: BullService,
        private readonly tasks: AppTasks,
    ) {}

    @Get()
    public async runTask() {
        const opt: Bull.JobOptions = { lifo: true };
        const data = [1, 2, 3];

        const result = await this.bullService.createJob(this.tasks.justATest, data, opt).then((job) => {
            return job.finished();
        });

        return result;
    }
}

import { Module, OnModuleInit } from '@nestjs/common';
import { ModuleRef } from '@nestjs/core';
import { BullModule, BullTaskRegisterService } from '../lib';
import { AppTasks } from './app.tasks';
import { AppController } from './app.controller';

@Module({
  imports: [BullModule],
  controllers: [AppController],
  providers: [AppTasks],
})
export class AppModule implements OnModuleInit {
  constructor(
      private readonly moduleRef: ModuleRef,
      private readonly taskRegister: BullTaskRegisterService,
  ) {}
  onModuleInit() {
      this.taskRegister.setModuleRef(this.moduleRef);
      this.taskRegister.register(AppTasks);
  }
}

Keywords

FAQs

Package last updated on 13 Nov 2019

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc