@iot9x.com/nestjs-ali-dysms
v0.0.2
Published
nestjs 阿里云平台短信集成插件
Downloads
2
Readme
NestJS
阿里云短信服务集成插件
注意:仍在开发中,目前仅在内部使用
支持环境
- node >=
14.x
- NestJS ===
8.x
安装
$ npm i @iot9x.com/nestjs-ali-dysms
or
$ yarn add @iot9x.com/nestjs-ali-dysms # 推荐使用yarn
配置
同步方式
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 { }
异步方式
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 {}