@lantsang/nestjs-ucpaas-sms
v0.0.1
Published
nestjs 云之讯平台短信集成插件
Downloads
117
Readme
NestJS
云之讯短信服务集成插件
注意:仍在开发中,目前仅在内部使用
支持环境
- node >=
14.x
- NestJS >=
7.x
安装
$ npm i @lantsang/nestjs-ucpaas-sms
or
$ yarn add @lantsang/nestjs-ucpaas-sms # 推荐使用yarn
配置
同步方式
import { Module } from '@nestjs/common';
import { UcpaasModule } from '@lantsang/nestjs-ucpaas-sms'
@Module({
imports: [
UcpaasModule.forRoot({
appid: '你的云之讯平台appid',
sid: '你的云之讯平台sid',
token: '你的云之讯平台token'
})
]
})
export class AppModule { }
异步方式
import { Module } from '@nestjs/common';
import { UcpaasModule } from '@lantsang/nestjs-ucpaas-sms'
import { ConfigModule } from './modules/config/config.module';
import { CONFIG_PROVIDER } from './modules/config/constants/config.constant';
import { ConfigService } from './modules/config/services/config.service';
@Module({
imports: [
UcpaasModule.forRootAsync({
useFactory: (configService: ConfigService) => ({
appid: configService.ucpaas.appid,
sid: configService.ucpaas.sid,
token: configService.ucpaas.token
}),
inject: [CONFIG_PROVIDER]
}),
ConfigModule
]
})
export class AppModule { }
提示:异步注册方式采用的
ConfigModule
并不是NestJS
自带的配置功能,而是我基于官方自己设计的一套,具体实现请参考笔记:NestJS配置模块设计