@comicrelief/lambda-wrapper 2.0.0-beta.1 → 2.0.0-beta.11
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/README.md +26 -3
- package/dist/core/DependencyAwareClass.d.ts +4 -3
- package/dist/core/DependencyAwareClass.d.ts.map +1 -1
- package/dist/core/DependencyAwareClass.js.map +1 -1
- package/dist/core/DependencyInjection.d.ts +6 -6
- package/dist/core/DependencyInjection.d.ts.map +1 -1
- package/dist/core/DependencyInjection.js +24 -2
- package/dist/core/DependencyInjection.js.map +1 -1
- package/dist/core/LambdaWrapper.d.ts +21 -9
- package/dist/core/LambdaWrapper.d.ts.map +1 -1
- package/dist/core/LambdaWrapper.js +55 -11
- package/dist/core/LambdaWrapper.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -4
- package/dist/index.js.map +1 -1
- package/dist/models/ResponseModel.d.ts +4 -22
- package/dist/models/ResponseModel.d.ts.map +1 -1
- package/dist/models/ResponseModel.js +2 -2
- package/dist/models/ResponseModel.js.map +1 -1
- package/dist/services/LoggerService.d.ts.map +1 -1
- package/dist/services/LoggerService.js +8 -17
- package/dist/services/LoggerService.js.map +1 -1
- package/dist/services/RequestService.d.ts +3 -3
- package/dist/services/RequestService.d.ts.map +1 -1
- package/dist/services/RequestService.js +9 -7
- package/dist/services/RequestService.js.map +1 -1
- package/dist/services/SQSService.d.ts +97 -15
- package/dist/services/SQSService.d.ts.map +1 -1
- package/dist/services/SQSService.js +74 -29
- package/dist/services/SQSService.js.map +1 -1
- package/dist/types/Status.d.ts +6 -0
- package/dist/types/Status.d.ts.map +1 -0
- package/dist/types/Status.js +3 -0
- package/dist/types/Status.js.map +1 -0
- package/package.json +17 -17
- package/dist/models/StatusModel.d.ts +0 -40
- package/dist/models/StatusModel.d.ts.map +0 -1
- package/dist/models/StatusModel.js +0 -50
- package/dist/models/StatusModel.js.map +0 -1
package/README.md
CHANGED
|
@@ -13,9 +13,9 @@ If you're coming from v1 and updating to v2, check out the [v2 migration guide](
|
|
|
13
13
|
Install via npm or Yarn:
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
|
-
npm i @comicrelief/lambda-wrapper
|
|
16
|
+
npm i @comicrelief/lambda-wrapper@beta
|
|
17
17
|
# or
|
|
18
|
-
yarn add @comicrelief/lambda-wrapper
|
|
18
|
+
yarn add @comicrelief/lambda-wrapper@beta
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
You can then wrap your Lambda handler functions like this:
|
|
@@ -186,7 +186,7 @@ When you go to configure your Lambda Wrapper, you can now include your dependenc
|
|
|
186
186
|
```ts
|
|
187
187
|
lambdaWrapper.configure<WithSQSServiceConfig>({
|
|
188
188
|
sqs: {
|
|
189
|
-
queues: 42 // Oops! This will be
|
|
189
|
+
queues: 42 // Oops! This will be flagged as a type error by TypeScript
|
|
190
190
|
},
|
|
191
191
|
});
|
|
192
192
|
```
|
|
@@ -204,6 +204,29 @@ lambdaWrapper.configure<WithSQSServiceConfig & WithOtherServiceConfig>({
|
|
|
204
204
|
});
|
|
205
205
|
```
|
|
206
206
|
|
|
207
|
+
## Monitoring
|
|
208
|
+
|
|
209
|
+
At Comic Relief we use [Lumigo](https://lumigo.io/) for monitoring and observability of our deployed services. Lambda Wrapper includes the Lumigo tracer to allow us to tag traces with custom labels and metrics ([execution tags](https://docs.lumigo.io/docs/execution-tags)).
|
|
210
|
+
|
|
211
|
+
Lumigo integration works out-of-the-box with Lumigo's [auto-trace feature](https://docs.lumigo.io/docs/serverless-applications#automatic-instrumentation). If you prefer manual tracing, enable it by setting `LUMIGO_TRACER_TOKEN` in your Lambda environment variables.
|
|
212
|
+
|
|
213
|
+
And if you don't use Lumigo, don't worry, their tracer will not be instantiated in your functions and no calls will be made to their servers unless `LUMIGO_TRACER_TOKEN` is set.
|
|
214
|
+
|
|
215
|
+
## Notes
|
|
216
|
+
|
|
217
|
+
Lambda Wrapper's dependency injection relies on class names being preserved. If your build process includes minifying or uglifying your code, you'll need to disable these transformations.
|
|
218
|
+
|
|
219
|
+
In many of our projects we use `serverless-webpack` to bundle service code prior to deployment. To disable name mangling, set `optimization.minimize` to `false` in your webpack config:
|
|
220
|
+
|
|
221
|
+
```js
|
|
222
|
+
// webpack.config.js
|
|
223
|
+
module.exports = {
|
|
224
|
+
// ...
|
|
225
|
+
optimization: {
|
|
226
|
+
minimize: false,
|
|
227
|
+
},
|
|
228
|
+
```
|
|
229
|
+
|
|
207
230
|
## Development
|
|
208
231
|
|
|
209
232
|
### Testing
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import DependencyInjection from './DependencyInjection';
|
|
2
|
+
import { LambdaWrapperConfig } from './config';
|
|
2
3
|
/**
|
|
3
4
|
* Base class for dependencies.
|
|
4
5
|
*/
|
|
5
|
-
export default class DependencyAwareClass {
|
|
6
|
-
readonly di: DependencyInjection
|
|
7
|
-
constructor(di: DependencyInjection);
|
|
6
|
+
export default class DependencyAwareClass<TConfig extends LambdaWrapperConfig = any> {
|
|
7
|
+
readonly di: DependencyInjection<TConfig>;
|
|
8
|
+
constructor(di: DependencyInjection<TConfig>);
|
|
8
9
|
/**
|
|
9
10
|
* Get dependency injection container.
|
|
10
11
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DependencyAwareClass.d.ts","sourceRoot":"","sources":["../../src/core/DependencyAwareClass.ts"],"names":[],"mappings":"AAAA,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"DependencyAwareClass.d.ts","sourceRoot":"","sources":["../../src/core/DependencyAwareClass.ts"],"names":[],"mappings":"AAAA,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAE/C;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,oBAAoB,CAAC,OAAO,SAAS,mBAAmB,GAAG,GAAG;IACrE,QAAQ,CAAC,EAAE,EAAE,mBAAmB,CAAC,OAAO,CAAC;gBAAhC,EAAE,EAAE,mBAAmB,CAAC,OAAO,CAAC;IAErD;;;;OAIG;IACH,YAAY,IAAI,mBAAmB;CAGpC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DependencyAwareClass.js","sourceRoot":"","sources":["../../src/core/DependencyAwareClass.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"DependencyAwareClass.js","sourceRoot":"","sources":["../../src/core/DependencyAwareClass.ts"],"names":[],"mappings":";;AAGA;;GAEG;AACH,MAAqB,oBAAoB;IACvC,YAAqB,EAAgC;QAAhC,OAAE,GAAF,EAAE,CAA8B;IAAG,CAAC;IAEzD;;;;OAIG;IACH,YAAY;QACV,OAAO,IAAI,CAAC,EAAE,CAAC;IACjB,CAAC;CACF;AAXD,uCAWC"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { Context } from 'aws-lambda';
|
|
2
2
|
import DependencyAwareClass from './DependencyAwareClass';
|
|
3
3
|
import { LambdaWrapperConfig } from './config';
|
|
4
|
-
declare type Class<
|
|
4
|
+
declare type Class<TInstance, TConfig extends LambdaWrapperConfig> = new (di: DependencyInjection<TConfig>) => TInstance;
|
|
5
5
|
/**
|
|
6
6
|
* Dependency injection container.
|
|
7
7
|
*
|
|
8
8
|
* Dependencies (singleton instances of dependency-aware classes) are provided
|
|
9
9
|
* to the main Lambda handler and other dependencies via this class.
|
|
10
10
|
*/
|
|
11
|
-
export default class DependencyInjection {
|
|
12
|
-
readonly config:
|
|
11
|
+
export default class DependencyInjection<TConfig extends LambdaWrapperConfig = any> {
|
|
12
|
+
readonly config: TConfig;
|
|
13
13
|
readonly event: any;
|
|
14
14
|
readonly context: Context;
|
|
15
15
|
/**
|
|
@@ -20,13 +20,13 @@ export default class DependencyInjection {
|
|
|
20
20
|
* True until all dependencies have been constructed.
|
|
21
21
|
*/
|
|
22
22
|
private isConstructing;
|
|
23
|
-
constructor(config:
|
|
23
|
+
constructor(config: TConfig, event: any, context: Context);
|
|
24
24
|
/**
|
|
25
25
|
* Get the singleton instance of the given dependency.
|
|
26
26
|
*
|
|
27
27
|
* @param dependency
|
|
28
28
|
*/
|
|
29
|
-
get<T extends DependencyAwareClass>(dependency: Class<T>): T;
|
|
29
|
+
get<T extends DependencyAwareClass>(dependency: Class<T, TConfig>): T;
|
|
30
30
|
/**
|
|
31
31
|
* Get the event passed to AWS Lambda.
|
|
32
32
|
*
|
|
@@ -44,7 +44,7 @@ export default class DependencyInjection {
|
|
|
44
44
|
*
|
|
45
45
|
* @deprecated Use `di.config` instead.
|
|
46
46
|
*/
|
|
47
|
-
getConfiguration():
|
|
47
|
+
getConfiguration(): TConfig;
|
|
48
48
|
/**
|
|
49
49
|
* True if the function is being executed in `serverless-offline`.
|
|
50
50
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DependencyInjection.d.ts","sourceRoot":"","sources":["../../src/core/DependencyInjection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAG/C,aAAK,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"DependencyInjection.d.ts","sourceRoot":"","sources":["../../src/core/DependencyInjection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAG/C,aAAK,KAAK,CAAC,SAAS,EAAE,OAAO,SAAS,mBAAmB,IAAI,KAAK,EAAE,EAAE,mBAAmB,CAAC,OAAO,CAAC,KAAK,SAAS,CAAC;AAEjH;;;;;GAKG;AACH,MAAM,CAAC,OAAO,OAAO,mBAAmB,CAAC,OAAO,SAAS,mBAAmB,GAAG,GAAG;IAY9E,QAAQ,CAAC,MAAM,EAAE,OAAO;IACxB,QAAQ,CAAC,KAAK,EAAE,GAAG;IACnB,QAAQ,CAAC,OAAO,EAAE,OAAO;IAb3B;;OAEG;IACH,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;IAE5D;;OAEG;IACH,OAAO,CAAC,cAAc,CAAQ;gBAGnB,MAAM,EAAE,OAAO,EACf,KAAK,EAAE,GAAG,EACV,OAAO,EAAE,OAAO;IAyC3B;;;;OAIG;IACH,GAAG,CAAC,CAAC,SAAS,oBAAoB,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,GAAG,CAAC;IAsBrE;;;;OAIG;IACH,QAAQ;IAIR;;;;OAIG;IACH,UAAU;IAIV;;;;OAIG;IACH,gBAAgB;IAIhB;;;;;;;;;;OAUG;IACH,IAAI,SAAS,IAAI,OAAO,CAIvB;CACF"}
|
|
@@ -15,7 +15,29 @@ class DependencyInjection {
|
|
|
15
15
|
* True until all dependencies have been constructed.
|
|
16
16
|
*/
|
|
17
17
|
this.isConstructing = true;
|
|
18
|
-
|
|
18
|
+
// get unique dependency classes -- a class may be included several times,
|
|
19
|
+
// but should be instantiated only once
|
|
20
|
+
const classes = Array.from(new Set(Object.values(config.dependencies)));
|
|
21
|
+
// guard against duplicate keys
|
|
22
|
+
const countByName = classes
|
|
23
|
+
.map((Constructor) => Constructor.name)
|
|
24
|
+
.reduce((counts, name) => ({ ...counts, [name]: (counts[name] || 0) + 1 }), {});
|
|
25
|
+
if (Object.values(countByName).some((count) => count > 1)) {
|
|
26
|
+
const duplicateNames = Object.entries(countByName)
|
|
27
|
+
.filter(([, count]) => count > 1)
|
|
28
|
+
.map(([name]) => name);
|
|
29
|
+
// if all class names are single-letter, they're probably minified -- in
|
|
30
|
+
// this case, give a hint about how to fix it
|
|
31
|
+
const action = duplicateNames.every((it) => it.length === 1)
|
|
32
|
+
? "If you don't recognise the single-letter names listed above, your "
|
|
33
|
+
+ "bundler may be minifying your code. You'll need to disable this "
|
|
34
|
+
+ 'for Lambda Wrapper to work correctly. Please refer to the Notes '
|
|
35
|
+
+ 'section of the Lambda Wrapper readme:\n\n'
|
|
36
|
+
+ ' https://github.com/comicrelief/lambda-wrapper/tree/beta#notes'
|
|
37
|
+
: 'Please ensure that all dependency classes have a unique name.';
|
|
38
|
+
throw new Error(`Dependency names are not unique: ${duplicateNames.join(', ')}\n\n${action}`);
|
|
39
|
+
}
|
|
40
|
+
// instantiate all dependencies
|
|
19
41
|
this.dependencies = Object.fromEntries(classes.map((Constructor) => [Constructor.name, new Constructor(this)]));
|
|
20
42
|
this.isConstructing = false;
|
|
21
43
|
}
|
|
@@ -27,7 +49,7 @@ class DependencyInjection {
|
|
|
27
49
|
get(dependency) {
|
|
28
50
|
if (this.isConstructing) {
|
|
29
51
|
throw new Error('Dependencies are not available in dependency class constructors.\n\n'
|
|
30
|
-
+ 'To fix this, call `di.get` in the function where the dependency is'
|
|
52
|
+
+ 'To fix this, call `di.get` in the function where the dependency is '
|
|
31
53
|
+ 'used instead of inside your constructor.');
|
|
32
54
|
}
|
|
33
55
|
const name = dependency.name;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DependencyInjection.js","sourceRoot":"","sources":["../../src/core/DependencyInjection.ts"],"names":[],"mappings":";;AAQA;;;;;GAKG;AACH,MAAqB,mBAAmB;IAWtC,YACW,
|
|
1
|
+
{"version":3,"file":"DependencyInjection.js","sourceRoot":"","sources":["../../src/core/DependencyInjection.ts"],"names":[],"mappings":";;AAQA;;;;;GAKG;AACH,MAAqB,mBAAmB;IAWtC,YACW,MAAe,EACf,KAAU,EACV,OAAgB;QAFhB,WAAM,GAAN,MAAM,CAAS;QACf,UAAK,GAAL,KAAK,CAAK;QACV,YAAO,GAAP,OAAO,CAAS;QAR3B;;WAEG;QACK,mBAAc,GAAG,IAAI,CAAC;QAO5B,0EAA0E;Q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daW
|
|
|
24
24
|
/**
|
|
25
25
|
* Wrap the given function.
|
|
26
26
|
*/
|
|
27
|
-
wrap<T>(handler: (di: DependencyInjection) => Promise<T>, options?: WrapOptions): (event: any, context: Context) => Promise<any>;
|
|
27
|
+
wrap<T>(handler: (di: DependencyInjection<TConfig>) => T | Promise<T>, options?: WrapOptions): (event: any, context: Context) => Promise<any>;
|
|
28
|
+
/**
|
|
29
|
+
* `true` if we will send traces to Lumigo.
|
|
30
|
+
*
|
|
31
|
+
* The `LUMIGO_TRACER_TOKEN` env var is present in both manually traced and
|
|
32
|
+
* auto-traced functions.
|
|
33
|
+
*/
|
|
34
|
+
static get isLumigoEnabled(): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* `true` if the Lambda function is already being traced by a higher-level
|
|
37
|
+
* Lumigo wrapper, in which case we don't need to manually wrap our handlers.
|
|
38
|
+
*
|
|
39
|
+
* There are two ways that this can be done, based on the documentation
|
|
40
|
+
* [here](https://docs.lumigo.io/docs/lambda-layers): using a Lambda runtime
|
|
41
|
+
* wrapper, or handler redirection. Each method can be detected via its
|
|
42
|
+
* environment variables. Auto-trace uses the runtime wrapper.
|
|
43
|
+
*/
|
|
44
|
+
static get isLumigoWrappingUs(): boolean;
|
|
28
45
|
/**
|
|
29
46
|
* Process the result once we have one.
|
|
30
47
|
*
|
|
@@ -33,11 +50,10 @@ export default class LambdaWrapper<TConfig extends LambdaWrapperConfig = LambdaW
|
|
|
33
50
|
*/
|
|
34
51
|
static handleSuccess(di: DependencyInjection, result: any): any;
|
|
35
52
|
/**
|
|
36
|
-
* Gracefully handles an error, logging in
|
|
53
|
+
* Gracefully handles an error, logging in Lumigo and generating a response
|
|
37
54
|
* reflecting the `code` of the error, if defined.
|
|
38
55
|
*
|
|
39
|
-
*
|
|
40
|
-
* Epsagon generates alerts for logs on level ERROR. This means that
|
|
56
|
+
* Lumigo generates alerts for logs on level ERROR. This means that
|
|
41
57
|
* `logger.error` will produce an alert. To avoid meaningless notifications,
|
|
42
58
|
* most likely coming from tests, we log INFO unless either:
|
|
43
59
|
*
|
|
@@ -50,11 +66,7 @@ export default class LambdaWrapper<TConfig extends LambdaWrapperConfig = LambdaW
|
|
|
50
66
|
*/
|
|
51
67
|
static handleError(di: DependencyInjection, error: Error, throwError?: boolean): {
|
|
52
68
|
statusCode: any;
|
|
53
|
-
headers:
|
|
54
|
-
'Content-Type': string;
|
|
55
|
-
'Access-Control-Allow-Origin': string;
|
|
56
|
-
'Access-Control-Allow-Credentials': boolean;
|
|
57
|
-
};
|
|
69
|
+
headers: Record<string, string>;
|
|
58
70
|
body: string;
|
|
59
71
|
} | Error;
|
|
60
72
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LambdaWrapper.d.ts","sourceRoot":"","sources":["../../src/core/LambdaWrapper.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAInC,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAe,MAAM,UAAU,CAAC;AAE5D,MAAM,WAAW,WAAW;IAC1B;;;;;;;OAOG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC;AAED,MAAM,CAAC,OAAO,OAAO,aAAa,CAAC,OAAO,SAAS,mBAAmB,GAAG,mBAAmB;IAC9E,QAAQ,CAAC,MAAM,EAAE,OAAO;gBAAf,MAAM,EAAE,OAAO;IAEpC;;;;OAIG;IACH,SAAS,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,WAAW,GAAG,aAAa,CAAC,OAAO,GAAG,WAAW,CAAC;IAIpG;;OAEG;IACH,IAAI,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"LambdaWrapper.d.ts","sourceRoot":"","sources":["../../src/core/LambdaWrapper.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAInC,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAe,MAAM,UAAU,CAAC;AAE5D,MAAM,WAAW,WAAW;IAC1B;;;;;;;OAOG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC;AAED,MAAM,CAAC,OAAO,OAAO,aAAa,CAAC,OAAO,SAAS,mBAAmB,GAAG,mBAAmB;IAC9E,QAAQ,CAAC,MAAM,EAAE,OAAO;gBAAf,MAAM,EAAE,OAAO;IAEpC;;;;OAIG;IACH,SAAS,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,WAAW,GAAG,aAAa,CAAC,OAAO,GAAG,WAAW,CAAC;IAIpG;;OAEG;IACH,IAAI,CAAC,CAAC,EACJ,OAAO,EAAE,CAAC,EAAE,EAAE,mBAAmB,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,EAC7D,OAAO,CAAC,EAAE,WAAW,WAMO,GAAG,WAAW,OAAO;IAyDnD;;;;;OAKG;IACH,MAAM,KAAK,eAAe,IAAI,OAAO,CAEpC;IAED;;;;;;;;OAQG;IACH,MAAM,KAAK,kBAAkB,IAAI,OAAO,CAKvC;IAED;;;;;OAKG;IACH,MAAM,CAAC,aAAa,CAAC,EAAE,EAAE,mBAAmB,EAAE,MAAM,EAAE,GAAG;IASzD;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,WAAW,CAAC,EAAE,EAAE,mBAAmB,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,UAAQ;;;;;CA8B7E"}
|
|
@@ -1,9 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
27
|
};
|
|
5
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const
|
|
29
|
+
const lumigo = __importStar(require("@lumigo/tracer"));
|
|
7
30
|
const ResponseModel_1 = __importDefault(require("../models/ResponseModel"));
|
|
8
31
|
const LoggerService_1 = __importDefault(require("../services/LoggerService"));
|
|
9
32
|
const RequestService_1 = __importDefault(require("../services/RequestService"));
|
|
@@ -63,16 +86,38 @@ class LambdaWrapper {
|
|
|
63
86
|
return handled;
|
|
64
87
|
}
|
|
65
88
|
};
|
|
66
|
-
// If
|
|
67
|
-
if (
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
wrapper =
|
|
89
|
+
// If Lumigo is enabled, wrap the handler in the Lumigo wrapper
|
|
90
|
+
if (LambdaWrapper.isLumigoEnabled && !LambdaWrapper.isLumigoWrappingUs) {
|
|
91
|
+
const tracer = lumigo.initTracer({ token: process.env.LUMIGO_TRACER_TOKEN });
|
|
92
|
+
// Lumigo's wrapper works with both callbacks or promises handlers, and
|
|
93
|
+
// the returned function behaves the same way as the original. For our
|
|
94
|
+
// promise-based handler we can safely coerce the type.
|
|
95
|
+
wrapper = tracer.trace(wrapper);
|
|
73
96
|
}
|
|
74
97
|
return wrapper;
|
|
75
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* `true` if we will send traces to Lumigo.
|
|
101
|
+
*
|
|
102
|
+
* The `LUMIGO_TRACER_TOKEN` env var is present in both manually traced and
|
|
103
|
+
* auto-traced functions.
|
|
104
|
+
*/
|
|
105
|
+
static get isLumigoEnabled() {
|
|
106
|
+
return !!process.env.LUMIGO_TRACER_TOKEN;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* `true` if the Lambda function is already being traced by a higher-level
|
|
110
|
+
* Lumigo wrapper, in which case we don't need to manually wrap our handlers.
|
|
111
|
+
*
|
|
112
|
+
* There are two ways that this can be done, based on the documentation
|
|
113
|
+
* [here](https://docs.lumigo.io/docs/lambda-layers): using a Lambda runtime
|
|
114
|
+
* wrapper, or handler redirection. Each method can be detected via its
|
|
115
|
+
* environment variables. Auto-trace uses the runtime wrapper.
|
|
116
|
+
*/
|
|
117
|
+
static get isLumigoWrappingUs() {
|
|
118
|
+
return this.isLumigoEnabled && (process.env.AWS_LAMBDA_EXEC_WRAPPER === '/opt/lumigo_wrapper'
|
|
119
|
+
|| !!process.env.LUMIGO_ORIGINAL_HANDLER);
|
|
120
|
+
}
|
|
76
121
|
/**
|
|
77
122
|
* Process the result once we have one.
|
|
78
123
|
*
|
|
@@ -86,11 +131,10 @@ class LambdaWrapper {
|
|
|
86
131
|
return result;
|
|
87
132
|
}
|
|
88
133
|
/**
|
|
89
|
-
* Gracefully handles an error, logging in
|
|
134
|
+
* Gracefully handles an error, logging in Lumigo and generating a response
|
|
90
135
|
* reflecting the `code` of the error, if defined.
|
|
91
136
|
*
|
|
92
|
-
*
|
|
93
|
-
* Epsagon generates alerts for logs on level ERROR. This means that
|
|
137
|
+
* Lumigo generates alerts for logs on level ERROR. This means that
|
|
94
138
|
* `logger.error` will produce an alert. To avoid meaningless notifications,
|
|
95
139
|
* most likely coming from tests, we log INFO unless either:
|
|
96
140
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LambdaWrapper.js","sourceRoot":"","sources":["../../src/core/LambdaWrapper.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"LambdaWrapper.js","sourceRoot":"","sources":["../../src/core/LambdaWrapper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uDAAyC;AAGzC,4EAAoD;AACpD,8EAAsD;AACtD,gFAAwD;AACxD,gFAAwD;AACxD,qCAA4D;AAc5D,MAAqB,aAAa;IAChC,YAAqB,MAAe;QAAf,WAAM,GAAN,MAAM,CAAS;IAAG,CAAC;IAExC;;;;OAIG;IACH,SAAS,CAAc,MAAsC;QAC3D,OAAO,IAAI,aAAa,CAAC,IAAA,oBAAW,EAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC7D,CAAC;IAED;;OAEG;IACH,IAAI,CACF,OAA6D,EAC7D,OAAqB;QAErB,MAAM,EACJ,oBAAoB,GAAG,IAAI,GAC5B,GAAG,OAAO,IAAI,EAAE,CAAC;QAElB,IAAI,OAAO,GAAG,KAAK,EAAE,KAAU,EAAE,OAAgB,EAAE,EAAE;YACnD,MAAM,EAAE,GAAG,IAAI,6BAAmB,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;YAChE,MAAM,OAAO,GAAG,EAAE,CAAC,GAAG,CAAC,wBAAc,CAAC,CAAC;YACvC,MAAM,MAAM,GAAG,EAAE,CAAC,GAAG,CAAC,uBAAa,CAAC,CAAC;YAErC,OAAO,CAAC,8BAA8B,GAAG,KAAK,CAAC;YAE/C,8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AC;SACrB;aAAM;YACL,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SACpB;QAED,IAAI,UAAU,EAAE;YACd,IAAI,KAAK,YAAY,KAAK,EAAE;gBAC1B,OAAO,KAAK,CAAC;aACd;YAED,mEAAmE;YACnE,wEAAwE;YACxE,OAAO,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC;SACzB;QAED,OAAO,uBAAa,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,IAAI,GAAG,EAAE,OAAO,CAAC,CAAC;IAC5D,CAAC;CACF;AAtKD,gCAsKC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -14,15 +14,15 @@ export { LambdaWrapperConfig } from './core/config';
|
|
|
14
14
|
export { default as DependencyAwareClass } from './core/DependencyAwareClass';
|
|
15
15
|
export { default as DependencyInjection } from './core/DependencyInjection';
|
|
16
16
|
export { default as LambdaWrapper, WrapOptions } from './core/LambdaWrapper';
|
|
17
|
-
export { default as ResponseModel, } from './models/ResponseModel';
|
|
17
|
+
export { default as ResponseModel, RESPONSE_HEADERS, } from './models/ResponseModel';
|
|
18
18
|
export { default as SQSMessageModel, } from './models/SQSMessageModel';
|
|
19
|
-
export { default as StatusModel, STATUS_TYPES, } from './models/StatusModel';
|
|
20
19
|
export { default as BaseConfigService, } from './services/BaseConfigService';
|
|
21
20
|
export { default as HTTPService, COMICRELIEF_TEST_METADATA_HEADER, } from './services/HTTPService';
|
|
22
21
|
export { default as LoggerService, } from './services/LoggerService';
|
|
23
22
|
export { default as RequestService, REQUEST_TYPES, RequestFile, } from './services/RequestService';
|
|
24
|
-
export { default as SQSService, SQS_OFFLINE_MODES, SQS_PUBLISH_FAILURE_MODES, SQSServiceConfig, WithSQSServiceConfig, } from './services/SQSService';
|
|
23
|
+
export { default as SQSService, QueueName, SQS_OFFLINE_MODES, SQS_PUBLISH_FAILURE_MODES, SQSServiceConfig, WithSQSServiceConfig, } from './services/SQSService';
|
|
25
24
|
export { default as TimerService, } from './services/TimerService';
|
|
25
|
+
export { ServiceStatus, Status, } from './types/Status';
|
|
26
26
|
export { default as LambdaTermination } from './utils/LambdaTermination';
|
|
27
27
|
export { default as PromisifiedDelay } from './utils/PromisifiedDelay';
|
|
28
28
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAGpD,OAAmB,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAGzE;;;;;GAKG;AACH,QAAA,MAAM,aAAa,2DAOjB,CAAC;AAEH,eAAe,aAAa,CAAC;AAE7B,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAC9E,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAC5E,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAE7E,OAAO,EACL,OAAO,IAAI,aAAa,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAGpD,OAAmB,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAGzE;;;;;GAKG;AACH,QAAA,MAAM,aAAa,2DAOjB,CAAC;AAEH,eAAe,aAAa,CAAC;AAE7B,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAC9E,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAC5E,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAE7E,OAAO,EACL,OAAO,IAAI,aAAa,EACxB,gBAAgB,GACjB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,OAAO,IAAI,eAAe,GAC3B,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,OAAO,IAAI,iBAAiB,GAC7B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,OAAO,IAAI,WAAW,EACtB,gCAAgC,GACjC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,OAAO,IAAI,aAAa,GACzB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,OAAO,IAAI,cAAc,EACzB,aAAa,EACb,WAAW,GACZ,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,OAAO,IAAI,UAAU,EACrB,SAAS,EACT,iBAAiB,EACjB,yBAAyB,EACzB,gBAAgB,EAChB,oBAAoB,GACrB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,OAAO,IAAI,YAAY,GACxB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,aAAa,EACb,MAAM,GACP,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,0BAA0B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.PromisifiedDelay = exports.LambdaTermination = exports.TimerService = exports.SQS_PUBLISH_FAILURE_MODES = exports.SQS_OFFLINE_MODES = exports.SQSService = exports.REQUEST_TYPES = exports.RequestService = exports.LoggerService = exports.COMICRELIEF_TEST_METADATA_HEADER = exports.HTTPService = exports.BaseConfigService = exports.
|
|
6
|
+
exports.PromisifiedDelay = exports.LambdaTermination = exports.TimerService = exports.SQS_PUBLISH_FAILURE_MODES = exports.SQS_OFFLINE_MODES = exports.SQSService = exports.REQUEST_TYPES = exports.RequestService = exports.LoggerService = exports.COMICRELIEF_TEST_METADATA_HEADER = exports.HTTPService = exports.BaseConfigService = exports.SQSMessageModel = exports.RESPONSE_HEADERS = exports.ResponseModel = exports.LambdaWrapper = exports.DependencyInjection = exports.DependencyAwareClass = void 0;
|
|
7
7
|
const LambdaWrapper_1 = __importDefault(require("./core/LambdaWrapper"));
|
|
8
8
|
const LoggerService_1 = __importDefault(require("./services/LoggerService"));
|
|
9
9
|
const RequestService_1 = __importDefault(require("./services/RequestService"));
|
|
@@ -32,11 +32,9 @@ var LambdaWrapper_2 = require("./core/LambdaWrapper");
|
|
|
32
32
|
Object.defineProperty(exports, "LambdaWrapper", { enumerable: true, get: function () { return __importDefault(LambdaWrapper_2).default; } });
|
|
33
33
|
var ResponseModel_1 = require("./models/ResponseModel");
|
|
34
34
|
Object.defineProperty(exports, "ResponseModel", { enumerable: true, get: function () { return __importDefault(ResponseModel_1).default; } });
|
|
35
|
+
Object.defineProperty(exports, "RESPONSE_HEADERS", { enumerable: true, get: function () { return ResponseModel_1.RESPONSE_HEADERS; } });
|
|
35
36
|
var SQSMessageModel_1 = require("./models/SQSMessageModel");
|
|
36
37
|
Object.defineProperty(exports, "SQSMessageModel", { enumerable: true, get: function () { return __importDefault(SQSMessageModel_1).default; } });
|
|
37
|
-
var StatusModel_1 = require("./models/StatusModel");
|
|
38
|
-
Object.defineProperty(exports, "StatusModel", { enumerable: true, get: function () { return __importDefault(StatusModel_1).default; } });
|
|
39
|
-
Object.defineProperty(exports, "STATUS_TYPES", { enumerable: true, get: function () { return StatusModel_1.STATUS_TYPES; } });
|
|
40
38
|
var BaseConfigService_1 = require("./services/BaseConfigService");
|
|
41
39
|
Object.defineProperty(exports, "BaseConfigService", { enumerable: true, get: function () { return __importDefault(BaseConfigService_1).default; } });
|
|
42
40
|
var HTTPService_1 = require("./services/HTTPService");
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,yEAAiD;AAEjD,6EAAqD;AACrD,+EAAuD;AACvD,uEAAyE;AACzE,2EAAmD;AAEnD;;;;;GAKG;AACH,MAAM,aAAa,GAAG,IAAI,uBAAa,CAA6C;IAClF,YAAY,EAAE;QACZ,aAAa,EAAb,uBAAa;QACb,cAAc,EAAd,wBAAc;QACd,UAAU,EAAV,oBAAU;QACV,YAAY,EAAZ,sBAAY;KACb;CACF,CAAC,CAAC;AAEH,kBAAe,aAAa,CAAC;AAK7B,oEAA8E;AAArE,6IAAA,OAAO,OAAwB;AACxC,kEAA4E;AAAnE,2IAAA,OAAO,OAAuB;AACvC,sDAA6E;AAApE,+HAAA,OAAO,OAAiB;AAEjC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,yEAAiD;AAEjD,6EAAqD;AACrD,+EAAuD;AACvD,uEAAyE;AACzE,2EAAmD;AAEnD;;;;;GAKG;AACH,MAAM,aAAa,GAAG,IAAI,uBAAa,CAA6C;IAClF,YAAY,EAAE;QACZ,aAAa,EAAb,uBAAa;QACb,cAAc,EAAd,wBAAc;QACd,UAAU,EAAV,oBAAU;QACV,YAAY,EAAZ,sBAAY;KACb;CACF,CAAC,CAAC;AAEH,kBAAe,aAAa,CAAC;AAK7B,oEAA8E;AAArE,6IAAA,OAAO,OAAwB;AACxC,kEAA4E;AAAnE,2IAAA,OAAO,OAAuB;AACvC,sDAA6E;AAApE,+HAAA,OAAO,OAAiB;AAEjC,wDAGgC;AAF9B,+HAAA,OAAO,OAAiB;AACxB,iHAAA,gBAAgB,OAAA;AAElB,4DAEkC;AADhC,mIAAA,OAAO,OAAmB;AAG5B,kEAEsC;AADpC,uIAAA,OAAO,OAAqB;AAE9B,sDAGgC;AAF9B,2HAAA,OAAO,OAAe;AACtB,+HAAA,gCAAgC,OAAA;AAElC,0DAEkC;AADhC,+HAAA,OAAO,OAAiB;AAE1B,4DAImC;AAHjC,iIAAA,OAAO,OAAkB;AACzB,+GAAA,aAAa,OAAA;AAGf,oDAO+B;AAN7B,yHAAA,OAAO,OAAc;AAErB,+GAAA,iBAAiB,OAAA;AACjB,uHAAA,yBAAyB,OAAA;AAI3B,wDAEiC;AAD/B,6HAAA,OAAO,OAAgB;AAQzB,+DAAyE;AAAhE,uIAAA,OAAO,OAAqB;AACrC,6DAAuE;AAA9D,qIAAA,OAAO,OAAoB"}
|
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* HTTP headers to be included in
|
|
2
|
+
* HTTP headers to be included in `ResponseModel`.
|
|
3
3
|
*/
|
|
4
|
-
export declare const RESPONSE_HEADERS:
|
|
5
|
-
'Content-Type': string;
|
|
6
|
-
/** Required for CORS support to work */
|
|
7
|
-
'Access-Control-Allow-Origin': string;
|
|
8
|
-
/** Required for cookies, authorization headers with HTTPS */
|
|
9
|
-
'Access-Control-Allow-Credentials': boolean;
|
|
10
|
-
};
|
|
4
|
+
export declare const RESPONSE_HEADERS: Record<string, string>;
|
|
11
5
|
/**
|
|
12
6
|
* Default message provided as part of response.
|
|
13
7
|
*/
|
|
@@ -57,13 +51,7 @@ export default class ResponseModel {
|
|
|
57
51
|
*/
|
|
58
52
|
generate(): {
|
|
59
53
|
statusCode: any;
|
|
60
|
-
headers:
|
|
61
|
-
'Content-Type': string;
|
|
62
|
-
/** Required for CORS support to work */
|
|
63
|
-
'Access-Control-Allow-Origin': string;
|
|
64
|
-
/** Required for cookies, authorization headers with HTTPS */
|
|
65
|
-
'Access-Control-Allow-Credentials': boolean;
|
|
66
|
-
};
|
|
54
|
+
headers: Record<string, string>;
|
|
67
55
|
body: string;
|
|
68
56
|
};
|
|
69
57
|
/**
|
|
@@ -78,13 +66,7 @@ export default class ResponseModel {
|
|
|
78
66
|
*/
|
|
79
67
|
static generate(data?: any, code?: number, message?: string): {
|
|
80
68
|
statusCode: any;
|
|
81
|
-
headers:
|
|
82
|
-
'Content-Type': string;
|
|
83
|
-
/** Required for CORS support to work */
|
|
84
|
-
'Access-Control-Allow-Origin': string;
|
|
85
|
-
/** Required for cookies, authorization headers with HTTPS */
|
|
86
|
-
'Access-Control-Allow-Credentials': boolean;
|
|
87
|
-
};
|
|
69
|
+
headers: Record<string, string>;
|
|
88
70
|
body: string;
|
|
89
71
|
};
|
|
90
72
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResponseModel.d.ts","sourceRoot":"","sources":["../../src/models/ResponseModel.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,gBAAgB
|
|
1
|
+
{"version":3,"file":"ResponseModel.d.ts","sourceRoot":"","sources":["../../src/models/ResponseModel.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAMnD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe,YAAY,CAAC;AAEzC;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,aAAa;IAChC,IAAI,EAAE,GAAG,CAAC;IAEV,IAAI,EAAE,GAAG,CAAC;gBAEE,IAAI,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM;IAQvD;;;;;OAKG;IACH,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG;IAIvC;;;;OAIG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM;IAIpB;;;;OAIG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM;IAIpB;;OAEG;IACH,OAAO;IAIP;;;;OAIG;IACH,UAAU,CAAC,OAAO,EAAE,MAAM;IAI1B;;OAEG;IACH,UAAU;IAIV;;OAEG;IACH,QAAQ;;;;;IAQR;;;;;;;;;OASG;IACH,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM;;;;;CAI5D"}
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DEFAULT_MESSAGE = exports.RESPONSE_HEADERS = void 0;
|
|
4
4
|
/**
|
|
5
|
-
* HTTP headers to be included in
|
|
5
|
+
* HTTP headers to be included in `ResponseModel`.
|
|
6
6
|
*/
|
|
7
7
|
exports.RESPONSE_HEADERS = {
|
|
8
8
|
'Content-Type': 'application/json',
|
|
9
9
|
/** Required for CORS support to work */
|
|
10
10
|
'Access-Control-Allow-Origin': '*',
|
|
11
11
|
/** Required for cookies, authorization headers with HTTPS */
|
|
12
|
-
'Access-Control-Allow-Credentials': true,
|
|
12
|
+
'Access-Control-Allow-Credentials': 'true',
|
|
13
13
|
};
|
|
14
14
|
/**
|
|
15
15
|
* Default message provided as part of response.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResponseModel.js","sourceRoot":"","sources":["../../src/models/ResponseModel.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACU,QAAA,gBAAgB,
|
|
1
|
+
{"version":3,"file":"ResponseModel.js","sourceRoot":"","sources":["../../src/models/ResponseModel.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACU,QAAA,gBAAgB,GAA2B;IACtD,cAAc,EAAE,kBAAkB;IAClC,wCAAwC;IACxC,6BAA6B,EAAE,GAAG;IAClC,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,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;QAC/C,OAAO,QAAQ,CAAC,QAAQ,EAAE,CAAC;IAC7B,CAAC;CACF;AAzFD,gCAyFC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LoggerService.d.ts","sourceRoot":"","sources":["../../src/services/LoggerService.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"LoggerService.d.ts","sourceRoot":"","sources":["../../src/services/LoggerService.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,OAAO,oBAAoB,MAAM,8BAA8B,CAAC;AAChE,OAAO,mBAAmB,MAAM,6BAA6B,CAAC;AAc9D;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,oBAAoB;IAC7D,OAAO,CAAC,MAAM,CAAuB;IAErC,OAAO,CAAC,OAAO,CAAwB;gBAE3B,EAAE,EAAE,mBAAmB;IA6BnC;;;;;OAKG;IACH,SAAS;IA6BT;;;;;OAKG;IACH,IAAI,MAAM,mBAMT;IAED;;OAEG;IACH,SAAS;IAIT;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,iBAAiB,CAAC,KAAK,EAAE,UAAU;IAkB1C;;;;OAIG;IACH,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,GAAG;IAUlC;;;;;OAKG;IACH,KAAK,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,SAAK;IAc9B;;;;OAIG;IACH,IAAI,CAAC,OAAO,EAAE,GAAG;IAIjB;;;;;;;;;OASG;IACH,OAAO,CAAC,KAAK,EAAE,GAAG;IAUlB;;;;;OAKG;IACH,KAAK,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,UAAQ;IAUxC;;;;;;OAMG;IACH,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,MAAM,UAAQ;IAUhE;;;;;;OAMG;IACH,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,GAAE,OAAO,GAAG,SAAS,GAAG,MAAe;CASjF"}
|
|
@@ -26,10 +26,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
const lumigo = __importStar(require("@lumigo/tracer"));
|
|
29
30
|
const Sentry = __importStar(require("@sentry/node"));
|
|
30
|
-
const epsagon_1 = __importDefault(require("epsagon"));
|
|
31
31
|
const winston_1 = __importDefault(require("winston"));
|
|
32
32
|
const DependencyAwareClass_1 = __importDefault(require("../core/DependencyAwareClass"));
|
|
33
|
+
const LambdaWrapper_1 = __importDefault(require("../core/LambdaWrapper"));
|
|
33
34
|
const sentryIsAvailable = typeof process.env.RAVEN_DSN !== 'undefined' && typeof process.env.RAVEN_DSN === 'string' && process.env.RAVEN_DSN !== 'undefined';
|
|
34
35
|
// initialise the Sentry client if available
|
|
35
36
|
if (sentryIsAvailable) {
|
|
@@ -168,12 +169,8 @@ class LoggerService extends DependencyAwareClass_1.default {
|
|
|
168
169
|
if (sentryIsAvailable && error instanceof Error) {
|
|
169
170
|
Sentry.captureException(error);
|
|
170
171
|
}
|
|
171
|
-
if (
|
|
172
|
-
|
|
173
|
-
&& typeof process.env.EPSAGON_SERVICE_NAME === 'string'
|
|
174
|
-
&& process.env.EPSAGON_SERVICE_NAME !== 'undefined'
|
|
175
|
-
&& error instanceof Error) {
|
|
176
|
-
epsagon_1.default.setError(error);
|
|
172
|
+
if (LambdaWrapper_1.default.isLumigoEnabled && error instanceof Error) {
|
|
173
|
+
lumigo.error(message || error.message, { err: error });
|
|
177
174
|
}
|
|
178
175
|
this.logger.log('error', message, { error: LoggerService.processMessage(error) });
|
|
179
176
|
this.label('error', true);
|
|
@@ -211,11 +208,8 @@ class LoggerService extends DependencyAwareClass_1.default {
|
|
|
211
208
|
* @param silent If `false`, the label will also be logged. (default: false)
|
|
212
209
|
*/
|
|
213
210
|
label(descriptor, silent = false) {
|
|
214
|
-
if (
|
|
215
|
-
|
|
216
|
-
&& typeof process.env.EPSAGON_SERVICE_NAME === 'string'
|
|
217
|
-
&& process.env.EPSAGON_SERVICE_NAME !== 'undefined') {
|
|
218
|
-
epsagon_1.default.label(descriptor, true);
|
|
211
|
+
if (LambdaWrapper_1.default.isLumigoEnabled) {
|
|
212
|
+
lumigo.addExecutionTag(descriptor, true);
|
|
219
213
|
}
|
|
220
214
|
if (!silent) {
|
|
221
215
|
this.logger.log('info', `label - ${descriptor}`);
|
|
@@ -229,11 +223,8 @@ class LoggerService extends DependencyAwareClass_1.default {
|
|
|
229
223
|
* @param silent If `false`, the metric will also be logged. (default: false)
|
|
230
224
|
*/
|
|
231
225
|
metric(descriptor, stat, silent = false) {
|
|
232
|
-
if (
|
|
233
|
-
|
|
234
|
-
&& typeof process.env.EPSAGON_SERVICE_NAME === 'string'
|
|
235
|
-
&& process.env.EPSAGON_SERVICE_NAME !== 'undefined') {
|
|
236
|
-
epsagon_1.default.label(descriptor, stat);
|
|
226
|
+
if (LambdaWrapper_1.default.isLumigoEnabled) {
|
|
227
|
+
lumigo.addExecutionTag(descriptor, stat);
|
|
237
228
|
}
|
|
238
229
|
if (silent === false) {
|
|
239
230
|
this.logger.log('info', `metric - ${descriptor} - ${stat}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LoggerService.js","sourceRoot":"","sources":["../../src/services/LoggerService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAuC;AAEvC,sDAA8B;
|
|
1
|
+
{"version":3,"file":"LoggerService.js","sourceRoot":"","sources":["../../src/services/LoggerService.ts"],"names":[],"mappings":";;;;;;;;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C,CAAC;SAC7D;IACH,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,MAAc,EAAE,MAAW,EAAE,QAAsC,MAAM;QAC9E,IAAI,CAAC,CAAC,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE;YACnD,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;SAC3C;QAED,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAEhD,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC;IAChD,CAAC;CACF;AAzOD,gCAyOC"}
|
|
@@ -37,11 +37,11 @@ export default class RequestService extends DependencyAwareClass {
|
|
|
37
37
|
/**
|
|
38
38
|
* Get all HTTP headers included in the request.
|
|
39
39
|
*
|
|
40
|
+
* Header names are converted to lowercase.
|
|
41
|
+
*
|
|
40
42
|
* @returns An object with a key for each header.
|
|
41
43
|
*/
|
|
42
|
-
getAllHeaders():
|
|
43
|
-
[x: string]: string | undefined;
|
|
44
|
-
};
|
|
44
|
+
getAllHeaders(): Record<string, string | undefined>;
|
|
45
45
|
/**
|
|
46
46
|
* Get an HTTP header from the request.
|
|
47
47
|
*
|