- DynamodbDocumentClient
- EventbridgeReponseEntry
- EventbridgeClient
- LambdaClient
- S3Client
- SqsSendMessageResponse
- SqsClient
- SnsSendMessageResponse
- SnsClient
- AppContext
- EventType
- parser
- processor
- serializer
- wrapper
- createContainer
- createProcessor
- createCache
- createWrapper
- lambdaHandler
- createHandler
- createJsonHandler
- createApiJsonHandler
- parseJsonHttpEvent
- HttpEvent
- parseJsonMonoSqsEvent
- SqsEvent
- MultiStatusJsonResponse
- multiStatusCodeJsonSerializer
- createDefaultWrapper
- createApiJsonWrapper
- readJson
- LOGGER_REDACTION_LISTS
A wrapper around AWS.DynamoDB.DocumentClient to simplify interactions
options
Object See belowoptions.table
string The DynamoDB table nameoptions.name
string The name to be used for the 'client' property on the logger (optional, default'dynamodb-document'
)options.hashKey
string The DynamoDB table hash key.options.rangeKey
string The DynamoDB table range key (if set).options.reqId
string The reqId used for distributed log tracing (optional, defaultuuidv4()
)options.log
Object A pino compatible logger (optional, defaultcreateLogger()
)options.params
Object Additional parameters to the AWS.S3 constructor 'params' property (optional, default{}
)
A basic POJO encapsulating event bridge response entry
A wrapper around AWS.EventBridge to simplify interactions
options
Object See belowoptions.eventBusName
string The events bus name.options.name
string The name to be used for the 'client' property on the logger (optional, default'eventbridge'
)options.reqId
string The reqId used for distributed log tracing (optional, defaultuuidv4()
)options.log
Object A pino compatible logger (optional, defaultcreateLogger()
)options.params
Object Additional parameters to the AWS.EventBridge constructor 'params' property (optional, default{}
)
Put events to the event bridge
events
Object The event entries to pass to eventbridge.Entries. Entry input structure is identical to the AWS Entry type, except all keys are in lower camelcase, the Detail should be a plain serializable object, and the EventBusName should be omitted. (optional, default[]
)params
Object Additional properties to pass to the eventbridge.putEvents method (optional, default{}
)
Returns Array<EventbridgeReponseEntry> Array of EventbridgeReponseEntry
A wrapper around AWS.Lambda to simplify interactions
options
Object See belowoptions.arn
string The ARN of the lambda to invokeoptions.name
string The name to be used for the 'client' property on the logger (optional, default'lambda'
)options.reqId
string The reqId used for distributed log tracing (optional, defaultuuidv4()
)options.log
Object A pino compatible logger (optional, defaultcreateLogger()
)options.params
Object Additional parameters to the AWS.Lambda constructor 'params' property (optional, default{}
)
Invoke the lambda
payload
Object The object to pass as the Payload for lambdaClient.invokeparams
Object Additional properties to the lambdaClient.invoke method (optional, default{}
)
Returns any The JSON parsed response from lambdaClient.invoke
A wrapper around AWS.S3 to simplify interactions
options
Object See belowoptions.bucket
string The s3 Bucketoptions.name
string The name to be used for the 'client' property on the logger (optional, default's3'
)options.reqId
string The reqId used for distributed log tracing (optional, defaultuuidv4()
)options.log
Object A pino compatible logger (optional, defaultcreateLogger()
)options.params
Object Additional parameters to the AWS.S3 constructor 'params' property (optional, default{}
)
upload to S3 Bucket
key
Object The key to pass as the Key for s3Client.uploadbody
Object The object passed as the Body for s3Client.uploadparams
Object Additional properties to the s3.upload method (optional, default{}
)
Returns Promise<void>
upload JSON to S3 Bucket
key
Object The key to pass to this.uploadbody
Object The object to be stringified and passed to this.uploadparams
Object Additional properties to pass to this.upload (optional, default{}
)
Returns Promise<void>
getObject from S3 Bucket
key
Object The key to pass as the Key for s3Client.getObjectparams
Object Additional properties to the s3.getObject method (optional, default{}
)
Returns any The Body of response from s3.getObject
getObjectJson from S3 Bucket
key
Object The key to pass to this.getObjectparams
Object Additional properties to pass to this.getObject (optional, default{}
)
Returns any The JSON response from s3.getObject
listObjectVersions from S3 Bucket
params
Object Additional properties to pass to s3.listObjectVersions (optional, default{}
)
Returns any The response from s3.listObjectVersions
deleteObjects from S3 Bucket
params
Object Properties to pass to s3.deleteObjects (optional, default{}
)
Returns any The response from s3.deleteObjects
A basic POJO encapsulating sent message attributes
options
Object
A wrapper around AWS.SQS to simplify interactions
options
Object See belowoptions.queueUrl
string The URL for the queueoptions.name
string The name to be used for the 'client' property on the logger (optional, default'sqs'
)options.reqId
string The reqId used for distributed log tracing (optional, defaultuuidv4()
)options.log
Object A pino compatible logger (optional, defaultcreateLogger()
)options.params
Object Additional parameters to the AWS.Lambda constructor 'params' property (optional, default{}
)
Publish a message to SQS that will be JSON
body
Object The message body to be sent to SQSparams
Object Additional properties to the sqsClient.sendMessage method (optional, default{}
)
Returns SqsSendMessageResponse Information about the message sent
A basic POJO encapsulating sent message attributes
A wrapper around AWS.SNS to simplify interactions
options
Object See belowoptions.topicArn
string The ARN for the topicoptions.name
string The name to be used for the 'client' property on the logger (optional, default'sns'
)options.reqId
string The reqId used for distributed log tracing (optional, defaultuuidv4()
)options.log
Object A pino compatible logger (optional, defaultcreateLogger()
)options.params
Object Additional parameters to the AWS.Lambda constructor 'params' property (optional, default{}
)
Publish a message to SNS that will be JSON
body
Object The message body to be sent to SNSparams
Object Additional properties to the SnsClient.sendMessage method (optional, default{}
)
Returns SnsSendMessageResponse Information about the message sent
The runtime context
options
Object See belowoptions.awsRequestId
string The awsRequestId for the current invocationoptions.eventType
string A string representing the type of eventoptions.functionName
string The name of the lambda function from lambda contextoptions.log
object A pino compatible loggeroptions.reqId
string The distributed tracing id for this invocation
awsRequestId
string The awsRequestId for the current invocationeventType
string A string representing the type of eventfunctionName
string The name of the lambda function from lambda contextlog
object A pino compatible loggerreqId
string The distributed tracing id for this invocation
The different types of events that can occur
cloudfront
stringawsConfig
stringcodeCommit
stringapiGatewayAuthorizer
stringcloudFormation
stringses
stringapiGatewayAwsProxy
stringscheduledEvent
stringcloudWatchLogs
stringsns
stringdynamoDb
stringkinesisFirehose
stringcognitoSyncTrigger
stringkinesis
strings3
stringmobileBackend
stringsqs
stringlambda
stringisValid
Function Return true if provided value is a valid event type, false otherwise
Type: Function
Returns any The parsed event for the processor
Type: Function
parsedEvent
any The parsed event output from theparser
Returns any The serialized lambda response
Type: Function
response
any The response from the handler to be serialized for lambda response
Returns any The serialized lambda response
Type: Function
response
processor The response from the handler to be serialized for lambda response
Returns Function The processor wrapped in any additional code you may want
Type: Function
appContext
AppContext The context for the current execution of the lambdaconfiguration
Object The configuration object from the passed configurationRequests
Returns Object All of the side effect dependencies in an object
Type: Function
appContext
AppContext The context for the current execution of the lambdacontainer
Object The response from the createContainer invocation
Returns Object All of the side effect dependencies in an object
Type: Function
Returns cacheManager An instance of cacheManager
Type: Function
appContext
AppContext The context for the current execution of the lambdaparser
parser The parser provided tocreateHandler
serializer
serializer The serializer provided tocreateHandler
Returns wrapper All of the side effect dependencies in an object
Type: Function
Returns any The result of the processor
The entry point for creating handlers
options
Object See belowoptions.parser
parser? An optional function to parse the incoming lambda eventoptions.serializer
serializer? An optional function to serialize the response from the lambda invocationoptions.configurationRequests
Array<ConfigurationRequest> An array of configuration requests to be fulfilled before each invocation of the handler (optional, default[]
)options.createContainer
createContainer A factory function that will return all needed side effect dependencies. Eg. Http (optional, default()=>({})
)options.createCache
createCache An instance of cacheManager. Will be used to cache configuration. (optional, defaultdefaultCache
)options.createWrapper
createWrapper A factory function that will return the processor wrapped in additional functionality (optional, defaultcreateDefaultWrapper
)options.createProcessor
createProcessor A factory function that will return the main handler for the lambdaoptions.loggerOptions
Object? Additional options to pass to the logger (optional, default{}
)options.t
any? For use with AVA during testing
Returns lambdaHandler A lambda handler
A handler designed for direct lambda invocations that respond with a JSON serializable object. Takes identical options as createHandler, however the serializer and parser options will always be overridden with the identity function.
options
any Takes identical options as createHandler, however the serializer and parser options will always be overridden with the identity function.
A handler designed for lambda invocations through api gateway that respond with a JSON serializable object. Takes identical options as createHandler, however the wrapper option will always be overridden with the multi-status code version.
See the following:
options
any Takes identical options as createHandler, however the wrapper option will always be overridden with the multi-status code version.
This parse will handle the following:
- Body parsed into a json object
- HTTP method as a string
- Path parameters as key value pairs, properly decoded from uri
- Query string parameters as multi-value entries. Object<string, Array>
- Headers as multi-value entries. Object<string, Array>
- Request context
- Cookies
event
object An event from Api Gateway -> Lambda Proxy Integration
Returns HttpEvent The parsed event
Parse an HTTP Lambda event
$0
Object$0.body
$0.httpMethod
$0.pathParameters
$0.queryStringParameters
$0.headers
$0.requestContext
$0.cookies
options
Object See belowoptions.body
Object The body of the eventoptions.httpMethod
string String name of the http methodoptions.pathParameters
Object<string, string> An object of path part name, value pairsoptions.queryStringParameters
Object<string, Array<string>> An object of parameter name, array of values pairsoptions.headers
Object<string, Array<string>> An object of header name, array of values pairs
requestContext
Object The requestContext object
body
Object The body of the eventhttpMethod
string String name of the http methodpathParameters
Object<string, string> An object of path part name, value pairsqueryStringParameters
Object<string, Array<string>> An object of parameter name, array of values pairsheaders
Object<string, Array<string>> An object of header name, array of values pairsrequestContext
Object The requestContext objectcookies
Object<string, string> Parsed cookies
Parse a Lambda SQS event
sqsEvent
Object A Lambda SQS event
Returns SqsEvent The parsed SQS event
An SQS Event
body
Object The body of the event
A json response with statusCode
$0
Object$0.statusCode
$0.body
statusCode
number The statusCode of the responsebody
Object The json object body of the response
A serializer for handling statusCode and json object body responses
response
MultiStatusJsonResponse The result from processorctx
AppContext The context of the current execution
Returns Object Api gateway compatible response with statusCode, body, and headers set appropriately
A wrapper that handles top level logging/parsing/serialization orchestration
ctx
object Internal useparser
(optional, defaultevent=>event
)serializer
(optional, defaultdata=>data
)
Returns wrapper The wrapped processor
A processor that uses the provided parser and the multiStatusCodeJsonSerializer The response from the process needs to be in the form: { statusCode: [number], data: [JSON serializable object] }
ctx
object Internal useparser
(optional, defaultevent=>event
)serializer
(optional, defaultmultiStatusCodeJsonSerializer
)
Returns wrapper The wrapped processor
A method read a file from disk and parse it as JSON
args
...any The path as it would be provided to path.resolve
Returns Object The file contents parsed as JSON
A collection of logger redactions for common sensitive property paths.