1.1.1 • Published 6 years ago

@stephenmathieson/sls-utils v1.1.1

Weekly downloads
1
License
MIT
Repository
-
Last release
6 years ago

@stephenmathieson/sls-utils

CircleCI

Utilities for working with Serverless.

API

utils.Handler(fn)

Create a SLS event handler, abstracting away oddities with responses and async functions.

Example:

const { Handler } = require('@stephenmathieson/sls-utils')

// Create your service.
const fooService = new Handler(async (event, context) => {
  const { body: rawBody } = event
  const { foo, bar, baz } = JSON.parse(rawBody)

  const data = await getData(foo, bar, baz)
  return data
})

// Export its handler.
exports.foo = fooService.getHandler()

utils.getHeader(name, headers)

Get the value of the name header, or null.

Useful because AWS does not normalize (lowercase) headers.

Example:

exports.foo = (event, context, callback) => {
  const authorization = getHeader('authorization', event.headers)
  if (!authorization) {
    // ...
  }
}

Releasing

CircleCI will publish all pushed semver-ish tags to npm.

1.1.1

6 years ago

1.1.0

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago