0.3.0 • Published 5 years ago

hapi-twilio-auth v0.3.0

Weekly downloads
44
License
MIT
Repository
github
Last release
5 years ago

hapi-twilio-auth

Hapi plugin for Twilio request validation.

install

npm i hapi-twilio-auth

usage

import hapi from '@hapi/hapi'
import hapiTwilioAuth from 'hapi-twilio-auth'

const { Server } = hapi

async function startServer() {
  const server = new Server({
    port: 3000,
  })

  await server.register(hapiTwilioAuth)

  server.auth.strategy('twilio-auth', 'twilio-signature', {
    baseUrl: 'https://mycompany.com/webhooks-path', // your twilio webhooks base url
    twilioAuthToken: 'xxxxxxxxxxx', // your twilio auth token
  })

  server.route({
    method: 'POST',
    path: '/',
    handler(request, h) {
      // ...
    },
  })

  await server.start()
}

startServer()