Skip to content

Commit

Permalink
fix: remove undocumented legacy callbacks (#18)
Browse files Browse the repository at this point in the history
`context.done` is from the pre-node4.10 runtime days of lambda, it was deprecated in favor of callback, which is optionally sidelined in favor of an async/promise-based return. If the function receives no callback and returns a promise or is marked as async, you should simply return/throw in order to actuate the callbacks.
  • Loading branch information
DavidJFelix authored Sep 17, 2020
1 parent 6e689c7 commit 0e6f825
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ module.exports.serverless = appFn => {
},
body: template
}
return context.done(null, res)
return res
}

// Otherwise let's listen handle the payload
Expand Down Expand Up @@ -79,21 +79,21 @@ module.exports.serverless = appFn => {
message: `Received ${e}.${event.body.action}`
})
}
return context.done(null, res)
return res
} catch (err) {
console.error(err)
return context.done(null, {
return {
statusCode: 500,
body: JSON.stringify(err)
})
}
}
} else {
console.error({ event, context })
context.done(null, 'unknown error')
throw 'unknown error'
}
return context.done(null, {
return {
statusCode: 200,
body: 'Nothing to do.'
})
}
}
}

0 comments on commit 0e6f825

Please sign in to comment.