Skip to content

Commit 05de462

Browse files
committed
Making this compatible with Node 8.10
1 parent e4ae133 commit 05de462

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

index.js

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const loadProbot = (plugin) => {
2222

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

25-
return (event, context, callback) => {
25+
return async (event, context) => {
2626

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

3939
// Otherwise let's listen handle the payload
@@ -53,21 +53,20 @@ module.exports.serverless = (plugin) => {
5353
console.log(`Received event ${e}${event.body.action ? ('.' + event.body.action) : ''}`)
5454
if (event) {
5555
try {
56-
probot.receive({
56+
await probot.receive({
5757
event: e,
5858
payload: event.body
59-
}).then(() => {
60-
const res = {
61-
statusCode: 200,
62-
body: JSON.stringify({
63-
message: 'Executed'
64-
})
65-
}
66-
return callback(null, res)
6759
})
60+
const res = {
61+
statusCode: 200,
62+
body: JSON.stringify({
63+
message: 'Hi Node8!'
64+
})
65+
}
66+
return context.done(null, res)
6867
} catch (err) {
6968
console.error(err)
70-
callback(err)
69+
return err
7170
}
7271
} else {
7372
console.error({ event, context })

0 commit comments

Comments
 (0)