Socket
Book a DemoInstallSign in
Socket

zeebe-node-nestjs

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zeebe-node-nestjs

Zeebe-Node client wrapper for NestJS

latest
Source
npmnpm
Version
1.0.0
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Nest Logo

Zeebe-Node client wrapper for NestJS


Strictly for Zeebe 1.x

for older zeebe please use @payk/nestjs-zeebe

Sample

// main.ts
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { ZeebeServer } from 'zeebe-node-nestjs';

async function bootstrap() {
    const app = await NestFactory.create(AppModule);

    const microservice = app.connectMicroservice({
        strategy: app.get(ZeebeServer),
    });
    await app.startAllMicroservicesAsync();

    await app.listen(3000);
}
bootstrap();
// app.module.ts
import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { ZeebeModule, ZeebeServer } from 'zeebe-node-nestjs';

@Module({
    imports: [
        ZeebeModule.forRoot({ gatewayAddress: 'localhost:26500' })
    ],
    controllers: [AppController],
    providers: [ZeebeServer],
})
export class AppModule {}
    // app.controller.ts
    import { Controller, Get, Inject } from '@nestjs/common';
    import { AppService } from './app.service';
    import { ZBClient, Duration } from 'zeebe-node';
    import { ZEEBE_CONNECTION_PROVIDER, ZeebeWorker } from 'zeebe-node-nestjs';

    @Controller()
    export class AppController {

        constructor(
            private readonly appService: AppService, 
            
            @Inject(ZEEBE_CONNECTION_PROVIDER)
            private readonly zbClient: ZBClient,
        ) {}

        // Use the client to create a new process instance
        @Get()
        getHello(): Promise<CreateWorkflowInstanceResponse> {
            return this.zbClient.createProcessInstance('Process_sample', { test: 1 });
        }

        // Subscribe to events of type 'Activity_test'
        @ZeebeWorker('Activity_test')
        async test(job) {
            console.log(job);
            this.appService.doSomething();
            job.complete();
        }

        // publish a message
        @Post()
        sendHello() {
            this.zbClient.publishMessage({
                name: 'message_notification',
                correlationKey: '1234',
                variables: { greeting: 'Hello' },
                timeToLive: Duration.seconds.of(10),
            });
        }
    }

Keywords

nestjs

FAQs

Package last updated on 17 Jul 2021

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