Uh oh!
There was an error while loading. Please reload this page.
forked from integrations/slack
- Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathlambdaHandler.js
More file actions
Latest commit
83 lines (72 loc) · 2.21 KB
/
Copy pathlambdaHandler.js
File metadata and controls
83 lines (72 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
constSentry=require('@sentry/node')
const{ exec }=require('child_process')
constinitializeAWSEnv=require('./initializeAWSEnv')
constserverlessExpress=require('aws-serverless-express')
module.exports.probot=async(event,context)=>{
// Load env vars from SecretsManager
try{
awaitinitializeAWSEnv()
}catch(error){
console.error(error)
returncontext.done(null,{
statusCode: 500,
body: JSON.stringify(error)
})
}
if(event.path==="/dbmigrate/"){
try{
awaitnewPromise((resolve,reject)=>{
constmigrate=exec(
'node_modules/sequelize-cli/lib/sequelize db:migrate',
{env: process.env},
(err,stdout,stderr)=>{
if(err){
reject(err)
}else{
resolve()
}
}
)
letmigrateOutput='';
migrate.stdout.on('data',(chunk)=>{
migrateOutput+=chunk.toString();
});
migrate.on('exit',function(code){
console.log(migrateOutput)
console.log(`Database migration completed with error code ${code}.`)
})
})
}catch(error){
console.error(error)
awaitSentry.flush(2500);
returncontext.done(null,{
statusCode: 500,
body: JSON.stringify(error)
})
}
returncontext.done(null,{
statusCode: 200,
body: JSON.stringify(`Migration complete.`)
})
}
const{ findPrivateKey }=require('probot/lib/private-key')
const{ createProbot }=require('probot')
constappFn=require('./lib')
constprobot=createProbot({
id: process.env.APP_ID,
secret: process.env.WEBHOOK_SECRET,
cert: findPrivateKey(),
port: process.env.PORT||3000,
webhookPath: '/github/events',
webhookProxy: process.env.WEBHOOK_PROXY_URL,
})
probot.load(appFn)
constserver=probot.server
server._socketPathSuffix=Math.random().toString(36).substring(2,15)
server._binaryTypes=[]
console.log("TEST POINT A")
constresult=serverlessExpress.proxy(server,event,context,"PROMISE")
constresponse=awaitresult.promise
console.log("RESPONSE",response)
returncontext.done(null,response)
}