@flowlib/nestjs
v0.0.5
Published
A NestJS module for executing Flowlib workflows with batch processing capabilities
Maintainers
Readme
Mount Flowlib into any NestJS app as a module. Provides a controller for all API endpoints and an injectable service for programmatic access.
Install
npx flowlib-cli initOr install manually:
npm install @flowlib/core @flowlib/nestjsUsage
import { Module } from '@nestjs/common';
import { FlowlibModule } from '@flowlib/nestjs';
@Module({
imports: [
FlowlibModule.forRoot({
database: {
type: 'sqlite',
connectionString: 'file:./dev.db',
},
encryptionKey: process.env.FLOWLIB_ENCRYPTION_KEY, // npx flowlib-cli secret
}),
],
})
export class AppModule {}Async Configuration
import { ConfigModule, ConfigService } from '@nestjs/config';
import { FlowlibModule } from '@flowlib/nestjs';
@Module({
imports: [
ConfigModule.forRoot(),
FlowlibModule.forRootAsync({
useFactory: (config: ConfigService) => ({
database: {
type: 'postgres',
connectionString: config.get('DATABASE_URL'),
},
encryptionKey: config.get('FLOWLIB_ENCRYPTION_KEY'),
}),
inject: [ConfigService],
}),
],
})
export class AppModule {}Programmatic Access
Inject FlowlibService to call the core engine directly:
import { Injectable } from '@nestjs/common';
import { FlowlibService } from '@flowlib/nestjs';
@Injectable()
export class MyService {
constructor(private readonly flowlib: FlowlibService) {}
async runWorkflow(flowId: string, inputs: Record<string, unknown>) {
return this.flowlib.getCore().runs.start(flowId, inputs);
}
}