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