Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pay-k/nestjs-zeebe
Zeebe transport and client for nestjs framework
https://github.com/pay-k/nestjs-zeebe
nestjs nestjs-zeebe zeebe zeebe-transport
Last synced: about 2 months ago
JSON representation
Zeebe transport and client for nestjs framework
- Host: GitHub
- URL: https://github.com/pay-k/nestjs-zeebe
- Owner: pay-k
- License: mit
- Created: 2019-09-01T10:28:02.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-12-30T18:39:03.000Z (about 2 years ago)
- Last Synced: 2024-10-08T18:19:16.463Z (3 months ago)
- Topics: nestjs, nestjs-zeebe, zeebe, zeebe-transport
- Language: TypeScript
- Size: 214 KB
- Stars: 42
- Watchers: 3
- Forks: 19
- Open Issues: 24
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# NestJS Zeebe Connector (Transport and Client)
A zeebe transport and client for NestJSUsing the zeebe-node module and exposing it as a NestJS transport and module.
[![Build Status](https://dev.azure.com/payk/PayK%20Public/_apis/build/status/pay-k.nestjs-zeebe?branchName=master)](https://dev.azure.com/payk/PayK%20Public/_build/latest?definitionId=1&branchName=master)## Install
npm install @payk/nestjs-zeebe## Basic usage
```ts
// app.module.ts
import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { ZeebeModule, ZeebeServer } from '@payk/nestjs-zeebe';@Module({
imports: [ ZeebeModule.forRoot({ gatewayAddress: 'localhost:26500' })],
controllers: [AppController],
providers: [ZeebeServer],
})
export class AppModule {}
``````ts
// main.ts
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { ZeebeServer } from '@payk/nestjs-zeebe';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();```
```ts
// app.controller.ts
import { Controller, Get, Inject } from '@nestjs/common';
import { AppService } from './app.service';
import { ZBClient } from 'zeebe-node';
import { CreateWorkflowInstanceResponse, CompleteFn, Job } from 'zeebe-node/interfaces';
import { ZEEBE_CONNECTION_PROVIDER, ZeebeWorker } from '@payk/nestjs-zeebe';
import {
Ctx,
Payload,
} from '@nestjs/microservices';@Controller()
export class AppController {
constructor(private readonly appService: AppService, @Inject(ZEEBE_CONNECTION_PROVIDER) private readonly zbClient: ZBClient) {}// Use the client to create a new workflow instance
@Get()
getHello() : Promise {
return this.zbClient.createWorkflowInstance('order-process', { test: 1, or: 'romano'});
}// Subscribe to events of type 'payment-service
@ZeebeWorker('payment-service')
paymentService(@Payload() job, @Ctx() fn: CompleteFn {
console.log('Payment-service, Task variables', job.variables);
let updatedVariables = Object.assign({}, job.variables, {
paymentService: 'Did my job',
});// Task worker business logic goes here
complete.success(updatedVariables);
}// Subscribe to events of type 'inventory-service and create a worker with the options as passed below (zeebe-node ZBWorkerOptions)
@ZeebeWorker('inventory-service', { maxJobsToActivate: 10, timeout: 300 })
inventoryService(@Payload() job, @Ctx() fn: CompleteFn) {
console.log('inventory-service, Task variables', job.variables);
let updatedVariables = Object.assign({}, job.variables, {
inventoryVar: 'Inventory donnnneee',
});// Task worker business logic goes here
complete.success(updatedVariables);
}
}```