11require ( 'dotenv' ) . config ( { path : __dirname + '/.env' } )
22const app = require ( 'express' ) ( )
3- const bodyParser = require ( 'body-parser' )
4- const Nexmo = require ( 'nexmo' )
3+ const Vonage = require ( '@vonage/server-sdk' )
54
6- const nexmo = new Nexmo ( {
7- apiKey : process . env . NEXMO_API_KEY ,
8- apiSecret : process . env . NEXMO_API_SECRET
5+ const vonage = new Vonage ( {
6+ apiKey : process . env . VONAGE_API_KEY ,
7+ apiSecret : process . env . VONAGE_API_SECRET
98} )
109
11- app . use ( bodyParser . json ( ) )
12- app . use ( bodyParser . urlencoded ( {
13- extended : true
14- } ) )
15-
16-
1710app
1811 . route ( '/webhooks/event' )
1912 . get ( eventWebhook )
@@ -31,9 +24,9 @@ function eventWebhook(request, response) {
3124}
3225
3326function sendSms ( request , response ) {
34- const text = 'This is a test SMS of my Nexmo Node.js skeleton app.'
27+ const text = 'This is a test SMS of my Vonage Node.js skeleton app.'
3528
36- nexmo . message . sendSms ( process . env . FROM_NUMBER , process . env . TO_NUMBER , text , ( err , responseData ) => {
29+ vonage . message . sendSms ( process . env . FROM_NUMBER , process . env . TO_NUMBER , text , ( err , responseData ) => {
3730 if ( err ) {
3831 response . status ( 404 ) . send ( err )
3932 } else {
0 commit comments