-
Notifications
You must be signed in to change notification settings - Fork 2k
Description
Hello!
At the moment, the only way to connect a lambda handler function to an APIGw route (or Function construct) is to pass it as a string path:
src/blabla/certainLambdasFile.handlerFunction. This is consistent with how CloudFormation refers to the handler method, but otherwise pretty gimmicky as something to be written "by hand".
When working in an all-typescript project, possibly a monorepo, it would be super handy to pass the handler by reference:
import { handlerFunction} from 'src/blabla/certainLambdasFile';
// ...
'GET /myLambda' : handlerFunction
// ..
There's been a discussion on Slack explaining it's rather difficult from the architecture standpoint.
Perhaps it would be possible to bypass the architectural problems, by "cheating" at build-time, swapping the references with their paths?
Also, is a "freely dangling" exported function the only way to export a handler? Would a class method, or the following syntax be possible anyhow?
export function MyLambdas() {
function handler() { }
return { handler }
}