Framework for development lambda-proxy function of AWS Lambda.
npm install lamprox```
$ npm install lamprox
.
Process is a function as shown below. `
interface Process {
(ambience: ProcessAmbience): Promise
}interface ProcessAmbience {
/* Variables that pssed lambda function. /
lambda: {
event: APIGatewayEvent
context: Context
callback: ProxyCallback
}
/* Result that preceding process. /
result?: T
/* Shared variables accross that processes. /
environments: E
}
`$3
Processor is a class that collects processes and executes them in order.
Processor holds the processes before, main, after, response, onError and executes it as a handler. `
/* Preparing before main process. /
type BeforeProcess = Process
/* Main process for request. /
type MainProcess = Process
/* After process. /
type AfterProcess = Process
/* Process that creating proxy result. /
type ResponseProcess = Process
/* Process that called when error occured. /
type OnErrorProcess = Processinterface IProcessor {
before: BeforeProcess
main: MainProcess
after: AfterProcess
response: ResponseProcess
onError: OnErrorProcess
toHandler: () => LambdaProxyHandler
}
`$3
Generally, it is not necessary to directly generate a processor.
Lamprox provides several functions for creating handler. ####
lamprox()
Create simple lambda proxy handler.
You can create a handler for lambda-proxy by simply writing a method to generate the response body. `
lamprox: (main: MainProcess) => LambdaProxyHandler
`####
buildHandler()
Create lambda function with various processes - befire, after, response, onError - and enviroments.
Enviroments is value shared across processes. `
buildHandler: (parmas: LambdaProxyHandlerBuilder.Params) => LambdaProxyHandler
`####
prepareHandlerBuilder()
prepareHandlerBuilder() is a function for creating buildHandler function.
Assuming that there are many Lambda functions, you can generate a buildHandler function that defines a common process. `
prepareHandlerBuilder: (preparedOptions?: ProcessorOptions) => LambdaProxyHandlerBuilder
`$3
Lamprox contains node-lambda-utilities, but provides some utility functions for lambda-proxy. ####
generateDummyAPIGatewayEvent()
This is a function for generating a dummy APIGatewayEvent.
You can test the handler by using it together with invokeHandler() of node-lambda-utilities. `
generateDummyAPIGatewayEvent: (params?: GenerateDummyAPIGatewayEvent.Params) => APIGatewayEvent
`####
generateProcessAmbience()
A function that generates ProcessAmbience which is an argument when Process is executed.
By using this, it is possible to test each Process. `
generateProcessAmbience: (params: GenerateProcessAmbience.Params) => ProcessAmbience
``