I am familiar with invoking lambda from another lambda and also to pass param to handler function based on which it calls different methods from a service(Same as stated here AWS Lambda - Invoke a method of another lambda function), But when there is a case to expose all the methods of a service its quite tedious to add multiple condition in the handler function.
So my question is Is there any dynamic way we can expose all the methods of the service using single lambda handler function, or may be any other efficient way. My main motive is to expose whole method in a service using lambda handler so that I don't have to add different conditions and another lambda can invoke it method name without any conditional parameter.
Sample code here
export const handler = async function(params: params,
context: Context,
callback: Callback) {
if(params.type === 'type1'){
const results = await testService.testmethod1(params.value);
context.succeed(results);
}
else if(params.type === 'type2'){
const results = await testService.testmethod2(params.value);
context.succeed(results);
} and so on...
};
So Is there any way we can expose all methods of testService(above we have exposed to methods testmethod1 and testmethode, there can be other methods as well) without all these conditional statements?