dm-ali-oss
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

Nest Logo

Description

a dynamic module for ali oss inject difference instance

Installation

$ npm install dm-ali-oss

Quick Start

async configuration

Like other factory providers, our factory function can be async and can inject dependencies through inject.

  AliOssModule.registerAsync('P1', {
      inject: [ConfigService],
      useFactory: (configService: ConfigService) => {
        return {
          accessKeyId: configService.get('ALI_OSS_ACCESS_KEY_ID'),
          accessKeySecret: configService.get('ALI_OSS_ACCESS_KEY_SECRET'),
          bucket: configService.get('ALI_OSS_BUCKET'),
          region: configService.get('ALI_OSS_REGION'),
          endpoint:configService.get('ALI_OSS_ENDPOINT'),
        };
      },
    }),

then you can inject with the target provider

@Injectable()
export class AppService {
  constructor(@Inject('P1') private readonly aliOssService: AliOssService) {}
  async getHello(): Promise<string> {
    const result = await this.aliOssService.getObject('test/test.txt');
    return result.toString();
  }
}

current AliOssService support method

  • putObject()
  • getObject()
  • putAcl()
  • createBucket()
  • getStream()

you can read details by typings

Test

# e2e tests
$ npm run test:e2e

# test coverage
$ npm run test:cov

License

Nest is MIT licensed.

Package Sidebar

Install

npm i dm-ali-oss

Weekly Downloads

0

Version

0.0.3

License

MIT

Unpacked Size

91.5 kB

Total Files

21

Last publish

Collaborators

  • lincd