Skip to content

Commit 0e6f825

Browse files
authored
fix: remove undocumented legacy callbacks (#18)
`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.
1 parent 6e689c7 commit 0e6f825

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

index.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ module.exports.serverless = appFn => {
3636
},
3737
body: template
3838
}
39-
return context.done(null, res)
39+
return res
4040
}
4141

4242
// Otherwise let's listen handle the payload
@@ -79,21 +79,21 @@ module.exports.serverless = appFn => {
7979
message: `Received ${e}.${event.body.action}`
8080
})
8181
}
82-
return context.done(null, res)
82+
return res
8383
} catch (err) {
8484
console.error(err)
85-
return context.done(null, {
85+
return {
8686
statusCode: 500,
8787
body: JSON.stringify(err)
88-
})
88+
}
8989
}
9090
} else {
9191
console.error({ event, context })
92-
context.done(null, 'unknown error')
92+
throw 'unknown error'
9393
}
94-
return context.done(null, {
94+
return {
9595
statusCode: 200,
9696
body: 'Nothing to do.'
97-
})
97+
}
9898
}
9999
}

0 commit comments

Comments
 (0)