@repit/lambda-param

1.0.1 • Public • Published

Lambda Param

Parse parameters in AWS Lambda.

Installation

$ npm install @repit/lambda-param --save

Usage

'use strict'

const param = require('@repit/lambda-param')

exports.handler = (event, context, callback) => {
  // Parse `foo` from `queryStringParameters`.
  param(event, 'foo') // value || null

  // Parse `foo` from `pathParameters`.
  param.path(event, 'foo') // value || null

  // Parse `foo` from `headers`.
  param.headers(event, 'foo') // value || null

  // Parse `foo` from `queryStringParameters`,
  // and test it against a given regexp.
  param(event, 'foo', /^[A-Z]{2}$/) // value || null

  // Parse `foo` from `queryStringParameters`,
  // and make sure it is contained in a given object.
  param(event, 'foo', null, { foo: true }) // value || null

  // Parse `foo` from `queryStringParameters`,
  // and make sure it is contained in a given array.
  param(event, 'foo', null, ['foo']) // value || null
}

License

MIT

Dependencies (0)

    Dev Dependencies (2)

    Package Sidebar

    Install

    npm i @repit/lambda-param

    Weekly Downloads

    0

    Version

    1.0.1

    License

    MIT

    Last publish

    Collaborators

    • sumanion