Frameworks
NestJS — Scell.io integration
NestJS module + DI provider via @scell/sdk
The `@scell/sdk` v3.5.0 SDK integrates with NestJS via a dynamic Module exposing the client as injectable provider. Pattern: `ScellModule.forRoot({ apiKey })` in `AppModule`, `@Inject('SCELL_CLIENT')` in services. Compatible with NestJS Guards, Interceptors, and Pipes. Ideal for hexagonal architectures (port/adapter).
Key facts
- Dynamic module `ScellModule.forRoot()`
- Injectable provider via `@Inject('SCELL_CLIENT')`
- Compatible with @nestjs/config (env vars)
- Port/Adapter pattern for testability
- Supports NestJS 10 and 11
Code example
import { Module, Injectable, Inject } from '@nestjs/common';
import { ScellClient } from '@scell/sdk';
@Module({
providers: [{
provide: 'SCELL_CLIENT',
useFactory: () => new ScellClient({ apiKey: process.env.SCELL_API_KEY! }),
}],
exports: ['SCELL_CLIENT'],
})
export class ScellModule {}
@Injectable()
export class InvoiceService {
constructor(@Inject('SCELL_CLIENT') private scell: ScellClient) {}
async create(amount: number) {
return this.scell.invoices.create({
format: 'factur-x',
lines: [{ description: 'Service', quantity: 1, unit_price: amount, vat_rate: 20.0 }],
});
}
}