Open mkliu opened 3 years ago
I looked at the implementation and trying to do it this way:
async function(event: any, context: any, callback: any) {
if (!googleActionApp) {
googleActionApp = createApp()
}
await googleActionApp.frameworks.lambda.handle(googleActionApp.handler)(event, context, (err, res) => {
console.log('googleActionApp callback', err, res)
return res;
})
}
The request is returned by with this error from google test console
Invalid response from webhook: Failed to translate JSON to ExecuteHttpResponse..
nvm, find the solution myself, for anyone who's interested, this would work:
async function(event: any, context: any, callback: any) {
if (!googleActionApp) {
googleActionApp = createApp()
}
let response
await googleActionApp.frameworks.lambda.handle(googleActionApp.handler)(event, context, (err, res) => {
console.log('googleActionApp callback', err, res)
response = res;
})
return response
}
Seems like you may be interested in a postware
method to compliment the middleware
method.
So i know i could do
module.exports.googleHandler = googleActionApp
But i want to explicitly handle the call myself, so i could do something before the response is sent. Something like this:
I could see my handler's first method is starting to get called, but it always exits pre-maturally. Any suggestions?
Basically i want to flush logging before exit, if anyone know how to have a response middleware, it'll do the job too.