Skip to content

Commit

Permalink
Making this compatible with Node 8.10
Browse files Browse the repository at this point in the history
  • Loading branch information
tcbyrd committed Apr 3, 2018
1 parent e4ae133 commit 05de462
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const loadProbot = (plugin) => {

module.exports.serverless = (plugin) => {

return (event, context, callback) => {
return async (event, context) => {

// 🤖 A friendly homepage if there isn't a payload
if (event.httpMethod === 'GET' && event.path === '/probot') {
Expand All @@ -33,7 +33,7 @@ module.exports.serverless = (plugin) => {
},
body: template
}
return callback(null, res)
return context.done(null, res)
}

// Otherwise let's listen handle the payload
Expand All @@ -53,21 +53,20 @@ module.exports.serverless = (plugin) => {
console.log(`Received event ${e}${event.body.action ? ('.' + event.body.action) : ''}`)
if (event) {
try {
probot.receive({
await probot.receive({
event: e,
payload: event.body
}).then(() => {
const res = {
statusCode: 200,
body: JSON.stringify({
message: 'Executed'
})
}
return callback(null, res)
})
const res = {
statusCode: 200,
body: JSON.stringify({
message: 'Hi Node8!'
})
}
return context.done(null, res)
} catch (err) {
console.error(err)
callback(err)
return err
}
} else {
console.error({ event, context })
Expand Down

0 comments on commit 05de462

Please sign in to comment.