@comicrelief/lambda-wrapper 2.0.0-beta.15 → 2.0.0-beta.16
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 +12 -1
- package/dist/core/LambdaWrapper.d.ts +9 -0
- package/dist/core/LambdaWrapper.d.ts.map +1 -1
- package/dist/core/LambdaWrapper.js +20 -0
- package/dist/core/LambdaWrapper.js.map +1 -1
- package/dist/services/LoggerService.d.ts +1 -1
- package/dist/services/LoggerService.js +1 -1
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -96,6 +96,17 @@ export default class MyService extends DependencyAwareClass {
|
|
|
96
96
|
}
|
|
97
97
|
```
|
|
98
98
|
|
|
99
|
+
If you need to override the constructor, it must take a `DependencyInjection` instance and pass it to `super`.
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
export default class MyService extends DependencyAwareClass {
|
|
103
|
+
constructor(di: DependencyInjection) {
|
|
104
|
+
super(di);
|
|
105
|
+
// now do your other constructor stuff
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
99
110
|
Then add it to your Lambda Wrapper configuration in the `dependencies` key.
|
|
100
111
|
|
|
101
112
|
```ts
|
|
@@ -231,7 +242,7 @@ module.exports = {
|
|
|
231
242
|
|
|
232
243
|
### Testing
|
|
233
244
|
|
|
234
|
-
Run `yarn test` to run the unit tests.
|
|
245
|
+
Run `yarn test` to run the unit tests, and `yarn test:types` to run the type tests.
|
|
235
246
|
|
|
236
247
|
When writing a bugfix, start by writing a test that reproduces the problem. It should fail with the current version of Lambda Wrapper, and pass once you've implemented the fix.
|
|
237
248
|
|
|
@@ -15,6 +15,15 @@ export interface WrapOptions {
|
|
|
15
15
|
export default class LambdaWrapper<TConfig extends LambdaWrapperConfig = LambdaWrapperConfig> {
|
|
16
16
|
readonly config: TConfig;
|
|
17
17
|
constructor(config: TConfig);
|
|
18
|
+
/**
|
|
19
|
+
* Validate the given config object.
|
|
20
|
+
*
|
|
21
|
+
* This is mainly to benefit projects that are not using TypeScript, where
|
|
22
|
+
* missing properties or incorrect types would not otherwise be flagged up.
|
|
23
|
+
*
|
|
24
|
+
* @param config
|
|
25
|
+
*/
|
|
26
|
+
static validateConfig(config: LambdaWrapperConfig): void;
|
|
18
27
|
/**
|
|
19
28
|
* Returns a new Lambda Wrapper with the given configuration applied.
|
|
20
29
|
*
|
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"LambdaWrapper.d.ts","sourceRoot":"","sources":["../../src/core/LambdaWrapper.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAKnC,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;IAIpC;;;;;;;OAOG;IACH,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,mBAAmB,GAAG,IAAI;IAYxD;;;;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"}
|
|
@@ -30,11 +30,31 @@ const lumigo = __importStar(require("@lumigo/tracer"));
|
|
|
30
30
|
const ResponseModel_1 = __importDefault(require("../models/ResponseModel"));
|
|
31
31
|
const LoggerService_1 = __importDefault(require("../services/LoggerService"));
|
|
32
32
|
const RequestService_1 = __importDefault(require("../services/RequestService"));
|
|
33
|
+
const DependencyAwareClass_1 = __importDefault(require("./DependencyAwareClass"));
|
|
33
34
|
const DependencyInjection_1 = __importDefault(require("./DependencyInjection"));
|
|
34
35
|
const config_1 = require("./config");
|
|
35
36
|
class LambdaWrapper {
|
|
36
37
|
constructor(config) {
|
|
37
38
|
this.config = config;
|
|
39
|
+
LambdaWrapper.validateConfig(config);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Validate the given config object.
|
|
43
|
+
*
|
|
44
|
+
* This is mainly to benefit projects that are not using TypeScript, where
|
|
45
|
+
* missing properties or incorrect types would not otherwise be flagged up.
|
|
46
|
+
*
|
|
47
|
+
* @param config
|
|
48
|
+
*/
|
|
49
|
+
static validateConfig(config) {
|
|
50
|
+
if (!config.dependencies) {
|
|
51
|
+
throw new TypeError("config is missing the 'dependencies' key");
|
|
52
|
+
}
|
|
53
|
+
Object.values(config.dependencies).forEach((dep) => {
|
|
54
|
+
if (!(dep.prototype instanceof DependencyAwareClass_1.default)) {
|
|
55
|
+
throw new TypeError(`dependency '${dep.name}' does not extend DependencyAwareClass`);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
38
58
|
}
|
|
39
59
|
/**
|
|
40
60
|
* Returns a new Lambda Wrapper with the given configuration applied.
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
1
|
+
{"version":3,"file":"LambdaWrapper.js","sourceRoot":"","sources":["../../src/core/LambdaWrapper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uDAAyC;AAGzC,4EAAoD;AACpD,8EAAsD;AACtD,gFAAwD;AACxD,kFAA0D;AAC1D,gFAAwD;AACxD,qCAA4D;AAc5D,MAAqB,aAAa;IAChC,YAAqB,MAAe;QAAf,WAAM,GAAN,MAAM,CAAS;QAClC,aAAa,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;IACvC,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,cAAc,CAAC,MAA2B;QAC/C,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE;YACxB,MAAM,IAAI,SAAS,CAAC,0CAA0C,CAAC,CAAC;SACjE;QAED,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;YACjD,IAAI,CAAC,CAAC,GAAG,CAAC,SAAS,YAAY,8BAAoB,CAAC,EAAE;gBACpD,MAAM,IAAI,SAAS,CAAC,eAAe,GAAG,CAAC,IAAI,wCAAwC,CAAC,CAAC;aACtF;QACH,CAAC,CAAC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G,EAAE,CAAC,GAAG,CAAC,uBAAa,CAAC,CAAC;QAErC,iEAAiE;QACjE,MAAM,CAAC,MAAM,CAAC,mBAAmB,EAAE,MAAM,EAAE,UAAU,IAAI,GAAG,CAAC,CAAC;QAE9D,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,WAAW,CAAC,EAAuB,EAAE,KAAY,EAAE,UAAU,GAAG,KAAK;QAC1E,MAAM,MAAM,GAAG,EAAE,CAAC,GAAG,CAAC,uBAAa,CAAC,CAAC;QAErC,MAAM,EACJ,IAAI,EACJ,cAAc,EACd,IAAI,GAAG,EAAE,EACT,OAAO,GAAG,eAAe,GAC1B,GAAG,KAAY,CAAC;QAEjB,MAAM,CAAC,MAAM,CAAC,mBAAmB,EAAE,IAAI,IAAI,GAAG,CAAC,CAAC;QAEhD,IAAI,cAAc,IAAI,CAAC,IAAI,IAAI,IAAI,IAAI,GAAG,EAAE;YAC1C,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;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;AA5LD,gCA4LC"}
|
|
@@ -8,7 +8,7 @@ import DependencyInjection from '../core/DependencyInjection';
|
|
|
8
8
|
*
|
|
9
9
|
* For logging we use [Winston](https://github.com/winstonjs/winston).
|
|
10
10
|
* Errors will also be sent to [Sentry](https://sentry.io/) and
|
|
11
|
-
* [
|
|
11
|
+
* [Lumigo](https://lumigo.io/) if those are configured.
|
|
12
12
|
*/
|
|
13
13
|
export default class LoggerService extends DependencyAwareClass {
|
|
14
14
|
private sentry;
|
|
@@ -45,7 +45,7 @@ if (sentryIsAvailable) {
|
|
|
45
45
|
*
|
|
46
46
|
* For logging we use [Winston](https://github.com/winstonjs/winston).
|
|
47
47
|
* Errors will also be sent to [Sentry](https://sentry.io/) and
|
|
48
|
-
* [
|
|
48
|
+
* [Lumigo](https://lumigo.io/) if those are configured.
|
|
49
49
|
*/
|
|
50
50
|
class LoggerService extends DependencyAwareClass_1.default {
|
|
51
51
|
constructor(di) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@comicrelief/lambda-wrapper",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.16",
|
|
4
4
|
"description": "Lambda wrapper for all Comic Relief Serverless Projects",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"author": "Adam Clark",
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"clean": "rm -rf dist",
|
|
19
19
|
"lint": "eslint src tests",
|
|
20
20
|
"test": "jest",
|
|
21
|
+
"test:types": "tsc -p tsconfig-type-test.json",
|
|
21
22
|
"coverage": "yarn test --coverage"
|
|
22
23
|
},
|
|
23
24
|
"devDependencies": {
|
|
@@ -35,6 +36,7 @@
|
|
|
35
36
|
"eslint": "^8.57.0",
|
|
36
37
|
"eslint-plugin-import": "^2.25.2",
|
|
37
38
|
"eslint-plugin-jsdoc": "^39.3.2",
|
|
39
|
+
"expect-type": "^0.18.0",
|
|
38
40
|
"jest": "^29.7.0",
|
|
39
41
|
"nyc": "^15.1.0",
|
|
40
42
|
"semantic-release": "^19.0.5",
|