1.3.0 • Published 5 years ago

@omkartech/service-request v1.3.0

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

@omkartech/service-request

The goal of this package is to centralize the boilerplate request setup and handling to any requests to lambda.

Import the service

import serviceRequest from '@omkartech/service-request'

Common request helper syntax

const lambdaFunction = params.FunctionName
const awsRegion = 'us-west-2'
const lambdaPayLoad = {}
  try {
    // find the lambda to invoke
    const svcParams = {
      InvocationType: 'Event',
      region: awsRegion || 'us-west-2',
    }
    // invoke lambda
    const resp = await serviceRequest(lambdaFunction, svcParams).request(lambdaPayLoad)
  } catch (err) {
    console.error(`Error in calling Lambda: ${lambdaFunction}, error: ${err.message}`)
    throw new Error(`Error in calling Lambda: ${lambdaFunction}, error: ${err.message}`)
  }