0.0.6 • Published 4 years ago

@shubuzuo/nestjs-sms v0.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

nest-sms SMS 封装

注意:仍在开发中,目前仅在内部使用 Nest框架 短信服务 插件

使用说明

外部人员仅供参考,请不要用于生产环境,因此导致的事故后果请自行承担。

安装

$ npm i @shubuzuo/nestjs-sms

or

$ yarn add @shubuzuo/nestjs-sms 

用法

config.js 配置

export const config = {
	"ApiKeyPublic": "-------",
  "ApiKeyPrivate": "-------"
};

module.ts

import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AwsSmsModule } from '@shubuzuo/nestjs-sms'

@Module({
  imports: [
    AwsSmsModule.forRoot({
      accessKeyId: '------',
      secretAccessKey: '------',
      apiVersion: '------',
      region: '-----',
    })
  ],
  controllers: [AppController],
  providers: [],
})
export class AppModule {}

controller.ts

import { Controller, Get } from '@nestjs/common';
import { AwsSmsService, PublishResponse } from '@shubuzuo/nestjs-sms';

@Controller()
export class AppController {
  constructor(
    private readonly awsSmsService: AwsSmsService
  ) {}

  @Get('sms')
  async setSms(): Promise<PublishResponse> {
    return  await this.awsSmsService.send('17630802711', '短信内容')
  }
}