@lambda-func/body-to-json
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

@lambda-func/body-to-json

https://img.shields.io/npm/v/@lambda-func/body-to-json

npm i @lambda-func/body-to-json

This package includes a lambda-func middleware to parse the JSON in the body of an incoming event.

Usage

import { APIGatewayProxyEvent } from 'aws-lambda'
import { bodyToJson } from '@lambda-func/body-to-json'

type User = { email: string }
const isUser = (value: unknown): value is User => typeof (<User>value).email === 'string'

export const handler = bodyToJson<APIGatewayProxyEvent>()(async (event) => {
  if (isUser(event.body)) {
    // do something
  }
})

Readme

Keywords

none

Package Sidebar

Install

npm i @lambda-func/body-to-json

Weekly Downloads

3

Version

0.1.1

License

ISC

Unpacked Size

3.51 kB

Total Files

8

Last publish

Collaborators

  • cgiles95