Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Injectable Twilio client for Nestjs.

License

NotificationsYou must be signed in to change notification settings

lkaric/nestjs-twilio

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Injectable Twilio client forNestjs.

npm versionminiziped sizetree shakingMIT licensed

Implementing theTwilioModule from this package you gain access to Twilio client through dependency injection with minimal setup.

Instalation

$ npm install --save nestjs-twilio
$ yarn add nestjs-twilio

Getting Started

To use Twilio client we need to register module for example in app.module.ts

import{TwilioModule}from'nestjs-twilio';@Module({imports:[TwilioModule.forRoot({accountSid:process.env.TWILIO_ACCOUNT_SID,authToken:process.env.TWILIO_AUTH_TOKEN,}),],})exportclassAppModule{}

If you are using the@nestjs/config package from nest, you can use theConfigModule using theregisterAsync() function to inject your environment variables like this in your custom module:

import{TwilioModule}from'nestjs-twilio';@Module({imports:[TwilioModule.forRootAsync({imports:[ConfigModule],useFactory:(cfg:ConfigService)=>({accountSid:cfg.get('TWILIO_ACCOUNT_SID'),authToken:cfg.get('TWILIO_AUTH_TOKEN'),}),inject:[ConfigService],}),],})exportclassAppModule{}

Example usage in service.

import{InjectTwilio,TwilioService}from'nestjs-twilio';@Injectable()exportclassAppService{publicconstructor(privatereadonlytwilioService:TwilioService){}asyncsendSMS(){returnthis.twilioService.client.messages.create({body:'SMS Body, sent to the phone!',from:TWILIO_PHONE_NUMBER,to:TARGET_PHONE_NUMBER,});}}

For full Client API see Twilio Node SDK referencehere

Testing

Example of testing can be foundhere.

About

Injectable Twilio client for Nestjs.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Sponsor this project

    Packages

    No packages published

    Contributors8


    [8]ページ先頭

    ©2009-2025 Movatter.jp