configurapi-runner-lambda-api 2.0.1 → 2.1.0

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.
Files changed (2) hide show
  1. package/package.json +2 -3
  2. package/src/index.mjs +11 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "configurapi-runner-lambda-api",
3
- "version": "2.0.1",
3
+ "version": "2.1.0",
4
4
  "description": "A lambda runner for configurapi.",
5
5
  "bin": {
6
6
  "configurapi-runner-lambda-api": "src/index.mjs"
@@ -24,8 +24,7 @@
24
24
  "configurapi-handler-http": "^1.4.1",
25
25
  "configurapi-handler-logging": "^1.4.0",
26
26
  "http-status": "^1.4.2",
27
- "oneliner": "0.0.8",
28
- "yargs-parser": "^11.1.1"
27
+ "oneliner": "0.0.8"
29
28
  },
30
29
  "devDependencies": {
31
30
  "@types/chai": "^4.2.9",
package/src/index.mjs CHANGED
@@ -29,7 +29,7 @@ service.on("error", (s) => log('Error', s));
29
29
  ///////////////////////////////////
30
30
  // Entry point
31
31
  ///////////////////////////////////
32
- export const handler = async (awsEvent, context, callback) =>
32
+ export const handler = async (awsEvent, context) =>
33
33
  {
34
34
  try
35
35
  {
@@ -49,12 +49,20 @@ export const handler = async (awsEvent, context, callback) =>
49
49
 
50
50
  await service.process(event);
51
51
 
52
- callback(undefined, Adapter.toResponse(event.response, context))
52
+ return Adapter.toResponse(event.response, context)
53
53
  }
54
54
  catch(error)
55
55
  {
56
56
  let response = new Configurapi.ErrorResponse(error, -1);
57
57
 
58
- callback(JSON.stringify(response));
58
+ const body = typeof response.body === 'string'
59
+ ? response.body
60
+ : JSON.stringify(response.body || '');
61
+
62
+ return {
63
+ statusCode: response.statusCode,
64
+ headers: response.headers,
65
+ body: body,
66
+ };
59
67
  }
60
68
  };