📝AWS Core
The module that provides the core AWS services for the other modules.
Imports
import { AwsCoreService } from 'niro-health';
Application Variables
How to set variable
You can set the application variable in your main module and/or in the module that will inject the service.
import { Inject, Injectable } from '@nestjs/common';
import type { IConfigurationService } from 'niro-health';
@Injectable()
export class AppService {
constructor(
@Inject('IConfigurationService')
private readonly configurationService: IConfigurationService,
) {
this.initialize();
}
async initialize() {
this.configurationService.setVariable('aws_api_version', 'latest');
this.configurationService.setVariable('aws_region', 'us-east-1');
}
}
Method of Use
To use this module, you need to inject it into the desired service.
import { Module } from '@nestjs/common';
import {
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: 'IAwsCoreServiceImpl',
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 { IAwsCoreServiceImpl } from 'niro-health';
@Injectable()
export class AppService {
constructor(
@Inject('IAwsCoreServiceImpl')
private readonly awsCoreService: IAwsCoreServiceImpl,
) {}
async configuration() {
return await this.awsCoreService.configuration();
}
}
With dependencies
You will need to inject the following interfaces.
IConfigurationService
IValidatorRegexpService
IStringExService
IAwsConfigurationService
IAwsStsService
Properties
get _apiVersion
private
Get the AWS API version from the configuration.
get _region
private
Get the AWS region from the configuration.
get _httpOptions
private
Get the AWS HTTP options.
get _credentials
private
Get the AWS configuration service.
get _sts
private
Get the AWS STS service.
Methods
initialize
private
Initialize the AWS configuration.
client
public
Get the client for the AWS services.
setRole3rdParty
public
Set the role for the 3rd party.
configuration
public
Get the AWS configuration.
Last updated