nestjs-cambpm
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

Nest Logo

NestJS Connector for Camunda BPM Runtime

Run your business logic anywhere

Install

npm i nestjs-cambpm

Example

The full example can be found here. Please also see the Azure Function Example.

// src/main.ts
 
async function bootstrap() {
  const app = await NestFactory.create(AppModule);
  app.connectMicroservice({
    strategy: app.get(ExternalTaskConnector),
  });
 
  await app.startAllMicroservicesAsync();
}
bootstrap();
// src/app.module.ts
 
@Module({
  controllers: [AppController],
  providers: [
    ExternalTaskConnector,
    ExternalTaskModule.createClient({
      baseUrl: 'http://localhost:8080/engine-rest',
    }),
  ],
})
export class AppModule {}
// src/app.controller.ts
 
@Controller()
export class AppController {
  @Subscription('my-external-task', {
    lockDuration: 500,
  })
  async myExternalTask(@Payload() task: Task, @Ctx() taskService: TaskService) {
    const businessKey = task.businessKey;
    const isBusinessKeyMissing = !businessKey;
 
    const processVariables = new Variables();
    processVariables.set('isBusinessKeyMissing', isBusinessKeyMissing);
 
    if (!isBusinessKeyMissing) {
      // Complete the External Task
      await taskService.complete(task, processVariables);
      Logger.log('External task successfully completed!');
 
    } else {
      const errorMessage = 'No business key given!';
      const options: HandleFailureOptions = {
        errorMessage: errorMessage,
      };
 
      // Raise an incident
      await taskService.handleFailure(task, options);
 
      Logger.error(errorMessage);
    }
  }
}

Package Sidebar

Install

npm i nestjs-cambpm

Weekly Downloads

12

Version

0.0.3

License

Apache License 2.0

Unpacked Size

686 kB

Total Files

25

Last publish

Collaborators

  • tasstastic