New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@pixelplex/sms-service

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pixelplex/sms-service

Sms service

latest
npmnpm
Version
1.2.0
Version published
Maintainers
1
Created
Source

SMS Service

Library for fast implementation of the functionality of sending SMS messages.

Supported gateways:

  • smsc
  • sms-traffic
  • twilio
  • fire-mobile
  • devinotele

and debug gateways:

  • console
  • slack

The service receive messages and sends them via SMS.

How to use

  • create template for message
  • add @pixelplex/sms-service to your application
  • call SmsModule.forRoot from @pixelplex/sms-service to import in your module
  • send a message by calling this.smsService.sendSms('+375297775544', 'auth', { name: 'Афанасий' }); where smsService is SmsSenderService from @pixelplex/sms-service

Didn't understand anything? Okay, let's see more details

Prepare templates

The service uses Handlebars as template engine. So all your sms templates should be prepared as handlebars templates.

Welcome, {{name}}! This is subject

Configuration Variables

NameDescriptionExample
gatewaysArray of gateways to send email, supported: smpt, slack, console['slack']
customGatewaysArray of custom gateways classes[CustomGateway]
slack.urlHook URL in case you want to duplicate messages to Slackhttps://hooks.slack.com
*.senderSms sender phone number+375333333333
*Other gateway-specific options like username, password, sid etc.

Trigger new message sending

1. Install npm package

yarn add @pixelplex/sms-service

2. Import SmsModule in your module you'll send sms from:

import { Module } from '@nestjs/common';
import { SmsModule } from '@pixelplex/sms-service';
import { AppService } from './app.service';

@Module({
  controllers: [],
  imports: [
    MailModule.forRoot({
      gateways: ['slack', 'twilio', 'console'],
      slack: { url: 'hooks.slack.com' },
      twilio: {
        sid: 'SID',
        token: 'TOKEN',
        sender: '+375333333333',
      },
    }),
  ],
  providers: [AppService],
})
export class AppModule {}

3. Call sendSms to send your sms:

import { Injectable } from '@nestjs/common';
import { SmsSenderService } from '@pixelplex/sms-service';

@Injectable()
export class AppService {

  constructor(private readonly smsService: SmsSenderService) {
  }

  async onModuleInit() {
    this.smsService.sendSms('+375297775544', './path', { name: 'Афанасий' });
  }

}

In the example below we'll send sms to +375297775544 with handlebars path ./path.

{name: 'Афанасий'} is the object with data which will used as payload data during processing your handlebars template.

FAQs

Package last updated on 24 Jul 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts