-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap.ts
45 lines (40 loc) · 1.15 KB
/
bootstrap.ts
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
import { APIGatewayEvent, Callback, Context, Handler } from 'aws-lambda';
import * as AWS from 'aws-sdk';
import * as https from 'https';
const S3 = new AWS.S3();
const genScript: Handler = (
event: APIGatewayEvent,
context: Context,
cb: Callback
) => {
let version = event.queryStringParameters
? event.queryStringParameters.v || 'current'
: 'current';
S3.getObject(
{
Bucket: 'mikeworks-libs',
Key: `techcheck/${version}/bootstrap.sh`
},
(err, data) => {
//
if (!data) {
cb(null, {
statusCode: 200,
body: `/** There is a problem with the script generation service. Please try again later **/
console.log('⚠️ There is a problem with the script generation service. Please try again later ⚠️');
`
});
return;
}
const response = {
statusCode: 200,
body: data.Body.toString().replace(
'https://mikeworks-libs.s3.amazonaws.com/techcheck/index.js',
`https://f2co98an90.execute-api.us-west-2.amazonaws.com/dev/preflight/script?v=${version}`
)
};
cb(null, response);
}
);
};
export default genScript;