import { APIGatewayEvent, Context, ProxyCallback, ProxyResult } from 'aws-lambda' export interface LambdaProxyHandler { (event: APIGatewayEvent, context: Context, callback: ProxyCallback): void } /** Processing one unit. */ export interface Process { (ambience: ProcessAmbience): Promise } /** Preparing before main process. */ export type BeforeProcess = Process /** Main process for request. */ export type MainProcess = Process /** After process. */ export type AfterProcess = Process /** Process that creating proxy result. */ export type ResponseProcess = Process /** Process that called when error occured. */ export type OnErrorProcess = Process export 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 } export interface IProcessor { before: BeforeProcess main: MainProcess after: AfterProcess response: ResponseProcess onError: OnErrorProcess toHandler: () => LambdaProxyHandler } export namespace IProcessor { export interface Params { main: MainProcess, environments: E, before?: BeforeProcess after?: AfterProcess response?: ResponseProcess onError?: OnErrorProcess } }