open-index/open-npm huggingface dataset:
npm package: @iot9x.com/nestjs-ali-dysms
Description: nestjs 阿里云平台短信集成插件
Author: Tankk
Latest version: 0.0.2

# `NestJS` 阿里云短信服务集成插件

注意：<font color="#dd0000">仍在开发中，目前仅在内部使用</font><br /> 

## 支持环境

* node >=`14.x`
* NestJS === `8.x`

## 安装

```shell
$ npm i @iot9x.com/nestjs-ali-dysms

or
$ yarn add @iot9x.com/nestjs-ali-dysms  # 推荐使用yarn
```

## 配置

### 同步方式

```typescript
import { Module } from '@nestjs/common';
import { AliDySmsModule } from '@iot9x.com/nestjs-ali-dysms'

@Module({
  imports: [
    AliDySmsModule.forRoot({
      accessKeyId: '你的阿里accessKeyId', 
      accessKeySecret: '你的阿里accessKeySecret',
      endpoint: 'dysmsapi.aliyuncs.com'
    })
  ]
})
export class AppModule { }
```

### 异步方式

```typescript
import { Module } from '@nestjs/common';
import { ConfigModule, ConfigType } from '@nestjs/config';
import { AliDySmsModule } from '@iot9x.com/nestjs-ali-dysms';
import { AliDySmsRegister } from './modules/config/registers/ali-dy-sms.register';
import { TestRegister } from './modules/config/registers/test.register';
import { ConfigValidation } from './modules/config/validations/config.validation';

@Module({
  imports: [
    ConfigModule.forRoot({
      isGlobal: true,
      validationSchema: ConfigValidation,
      validationOptions: {
        allowUnknown: true,
        abortEarly: true,
      },
      load: [AliDySmsRegister, TestRegister],
    }),
    AliDySmsModule.forRootAsync({
      useFactory: (aliDySmsConfig: ConfigType<typeof AliDySmsRegister>) =>
        aliDySmsConfig,
      inject: [AliDySmsRegister.KEY],
    }),
  ],
})
export class AppModule {}

```