This package has been deprecated

Author message:

nest-alicloud-sms is deprecated! Use nestjs-alicloud-sms instead!

nest-alicloud-sms

1.0.3 • Public • Published

Nest Logo

A short message module for Nest framework (node.js) using Alicloud SMS service.

NPM Version Package License

Before Installation

  1. Create Alicloud account
  2. Purchase SMS. (read more)
  3. Apply for SMS sign name and message template, go to Dashboard > Short Message Service > Domestic Message > Add Singname
  4. Create message template, go to Dashboard > Short Message Service > Domestic Message > Add Template.

Installation

npm install --save nest-alicloud-sms
#or
yarn add nest-alicloud-sms

Documentation

  1. Import the AlicloudSmsModule with the following configuration:
import { Module } from '@nestjs/common';
import { AlicloudSmsModule } from 'nest-alicloud-sms';

import { AppController } from './app.controller';
import { AppService } from './app.service';


@Module({
  controllers: [AppController],
  providers: [AppService],
  imports: [
    AlicloudSmsModule.forRoot({
      config: { accessKeyId: '***', accessKeySecret:'***' },
      defaults: { signName: '***', regionId: 'cn-hangzhou' },
    }),
  ],
})
export class AppModule {}
  1. Send Message
import { Controller, Logger, Post } from '@nestjs/common';
import { AlicloudSmsService } from 'nest-alicloud-sms';

@Controller()
export class AppController {

  constructor(private readonly smsService: AlicloudSmsService){}
  
  @Post('sms/send')
  async sendSms( ): Promise<any> {
    const templateCodeId = 'SMS_1490999999'
    const phoneNumber = '1388886666';
    const templateParam = { code: '888666' };

    const sendResponse = await this.smsService.sendSms(templateCodeId, phoneNumber, templateParam);

    if (sendResponse.Code === 'OK') {
      // success

    } else {
      // failed

    }

  }
}

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i nest-alicloud-sms

Weekly Downloads

5

Version

1.0.3

License

MIT

Unpacked Size

15.5 kB

Total Files

18

Last publish

Collaborators

  • zhouzhenzhou