@hybridless/hybridless 0.0.84-alpha20 → 0.0.84-alpha23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@ COPY proxy.js /usr/src/hybridless-runtime/proxy.js
|
|
|
7
7
|
# Set the working directory
|
|
8
8
|
WORKDIR /usr/src/app
|
|
9
9
|
|
|
10
|
-
RUN cd /usr/src/hybridless-runtime/ && npm i -S
|
|
10
|
+
RUN cd /usr/src/hybridless-runtime/ && npm i -S cuid
|
|
11
11
|
|
|
12
12
|
# Run the specified command within the container.
|
|
13
13
|
ENTRYPOINT ["node", "../hybridless-runtime/proxy.js"]
|
|
@@ -7,7 +7,7 @@ COPY proxy.js /usr/src/hybridless-runtime/proxy.js
|
|
|
7
7
|
# Set the working directory
|
|
8
8
|
WORKDIR /usr/src/app
|
|
9
9
|
|
|
10
|
-
RUN cd /usr/src/hybridless-runtime/ && npm i -S
|
|
10
|
+
RUN cd /usr/src/hybridless-runtime/ && npm i -S cuid
|
|
11
11
|
|
|
12
12
|
# Run the specified command within the container.
|
|
13
13
|
ENTRYPOINT ["node", "../hybridless-runtime/proxy.js"]
|
|
@@ -7,7 +7,7 @@ COPY proxy.js /usr/src/hybridless-runtime/proxy.js
|
|
|
7
7
|
# Set the working directory
|
|
8
8
|
WORKDIR /usr/src/app
|
|
9
9
|
|
|
10
|
-
RUN cd /usr/src/hybridless-runtime/ && npm i -S
|
|
10
|
+
RUN cd /usr/src/hybridless-runtime/ && npm i -S cuid
|
|
11
11
|
|
|
12
12
|
# Run the specified command within the container.
|
|
13
13
|
ENTRYPOINT ["node", "../hybridless-runtime/proxy.js"]
|
|
@@ -5,23 +5,41 @@ process.on('SIGINT', function() {
|
|
|
5
5
|
});
|
|
6
6
|
//Execution scope
|
|
7
7
|
(async () => {
|
|
8
|
+
//
|
|
8
9
|
try {
|
|
10
|
+
const cuid = require('cuid');
|
|
11
|
+
//helper
|
|
12
|
+
function _buildContext(callback) {
|
|
13
|
+
return {
|
|
14
|
+
awsRequestId: `${cuid()}-${cuid()}`,
|
|
15
|
+
callbackWaitsForEmptyEventLoop: true,
|
|
16
|
+
getRemainingTimeInMillis: () => { return 0; },
|
|
17
|
+
done: (err, data) => callback(err, data),
|
|
18
|
+
fail: (err) => callback(err),
|
|
19
|
+
succeed: (res) => callback(null, res),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
async function invoke(functionPath, input) {
|
|
23
|
+
return new Promise(async (resolve) => {
|
|
24
|
+
//Invoke
|
|
25
|
+
const context = _buildContext((err, data) => {
|
|
26
|
+
resolve({ err, data });
|
|
27
|
+
});
|
|
28
|
+
const resp = await (require(`${functionPath}`)[process.env.ENTRYPOINT_FUNC](input, context));
|
|
29
|
+
if (resp) resolve({data: resp}); //indicates sync content
|
|
30
|
+
});
|
|
31
|
+
}
|
|
9
32
|
//Get inputs
|
|
10
33
|
let input = {};
|
|
11
34
|
console.debug(process.argv);
|
|
12
35
|
try { input = JSON.parse(process.argv[2]); }
|
|
13
36
|
catch (e) { console.log('[Hybridless Runtime] - Error while decoding inputEvent parameter!', e); }
|
|
14
|
-
|
|
15
|
-
//Init lambda event and call it
|
|
16
|
-
const LambdaEvent = require("@hybridless/runtime-nodejs-httpd").LambdaEvent;
|
|
37
|
+
//Invoke
|
|
17
38
|
const functionPath = `${__dirname}/../app/${process.env.ENTRYPOINT}`;
|
|
18
|
-
const
|
|
19
|
-
//Callout
|
|
20
|
-
const resp = await lambda.invoke();
|
|
21
|
-
|
|
39
|
+
const resp = await invoke(functionPath, input);
|
|
22
40
|
//Return
|
|
23
41
|
console.debug(resp);
|
|
24
|
-
if (resp.
|
|
42
|
+
if (!resp.err && resp.data && resp.data.statusCode == 200) process.exit(0);
|
|
25
43
|
else process.exit(1);
|
|
26
44
|
} catch (e) {
|
|
27
45
|
console.error(e);
|