@mbc-cqrs-serverless/core 0.1.65-beta.0 → 0.1.66-beta.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.
- package/dist/env.validation.d.ts +0 -1
- package/dist/env.validation.js +0 -5
- package/dist/env.validation.js.map +1 -1
- package/dist/notifications/appsync.service.d.ts +4 -3
- package/dist/notifications/appsync.service.js +10 -23
- package/dist/notifications/appsync.service.js.map +1 -1
- package/dist/notifications/event/notification.event.handler.d.ts +1 -3
- package/dist/notifications/event/notification.event.handler.js +2 -9
- package/dist/notifications/event/notification.event.handler.js.map +1 -1
- package/package.json +2 -2
- package/dist/interfaces/appsync-endpoint.interface.d.ts +0 -7
- package/dist/interfaces/appsync-endpoint.interface.js +0 -3
- package/dist/interfaces/appsync-endpoint.interface.js.map +0 -1
package/dist/env.validation.d.ts
CHANGED
package/dist/env.validation.js
CHANGED
|
@@ -101,11 +101,6 @@ __decorate([
|
|
|
101
101
|
(0, class_validator_1.IsOptional)(),
|
|
102
102
|
__metadata("design:type", String)
|
|
103
103
|
], EnvironmentVariables.prototype, "APPSYNC_ENDPOINT", void 0);
|
|
104
|
-
__decorate([
|
|
105
|
-
(0, class_validator_1.IsString)(),
|
|
106
|
-
(0, class_validator_1.IsOptional)(),
|
|
107
|
-
__metadata("design:type", String)
|
|
108
|
-
], EnvironmentVariables.prototype, "APPSYNC_SECOND_ENDPOINT", void 0);
|
|
109
104
|
__decorate([
|
|
110
105
|
(0, class_validator_1.IsString)(),
|
|
111
106
|
(0, class_validator_1.IsOptional)(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.validation.js","sourceRoot":"","sources":["../src/env.validation.ts"],"names":[],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"env.validation.js","sourceRoot":"","sources":["../src/env.validation.ts"],"names":[],"mappings":";;;;;;;;;;;;AAiFA,8CAoBC;AArGD,yDAAqE;AACrE,qDAQwB;AAExB,I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AAA,4BAAU,GAAE;;wDACK;AAElB;IADC,IAAA,0BAAQ,GAAE;;4DACW;AAGxB,SAAgB,iBAAiB,CAC/B,GAAyB;IAEzB,OAAO,SAAS,QAAQ,CAAC,MAA+B;QACtD,MAAM,eAAe,GAAG,IAAA,mCAAe,EACrC,GAAG,IAAI,oBAAoB,EAC3B,MAAM,EACN;YACE,wBAAwB,EAAE,IAAI;SAC/B,CACF,CAAA;QACD,MAAM,MAAM,GAAG,IAAA,8BAAY,EAAC,eAAe,EAAE;YAC3C,qBAAqB,EAAE,KAAK;SAC7B,CAAC,CAAA;QAEF,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAA;QACpC,CAAC;QACD,OAAO,eAAe,CAAA;IACxB,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { ConfigService } from '@nestjs/config';
|
|
2
2
|
import { INotification } from '../interfaces';
|
|
3
|
-
import { AppsyncType } from '../interfaces/appsync-endpoint.interface';
|
|
4
3
|
export declare class AppSyncService {
|
|
5
4
|
private readonly config;
|
|
6
5
|
private readonly logger;
|
|
7
|
-
private readonly
|
|
6
|
+
private readonly endpoint;
|
|
7
|
+
private readonly hostname;
|
|
8
|
+
private readonly apiKey;
|
|
8
9
|
private readonly region;
|
|
9
10
|
private readonly signer;
|
|
10
11
|
constructor(config: ConfigService);
|
|
11
|
-
sendMessage(msg: INotification
|
|
12
|
+
sendMessage(msg: INotification): Promise<any>;
|
|
12
13
|
}
|
|
@@ -37,22 +37,10 @@ let AppSyncService = AppSyncService_1 = class AppSyncService {
|
|
|
37
37
|
constructor(config) {
|
|
38
38
|
this.config = config;
|
|
39
39
|
this.logger = new common_1.Logger(AppSyncService_1.name);
|
|
40
|
-
this.
|
|
41
|
-
|
|
42
|
-
endpoint: config.get('APPSYNC_ENDPOINT'),
|
|
43
|
-
apiKey: config.get('APPSYNC_API_KEY'),
|
|
44
|
-
hostname: new URL(config.get('APPSYNC_ENDPOINT')).hostname,
|
|
45
|
-
},
|
|
46
|
-
};
|
|
47
|
-
if (config.get('APPSYNC_SECOND_ENDPOINT')) {
|
|
48
|
-
this.endpoints.second = {
|
|
49
|
-
endpoint: config.get('APPSYNC_SECOND_ENDPOINT'),
|
|
50
|
-
hostname: new URL(config.get('APPSYNC_SECOND_ENDPOINT'))
|
|
51
|
-
.hostname,
|
|
52
|
-
apiKey: config.get('APPSYNC_SECOND_API_KEY'),
|
|
53
|
-
};
|
|
54
|
-
}
|
|
40
|
+
this.endpoint = config.get('APPSYNC_ENDPOINT');
|
|
41
|
+
this.apiKey = config.get('APPSYNC_API_KEY');
|
|
55
42
|
this.region = 'ap-northeast-1';
|
|
43
|
+
this.hostname = new URL(this.endpoint).hostname;
|
|
56
44
|
this.signer = new signature_v4_1.SignatureV4({
|
|
57
45
|
credentials: (0, credential_provider_node_1.defaultProvider)(),
|
|
58
46
|
region: this.region,
|
|
@@ -60,11 +48,10 @@ let AppSyncService = AppSyncService_1 = class AppSyncService {
|
|
|
60
48
|
sha256: sha256_js_1.Sha256,
|
|
61
49
|
});
|
|
62
50
|
}
|
|
63
|
-
async sendMessage(msg
|
|
64
|
-
const { endpoint, hostname, apiKey } = this.endpoints[target];
|
|
51
|
+
async sendMessage(msg) {
|
|
65
52
|
const headers = {
|
|
66
53
|
'Content-Type': 'application/json',
|
|
67
|
-
host: hostname,
|
|
54
|
+
host: this.hostname,
|
|
68
55
|
};
|
|
69
56
|
const body = JSON.stringify({
|
|
70
57
|
query,
|
|
@@ -74,9 +61,9 @@ let AppSyncService = AppSyncService_1 = class AppSyncService {
|
|
|
74
61
|
});
|
|
75
62
|
const method = 'POST';
|
|
76
63
|
let res;
|
|
77
|
-
if (apiKey) {
|
|
78
|
-
headers['x-api-key'] = apiKey;
|
|
79
|
-
res = await (0, node_fetch_1.default)(endpoint, {
|
|
64
|
+
if (this.apiKey) {
|
|
65
|
+
headers['x-api-key'] = this.apiKey;
|
|
66
|
+
res = await (0, node_fetch_1.default)(this.endpoint, {
|
|
80
67
|
method,
|
|
81
68
|
headers,
|
|
82
69
|
body,
|
|
@@ -87,7 +74,7 @@ let AppSyncService = AppSyncService_1 = class AppSyncService {
|
|
|
87
74
|
method,
|
|
88
75
|
headers,
|
|
89
76
|
protocol: 'https:',
|
|
90
|
-
hostname: hostname,
|
|
77
|
+
hostname: this.hostname,
|
|
91
78
|
path: '/graphql',
|
|
92
79
|
body,
|
|
93
80
|
region: this.region,
|
|
@@ -96,7 +83,7 @@ let AppSyncService = AppSyncService_1 = class AppSyncService {
|
|
|
96
83
|
const signedRequest = await this.signer.sign(request, {
|
|
97
84
|
signingDate: new Date(),
|
|
98
85
|
});
|
|
99
|
-
res = await (0, node_fetch_1.default)(endpoint, {
|
|
86
|
+
res = await (0, node_fetch_1.default)(this.endpoint, {
|
|
100
87
|
method: signedRequest.method,
|
|
101
88
|
headers: signedRequest.headers,
|
|
102
89
|
body: signedRequest.body,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"appsync.service.js","sourceRoot":"","sources":["../../src/notifications/appsync.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAA8C;AAC9C,gFAAmE;AACnE,wDAAmD;AACnD,2CAAmD;AACnD,2CAA8C;AAC9C,4DAA4C;
|
|
1
|
+
{"version":3,"file":"appsync.service.js","sourceRoot":"","sources":["../../src/notifications/appsync.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAA8C;AAC9C,gFAAmE;AACnE,wDAAmD;AACnD,2CAAmD;AACnD,2CAA8C;AAC9C,4DAA4C;AAI5C,MAAM,KAAK,GAAG,aAAa,CAAC;;;;;;;;;;;;CAY3B,CAAA;AAGM,IAAM,cAAc,sBAApB,MAAM,cAAc;IASzB,YAA6B,MAAqB;QAArB,WAAM,GAAN,MAAM,CAAe;QARjC,WAAM,GAAG,IAAI,eA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I,CAAC,QAAQ;gBACvB,IAAI,EAAE,UAAU;gBAChB,IAAI;gBACJ,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,OAAO,EAAE,SAAS;aACnB,CAAA;YACD,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE;gBACpD,WAAW,EAAE,IAAI,IAAI,EAAE;aACxB,CAAC,CAAA;YACF,GAAG,GAAG,MAAM,IAAA,oBAAK,EAAC,IAAI,CAAC,QAAQ,EAAE;gBAC/B,MAAM,EAAE,aAAa,CAAC,MAAM;gBAC5B,OAAO,EAAE,aAAa,CAAC,OAAO;gBAC9B,IAAI,EAAE,aAAa,CAAC,IAAI;aACzB,CAAC,CAAA;QACJ,CAAC;QACD,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAA;QAC7B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,sCAAsC,EAAE,IAAI,CAAC,CAAA;QAE/D,OAAO,IAAI,CAAA;IACb,CAAC;CACF,CAAA;AAnEY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,mBAAU,GAAE;qCAU0B,sBAAa;GATvC,cAAc,CAmE1B"}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { ConfigService } from '@nestjs/config';
|
|
2
1
|
import { IEventHandler } from '../../interfaces';
|
|
3
2
|
import { AppSyncService } from '../appsync.service';
|
|
4
3
|
import { NotificationEvent } from './notification.event';
|
|
5
4
|
export declare class NotificationEventHandler implements IEventHandler<NotificationEvent> {
|
|
6
5
|
private readonly appSyncService;
|
|
7
|
-
private readonly config;
|
|
8
6
|
private readonly logger;
|
|
9
|
-
constructor(appSyncService: AppSyncService
|
|
7
|
+
constructor(appSyncService: AppSyncService);
|
|
10
8
|
execute(event: NotificationEvent): Promise<any>;
|
|
11
9
|
}
|
|
@@ -12,31 +12,24 @@ var NotificationEventHandler_1;
|
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
exports.NotificationEventHandler = void 0;
|
|
14
14
|
const common_1 = require("@nestjs/common");
|
|
15
|
-
const config_1 = require("@nestjs/config");
|
|
16
15
|
const decorators_1 = require("../../decorators");
|
|
17
16
|
const appsync_service_1 = require("../appsync.service");
|
|
18
17
|
const notification_event_1 = require("./notification.event");
|
|
19
18
|
let NotificationEventHandler = NotificationEventHandler_1 = class NotificationEventHandler {
|
|
20
|
-
constructor(appSyncService
|
|
19
|
+
constructor(appSyncService) {
|
|
21
20
|
this.appSyncService = appSyncService;
|
|
22
|
-
this.config = config;
|
|
23
21
|
this.logger = new common_1.Logger(NotificationEventHandler_1.name);
|
|
24
22
|
}
|
|
25
23
|
async execute(event) {
|
|
26
24
|
this.logger.debug('notification event executing:: ', event);
|
|
27
25
|
//send to appsync
|
|
28
26
|
const body = JSON.parse(event.body);
|
|
29
|
-
const secondAppsyncEndpoint = this.config.get('APPSYNC_SECOND_ENDPOINT');
|
|
30
|
-
if (secondAppsyncEndpoint) {
|
|
31
|
-
await this.appSyncService.sendMessage(body, 'second');
|
|
32
|
-
}
|
|
33
27
|
return await this.appSyncService.sendMessage(body);
|
|
34
28
|
}
|
|
35
29
|
};
|
|
36
30
|
exports.NotificationEventHandler = NotificationEventHandler;
|
|
37
31
|
exports.NotificationEventHandler = NotificationEventHandler = NotificationEventHandler_1 = __decorate([
|
|
38
32
|
(0, decorators_1.EventHandler)(notification_event_1.NotificationEvent),
|
|
39
|
-
__metadata("design:paramtypes", [appsync_service_1.AppSyncService
|
|
40
|
-
config_1.ConfigService])
|
|
33
|
+
__metadata("design:paramtypes", [appsync_service_1.AppSyncService])
|
|
41
34
|
], NotificationEventHandler);
|
|
42
35
|
//# sourceMappingURL=notification.event.handler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notification.event.handler.js","sourceRoot":"","sources":["../../../src/notifications/event/notification.event.handler.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAuC;
|
|
1
|
+
{"version":3,"file":"notification.event.handler.js","sourceRoot":"","sources":["../../../src/notifications/event/notification.event.handler.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAuC;AAEvC,iDAA+C;AAE/C,wDAAmD;AACnD,6DAAwD;AAGjD,IAAM,wBAAwB,gCAA9B,MAAM,wBAAwB;IAKnC,YAA6B,cAA8B;QAA9B,mBAAc,GAAd,cAAc,CAAgB;QAF1C,WAAM,GAAG,IAAI,eAAM,CAAC,0BAAwB,CAAC,IAAI,CAAC,CAAA;IAEL,CAAC;IAE/D,KAAK,CAAC,OAAO,CAAC,KAAwB;QACpC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,iCAAiC,EAAE,KAAK,CAAC,CAAA;QAC3D,iBAAiB;QACjB,MAAM,IAAI,GAAkB,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QAClD,OAAO,MAAM,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,IAAI,CAAC,CAAA;IACpD,CAAC;CACF,CAAA;AAbY,4DAAwB;mCAAxB,wBAAwB;IADpC,IAAA,yBAAY,EAAC,sCAAiB,CAAC;qCAMe,gCAAc;GALhD,wBAAwB,CAapC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mbc-cqrs-serverless/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.66-beta.0",
|
|
4
4
|
"description": "CQRS and event base core",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mbc",
|
|
@@ -86,5 +86,5 @@
|
|
|
86
86
|
"serverless-step-functions-local": "^0.5.1",
|
|
87
87
|
"supertest": "^7.0.0"
|
|
88
88
|
},
|
|
89
|
-
"gitHead": "
|
|
89
|
+
"gitHead": "484c4c604991e50742ba5fd2d8d82d1bc89bfbf3"
|
|
90
90
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"appsync-endpoint.interface.js","sourceRoot":"","sources":["../../src/interfaces/appsync-endpoint.interface.ts"],"names":[],"mappings":""}
|