Is there a way to have 2 routes (GET + POST) using...
# help
j
Is there a way to have 2 routes (GET + POST) using the same function and using
defaultFunctionProps
on
Api
.? Once I create the function manually so it can be reused, it throws:
The "defaultFunctionProps" cannot be applied if an instance of a Function construct is passed in.
t
we can't mutate the function once you've created it hence the error
you can also set defaults at the stack or app level if that helps
j
yea I realize that, wonder what would be the most elegant solution
I don't like that when I need to do this for one set of routes, I have to redo all other routes that depended on these defaults ... Perhaps
createFunctionFactory(defaults)(functionProps)
that would handle merging the defaults would be better then the current "inheritance" approach
Or since there probably aren't other use cases, SST could allow something like eg:
"GET,POST /path": {}
f
yeah that’s good point. Lemme add it to our roadmap.
We are in the middle of making a structural change to SST constructs to provide a consistent and transparent way to modify underlying CDK constructs for thing SST doesn’t support yet (ie. Parameter Mapping).
We will get to this after that is wrapped up.