To use this module, you need to inject it into the desired service.
import { Module } from '@nestjs/common';
import {
AwsS3Service,
AwsCoreService,
AwsConfigurationService,
AwsStsService,
ConfigurationService,
ValidatorRegexpService,
StringExService,
} from 'niro-health';
import { AppController } from './app.controller';
import { AppService } from './app.service';
@Module({
controllers: [AppController],
providers: [
AppService,
{
provide: 'IAwsS3Service',
useClass: AwsS3Service,
},
{
provide: 'IAwsCoreService',
useClass: AwsCoreService,
},
{
provide: 'IAwsConfigurationService',
useClass: AwsConfigurationService,
},
{
provide: 'IAwsStsService',
useClass: AwsStsService,
},
{
provide: 'IConfigurationService',
useClass: ConfigurationService,
},
{
provide: 'IValidatorRegexpService',
useClass: ValidatorRegexpService,
},
{
provide: 'IStringExService',
useClass: StringExService,
},
],
})
export class AppModule {}
Injecting the module into our service.
import { Inject, Injectable } from '@nestjs/common';
import type { IAwsS3Service } from 'niro-health';
@Injectable()
export class AppService {
constructor(
@Inject('IAwsS3Service')
private readonly awsS3Service: IAwsS3Service,
) {}
async getFile() {
return await this.awsS3Service.get('my-photo', 'png', 1, 'my-bucket');
}
}
You will need to inject the following interfaces.