@open-rlb/nestjs-amqp 1.0.27 → 2.0.1
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 +572 -169
- package/amqp-lib/amqp/connection.d.ts +1 -1
- package/common/errors.d.ts +13 -0
- package/common/errors.js +26 -0
- package/common/errors.js.map +1 -0
- package/common/flatten.util.d.ts +1 -0
- package/common/flatten.util.js +29 -0
- package/common/flatten.util.js.map +1 -0
- package/common/index.d.ts +3 -0
- package/common/index.js +20 -0
- package/common/index.js.map +1 -0
- package/common/pagination.model.d.ts +6 -0
- package/common/pagination.model.js +3 -0
- package/common/pagination.model.js.map +1 -0
- package/index.d.ts +3 -0
- package/index.js +3 -0
- package/index.js.map +1 -1
- package/modules/acl/acl.module.d.ts +5 -0
- package/modules/acl/acl.module.js +36 -0
- package/modules/acl/acl.module.js.map +1 -0
- package/modules/acl/cache/acl-cache.service.d.ts +15 -0
- package/modules/acl/cache/acl-cache.service.js +98 -0
- package/modules/acl/cache/acl-cache.service.js.map +1 -0
- package/modules/acl/cache/cache-store.d.ts +6 -0
- package/modules/acl/cache/cache-store.js +3 -0
- package/modules/acl/cache/cache-store.js.map +1 -0
- package/modules/acl/config/acl.config.d.ts +8 -0
- package/modules/acl/config/acl.config.js +3 -0
- package/modules/acl/config/acl.config.js.map +1 -0
- package/modules/acl/const.d.ts +17 -0
- package/modules/acl/const.js +21 -0
- package/modules/acl/const.js.map +1 -0
- package/modules/acl/index.d.ts +11 -0
- package/modules/acl/index.js +28 -0
- package/modules/acl/index.js.map +1 -0
- package/modules/acl/models.d.ts +19 -0
- package/modules/acl/models.js +3 -0
- package/modules/acl/models.js.map +1 -0
- package/modules/acl/repository/acl-action.repository.d.ts +11 -0
- package/modules/acl/repository/acl-action.repository.js +7 -0
- package/modules/acl/repository/acl-action.repository.js.map +1 -0
- package/modules/acl/repository/acl-grant.repository.d.ts +11 -0
- package/modules/acl/repository/acl-grant.repository.js +7 -0
- package/modules/acl/repository/acl-grant.repository.js.map +1 -0
- package/modules/acl/repository/acl-role.repository.d.ts +10 -0
- package/modules/acl/repository/acl-role.repository.js +7 -0
- package/modules/acl/repository/acl-role.repository.js.map +1 -0
- package/modules/acl/services/acl-management.service.d.ts +26 -0
- package/modules/acl/services/acl-management.service.js +202 -0
- package/modules/acl/services/acl-management.service.js.map +1 -0
- package/modules/acl/services/acl.service.d.ts +11 -0
- package/modules/acl/services/acl.service.js +63 -0
- package/modules/acl/services/acl.service.js.map +1 -0
- package/modules/broker/broker.module.d.ts +1 -7
- package/modules/broker/broker.module.js +1 -27
- package/modules/broker/broker.module.js.map +1 -1
- package/modules/broker/services/broker.service.js +2 -2
- package/modules/broker/services/broker.service.js.map +1 -1
- package/modules/gateway-admin/config/gateway-admin.config.d.ts +3 -0
- package/modules/gateway-admin/config/gateway-admin.config.js +3 -0
- package/modules/gateway-admin/config/gateway-admin.config.js.map +1 -0
- package/modules/gateway-admin/const.d.ts +18 -0
- package/modules/gateway-admin/const.js +22 -0
- package/modules/gateway-admin/const.js.map +1 -0
- package/modules/gateway-admin/gateway-admin.module.d.ts +5 -0
- package/modules/gateway-admin/gateway-admin.module.js +35 -0
- package/modules/gateway-admin/gateway-admin.module.js.map +1 -0
- package/modules/gateway-admin/index.d.ts +11 -0
- package/modules/gateway-admin/index.js +28 -0
- package/modules/gateway-admin/index.js.map +1 -0
- package/modules/gateway-admin/models.d.ts +22 -0
- package/modules/gateway-admin/models.js +3 -0
- package/modules/gateway-admin/models.js.map +1 -0
- package/modules/gateway-admin/repository/auth-provider.repository.d.ts +15 -0
- package/modules/gateway-admin/repository/auth-provider.repository.js +7 -0
- package/modules/gateway-admin/repository/auth-provider.repository.js.map +1 -0
- package/modules/gateway-admin/repository/http-metric.repository.d.ts +7 -0
- package/modules/gateway-admin/repository/http-metric.repository.js +7 -0
- package/modules/gateway-admin/repository/http-metric.repository.js.map +1 -0
- package/modules/gateway-admin/repository/http-path.repository.d.ts +15 -0
- package/modules/gateway-admin/repository/http-path.repository.js +7 -0
- package/modules/gateway-admin/repository/http-path.repository.js.map +1 -0
- package/modules/gateway-admin/services/gateway-auth.service.d.ts +14 -0
- package/modules/gateway-admin/services/gateway-auth.service.js +100 -0
- package/modules/gateway-admin/services/gateway-auth.service.js.map +1 -0
- package/modules/gateway-admin/services/gateway-metrics.service.d.ts +11 -0
- package/modules/gateway-admin/services/gateway-metrics.service.js +59 -0
- package/modules/gateway-admin/services/gateway-metrics.service.js.map +1 -0
- package/modules/gateway-admin/services/gateway-path.service.d.ts +14 -0
- package/modules/gateway-admin/services/gateway-path.service.js +106 -0
- package/modules/gateway-admin/services/gateway-path.service.js.map +1 -0
- package/modules/gateway-admin/util/path-order.d.ts +3 -0
- package/modules/gateway-admin/util/path-order.js +36 -0
- package/modules/gateway-admin/util/path-order.js.map +1 -0
- package/modules/proxy/config/path-definition.config.d.ts +14 -1
- package/modules/proxy/proxy.module.d.ts +15 -2
- package/modules/proxy/proxy.module.js +24 -4
- package/modules/proxy/proxy.module.js.map +1 -1
- package/modules/proxy/services/http-auth-handler.service.d.ts +6 -0
- package/modules/proxy/services/http-auth-handler.service.js +48 -24
- package/modules/proxy/services/http-auth-handler.service.js.map +1 -1
- package/modules/proxy/services/http-handler.service.d.ts +5 -1
- package/modules/proxy/services/http-handler.service.js +79 -10
- package/modules/proxy/services/http-handler.service.js.map +1 -1
- package/modules/proxy/services/jwt.service.d.ts +3 -0
- package/modules/proxy/services/jwt.service.js +66 -9
- package/modules/proxy/services/jwt.service.js.map +1 -1
- package/modules/proxy/services/websocket.service.d.ts +33 -6
- package/modules/proxy/services/websocket.service.js +250 -82
- package/modules/proxy/services/websocket.service.js.map +1 -1
- package/package.json +29 -28
- package/schematics/nest-add/files/skills/rlb-amqp/SKILL.md +59 -0
- package/schematics/nest-add/files/skills/rlb-amqp/references/config-schema.md +214 -0
- package/schematics/nest-add/files/skills/rlb-amqp/references/gotchas.md +95 -0
- package/schematics/nest-add/files/skills/rlb-amqp-add-action/SKILL.md +102 -0
- package/schematics/nest-add/files/skills/rlb-amqp-add-route/SKILL.md +61 -0
- package/schematics/nest-add/files/skills/rlb-amqp-add-ws-event/SKILL.md +93 -0
- package/schematics/nest-add/files/skills/rlb-amqp-scaffold/SKILL.md +160 -0
- package/schematics/nest-add/index.js +82 -49
- package/schematics/nest-add/index.js.map +1 -1
- package/schematics/nest-add/index.ts +113 -68
- package/schematics/nest-add/init.schema.d.ts +2 -0
- package/schematics/nest-add/init.schema.ts +11 -1
- package/schematics/nest-add/schema.json +25 -12
- package/tsconfig.build.tsbuildinfo +0 -1
|
@@ -0,0 +1,28 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./config/gateway-admin.config"), exports);
|
|
18
|
+
__exportStar(require("./const"), exports);
|
|
19
|
+
__exportStar(require("./gateway-admin.module"), exports);
|
|
20
|
+
__exportStar(require("./models"), exports);
|
|
21
|
+
__exportStar(require("./repository/auth-provider.repository"), exports);
|
|
22
|
+
__exportStar(require("./repository/http-metric.repository"), exports);
|
|
23
|
+
__exportStar(require("./repository/http-path.repository"), exports);
|
|
24
|
+
__exportStar(require("./services/gateway-auth.service"), exports);
|
|
25
|
+
__exportStar(require("./services/gateway-metrics.service"), exports);
|
|
26
|
+
__exportStar(require("./services/gateway-path.service"), exports);
|
|
27
|
+
__exportStar(require("./util/path-order"), exports);
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../libs/rlb-nestjs-amqp/src/modules/gateway-admin/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gEAA8C;AAC9C,0CAAwB;AACxB,yDAAuC;AACvC,2CAAyB;AACzB,wEAAsD;AACtD,sEAAoD;AACpD,oEAAkD;AAClD,kEAAgD;AAChD,qEAAmD;AACnD,kEAAgD;AAChD,oDAAkC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface HttpMetric<Id = string> {
|
|
2
|
+
_id?: Id;
|
|
3
|
+
method: string;
|
|
4
|
+
route: string;
|
|
5
|
+
name?: string;
|
|
6
|
+
topic?: string;
|
|
7
|
+
action?: string;
|
|
8
|
+
count: number;
|
|
9
|
+
errorCount: number;
|
|
10
|
+
lastStatus?: number;
|
|
11
|
+
lastCalledAt?: number;
|
|
12
|
+
totalDurationMs: number;
|
|
13
|
+
}
|
|
14
|
+
export interface TrackCallInput {
|
|
15
|
+
method: string;
|
|
16
|
+
route: string;
|
|
17
|
+
name?: string;
|
|
18
|
+
topic?: string;
|
|
19
|
+
action?: string;
|
|
20
|
+
status?: number;
|
|
21
|
+
durationMs?: number;
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"models.js","sourceRoot":"","sources":["../../../libs/rlb-nestjs-amqp/src/modules/gateway-admin/models.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { PaginationModel } from '../../../common';
|
|
2
|
+
import { HandlerAuthConfig } from '../../broker/config/handler-auth.config';
|
|
3
|
+
export type StoredAuthProvider = Partial<HandlerAuthConfig> & {
|
|
4
|
+
_id?: string;
|
|
5
|
+
enabled?: boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare abstract class AuthProviderRepository {
|
|
8
|
+
abstract insert(model: StoredAuthProvider): Promise<StoredAuthProvider>;
|
|
9
|
+
abstract findById(id: string): Promise<StoredAuthProvider>;
|
|
10
|
+
abstract findOne(filter: Record<string, any>): Promise<StoredAuthProvider>;
|
|
11
|
+
abstract updateById(id: string, model: StoredAuthProvider): Promise<StoredAuthProvider>;
|
|
12
|
+
abstract removeById(id: string): Promise<StoredAuthProvider>;
|
|
13
|
+
abstract listEnabled(): Promise<HandlerAuthConfig[]>;
|
|
14
|
+
abstract filterPaginated(filter: Record<string, any>, page?: number, limit?: number): Promise<PaginationModel<StoredAuthProvider>>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AuthProviderRepository = void 0;
|
|
4
|
+
class AuthProviderRepository {
|
|
5
|
+
}
|
|
6
|
+
exports.AuthProviderRepository = AuthProviderRepository;
|
|
7
|
+
//# sourceMappingURL=auth-provider.repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-provider.repository.js","sourceRoot":"","sources":["../../../../libs/rlb-nestjs-amqp/src/modules/gateway-admin/repository/auth-provider.repository.ts"],"names":[],"mappings":";;;AAMA,MAAsB,sBAAsB;CAS3C;AATD,wDASC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-metric.repository.js","sourceRoot":"","sources":["../../../../libs/rlb-nestjs-amqp/src/modules/gateway-admin/repository/http-metric.repository.ts"],"names":[],"mappings":";;;AAGA,MAAsB,oBAAoB;CAKzC;AALD,oDAKC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { PaginationModel } from '../../../common';
|
|
2
|
+
import { PathDefinition } from '../../proxy/config/path-definition.config';
|
|
3
|
+
export type StoredHttpPath = Partial<PathDefinition> & {
|
|
4
|
+
_id?: string;
|
|
5
|
+
enabled?: boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare abstract class HttpPathRepository {
|
|
8
|
+
abstract insert(model: StoredHttpPath): Promise<StoredHttpPath>;
|
|
9
|
+
abstract findById(id: string): Promise<StoredHttpPath>;
|
|
10
|
+
abstract findOne(filter: Record<string, any>): Promise<StoredHttpPath>;
|
|
11
|
+
abstract updateById(id: string, model: StoredHttpPath): Promise<StoredHttpPath>;
|
|
12
|
+
abstract removeById(id: string): Promise<StoredHttpPath>;
|
|
13
|
+
abstract listEnabled(): Promise<PathDefinition[]>;
|
|
14
|
+
abstract filterPaginated(filter: Record<string, any>, page?: number, limit?: number): Promise<PaginationModel<StoredHttpPath>>;
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-path.repository.js","sourceRoot":"","sources":["../../../../libs/rlb-nestjs-amqp/src/modules/gateway-admin/repository/http-path.repository.ts"],"names":[],"mappings":";;;AAMA,MAAsB,kBAAkB;CASvC;AATD,gDASC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { PaginationModel } from '../../../common';
|
|
2
|
+
import { HandlerAuthConfig } from '../../broker/config/handler-auth.config';
|
|
3
|
+
import { AuthProviderRepository, StoredAuthProvider } from '../repository/auth-provider.repository';
|
|
4
|
+
export declare class GatewayAuthService {
|
|
5
|
+
private readonly repo;
|
|
6
|
+
private readonly logger;
|
|
7
|
+
constructor(repo: AuthProviderRepository);
|
|
8
|
+
create(model: StoredAuthProvider): Promise<StoredAuthProvider>;
|
|
9
|
+
update(id: string, model: StoredAuthProvider): Promise<StoredAuthProvider>;
|
|
10
|
+
remove(id: string): Promise<StoredAuthProvider>;
|
|
11
|
+
get(id: string): Promise<StoredAuthProvider>;
|
|
12
|
+
list(page?: number, limit?: number): Promise<PaginationModel<StoredAuthProvider>>;
|
|
13
|
+
export(): Promise<HandlerAuthConfig[]>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
var GatewayAuthService_1;
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.GatewayAuthService = void 0;
|
|
17
|
+
const common_1 = require("@nestjs/common");
|
|
18
|
+
const common_2 = require("../../../common");
|
|
19
|
+
const broker_1 = require("../../broker");
|
|
20
|
+
const const_1 = require("../const");
|
|
21
|
+
const auth_provider_repository_1 = require("../repository/auth-provider.repository");
|
|
22
|
+
let GatewayAuthService = GatewayAuthService_1 = class GatewayAuthService {
|
|
23
|
+
constructor(repo) {
|
|
24
|
+
this.repo = repo;
|
|
25
|
+
this.logger = new common_1.Logger(GatewayAuthService_1.name);
|
|
26
|
+
}
|
|
27
|
+
async create(model) {
|
|
28
|
+
if (!model?.name)
|
|
29
|
+
throw new common_2.BadRequestError('name is required');
|
|
30
|
+
if (!model?.type)
|
|
31
|
+
throw new common_2.BadRequestError('type is required');
|
|
32
|
+
return this.repo.insert(model);
|
|
33
|
+
}
|
|
34
|
+
async update(id, model) {
|
|
35
|
+
if (!id)
|
|
36
|
+
throw new common_2.BadRequestError('id is required');
|
|
37
|
+
return this.repo.updateById(id, model);
|
|
38
|
+
}
|
|
39
|
+
async remove(id) {
|
|
40
|
+
return this.repo.removeById(id);
|
|
41
|
+
}
|
|
42
|
+
async get(id) {
|
|
43
|
+
return this.repo.findById(id);
|
|
44
|
+
}
|
|
45
|
+
async list(page, limit) {
|
|
46
|
+
return this.repo.filterPaginated({}, Number(page) || 1, Number(limit) || 10);
|
|
47
|
+
}
|
|
48
|
+
async export() {
|
|
49
|
+
return this.repo.listEnabled();
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
exports.GatewayAuthService = GatewayAuthService;
|
|
53
|
+
__decorate([
|
|
54
|
+
(0, broker_1.BrokerAction)(const_1.GATEWAY_ADMIN_TOPIC, const_1.GW_ADMIN_ACTIONS.authCreate, 'rpc'),
|
|
55
|
+
__param(0, (0, broker_1.BrokerParam)('body-full')),
|
|
56
|
+
__metadata("design:type", Function),
|
|
57
|
+
__metadata("design:paramtypes", [Object]),
|
|
58
|
+
__metadata("design:returntype", Promise)
|
|
59
|
+
], GatewayAuthService.prototype, "create", null);
|
|
60
|
+
__decorate([
|
|
61
|
+
(0, broker_1.BrokerAction)(const_1.GATEWAY_ADMIN_TOPIC, const_1.GW_ADMIN_ACTIONS.authUpdate, 'rpc'),
|
|
62
|
+
__param(0, (0, broker_1.BrokerParam)('body', 'id')),
|
|
63
|
+
__param(1, (0, broker_1.BrokerParam)('body-full')),
|
|
64
|
+
__metadata("design:type", Function),
|
|
65
|
+
__metadata("design:paramtypes", [String, Object]),
|
|
66
|
+
__metadata("design:returntype", Promise)
|
|
67
|
+
], GatewayAuthService.prototype, "update", null);
|
|
68
|
+
__decorate([
|
|
69
|
+
(0, broker_1.BrokerAction)(const_1.GATEWAY_ADMIN_TOPIC, const_1.GW_ADMIN_ACTIONS.authDelete, 'rpc'),
|
|
70
|
+
__param(0, (0, broker_1.BrokerParam)('body', 'id')),
|
|
71
|
+
__metadata("design:type", Function),
|
|
72
|
+
__metadata("design:paramtypes", [String]),
|
|
73
|
+
__metadata("design:returntype", Promise)
|
|
74
|
+
], GatewayAuthService.prototype, "remove", null);
|
|
75
|
+
__decorate([
|
|
76
|
+
(0, broker_1.BrokerAction)(const_1.GATEWAY_ADMIN_TOPIC, const_1.GW_ADMIN_ACTIONS.authGet, 'rpc'),
|
|
77
|
+
__param(0, (0, broker_1.BrokerParam)('body', 'id')),
|
|
78
|
+
__metadata("design:type", Function),
|
|
79
|
+
__metadata("design:paramtypes", [String]),
|
|
80
|
+
__metadata("design:returntype", Promise)
|
|
81
|
+
], GatewayAuthService.prototype, "get", null);
|
|
82
|
+
__decorate([
|
|
83
|
+
(0, broker_1.BrokerAction)(const_1.GATEWAY_ADMIN_TOPIC, const_1.GW_ADMIN_ACTIONS.authList, 'rpc'),
|
|
84
|
+
__param(0, (0, broker_1.BrokerParam)('body', 'page')),
|
|
85
|
+
__param(1, (0, broker_1.BrokerParam)('body', 'limit')),
|
|
86
|
+
__metadata("design:type", Function),
|
|
87
|
+
__metadata("design:paramtypes", [Number, Number]),
|
|
88
|
+
__metadata("design:returntype", Promise)
|
|
89
|
+
], GatewayAuthService.prototype, "list", null);
|
|
90
|
+
__decorate([
|
|
91
|
+
(0, broker_1.BrokerAction)(const_1.GATEWAY_ADMIN_TOPIC, const_1.GW_ADMIN_ACTIONS.authExport, 'rpc'),
|
|
92
|
+
__metadata("design:type", Function),
|
|
93
|
+
__metadata("design:paramtypes", []),
|
|
94
|
+
__metadata("design:returntype", Promise)
|
|
95
|
+
], GatewayAuthService.prototype, "export", null);
|
|
96
|
+
exports.GatewayAuthService = GatewayAuthService = GatewayAuthService_1 = __decorate([
|
|
97
|
+
(0, common_1.Injectable)(),
|
|
98
|
+
__metadata("design:paramtypes", [auth_provider_repository_1.AuthProviderRepository])
|
|
99
|
+
], GatewayAuthService);
|
|
100
|
+
//# sourceMappingURL=gateway-auth.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gateway-auth.service.js","sourceRoot":"","sources":["../../../../libs/rlb-nestjs-amqp/src/modules/gateway-admin/services/gateway-auth.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAoD;AACpD,4CAAmE;AAEnE,yCAAyD;AACzD,oCAAiE;AACjE,qFAAoG;AAG7F,IAAM,kBAAkB,0BAAxB,MAAM,kBAAkB;IAG7B,YAA6B,IAA4B;QAA5B,SAAI,GAAJ,IAAI,CAAwB;QAFxC,WAAM,GAAG,IAAI,eAAM,CAAC,oBAAkB,CAAC,IAAI,CAAC,CAAC;IAED,CAAC;IAGxD,AAAN,KAAK,CAAC,MAAM,CAA2B,KAAyB;QAC9D,IAAI,CAAC,KAAK,EAAE,IAAI;YAAE,MAAM,IAAI,wBAAe,CAAC,kBAAkB,CAAC,CAAC;QAChE,IAAI,CAAC,KAAK,EAAE,IAAI;YAAE,MAAM,IAAI,wBAAe,CAAC,kBAAkB,CAAC,CAAC;QAChE,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC;IAGK,AAAN,KAAK,CAAC,MAAM,CAA4B,EAAU,EAA4B,KAAyB;QACrG,IAAI,CAAC,EAAE;YAAE,MAAM,IAAI,wBAAe,CAAC,gBAAgB,CAAC,CAAC;QACrD,OAAO,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;IACzC,CAAC;IAGK,AAAN,KAAK,CAAC,MAAM,CAA4B,EAAU;QAChD,OAAO,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;IAClC,CAAC;IAGK,AAAN,KAAK,CAAC,GAAG,CAA4B,EAAU;QAC7C,OAAO,IAAI,CAAC,IAAI,CAAC,Q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EAAE,OAAO,CAAC,CAAA;;;;8CAEnF;AAIK;IADL,IAAA,qBAAY,EAAC,2BAAmB,EAAE,wBAAgB,CAAC,UAAU,EAAE,KAAK,CAAC;;;;gDAGrE;6BArCU,kBAAkB;IAD9B,IAAA,mBAAU,GAAE;qCAIwB,iDAAsB;GAH9C,kBAAkB,CAsC9B"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { HttpMetric, TrackCallInput } from '../models';
|
|
2
|
+
import { HttpMetricRepository } from '../repository/http-metric.repository';
|
|
3
|
+
export declare class GatewayMetricsService {
|
|
4
|
+
private readonly repo;
|
|
5
|
+
private readonly logger;
|
|
6
|
+
constructor(repo: HttpMetricRepository);
|
|
7
|
+
track(input: TrackCallInput): Promise<void>;
|
|
8
|
+
get(route?: string): Promise<(HttpMetric & {
|
|
9
|
+
avgDurationMs: number;
|
|
10
|
+
})[]>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
var GatewayMetricsService_1;
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.GatewayMetricsService = void 0;
|
|
17
|
+
const common_1 = require("@nestjs/common");
|
|
18
|
+
const broker_1 = require("../../broker");
|
|
19
|
+
const const_1 = require("../const");
|
|
20
|
+
const http_metric_repository_1 = require("../repository/http-metric.repository");
|
|
21
|
+
let GatewayMetricsService = GatewayMetricsService_1 = class GatewayMetricsService {
|
|
22
|
+
constructor(repo) {
|
|
23
|
+
this.repo = repo;
|
|
24
|
+
this.logger = new common_1.Logger(GatewayMetricsService_1.name);
|
|
25
|
+
}
|
|
26
|
+
async track(input) {
|
|
27
|
+
try {
|
|
28
|
+
if (!input?.method || !input?.route)
|
|
29
|
+
return;
|
|
30
|
+
await this.repo.increment(input);
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
this.logger.error(error);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
async get(route) {
|
|
37
|
+
return this.repo.list(route);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
exports.GatewayMetricsService = GatewayMetricsService;
|
|
41
|
+
__decorate([
|
|
42
|
+
(0, broker_1.BrokerAction)(const_1.GATEWAY_ADMIN_TOPIC, const_1.GW_ADMIN_ACTIONS.metricsTrack, 'event'),
|
|
43
|
+
__param(0, (0, broker_1.BrokerParam)('body-full')),
|
|
44
|
+
__metadata("design:type", Function),
|
|
45
|
+
__metadata("design:paramtypes", [Object]),
|
|
46
|
+
__metadata("design:returntype", Promise)
|
|
47
|
+
], GatewayMetricsService.prototype, "track", null);
|
|
48
|
+
__decorate([
|
|
49
|
+
(0, broker_1.BrokerAction)(const_1.GATEWAY_ADMIN_TOPIC, const_1.GW_ADMIN_ACTIONS.metricsGet, 'rpc'),
|
|
50
|
+
__param(0, (0, broker_1.BrokerParam)('body', 'route')),
|
|
51
|
+
__metadata("design:type", Function),
|
|
52
|
+
__metadata("design:paramtypes", [String]),
|
|
53
|
+
__metadata("design:returntype", Promise)
|
|
54
|
+
], GatewayMetricsService.prototype, "get", null);
|
|
55
|
+
exports.GatewayMetricsService = GatewayMetricsService = GatewayMetricsService_1 = __decorate([
|
|
56
|
+
(0, common_1.Injectable)(),
|
|
57
|
+
__metadata("design:paramtypes", [http_metric_repository_1.HttpMetricRepository])
|
|
58
|
+
], GatewayMetricsService);
|
|
59
|
+
//# sourceMappingURL=gateway-metrics.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gateway-metrics.service.js","sourceRoot":"","sources":["../../../../libs/rlb-nestjs-amqp/src/modules/gateway-admin/services/gateway-metrics.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAoD;AACpD,yCAAyD;AACzD,oCAAiE;AAEjE,iFAA4E;AAGrE,IAAM,qBAAqB,6BAA3B,MAAM,qBAAqB;IAGhC,YAA6B,IAA0B;QAA1B,SAAI,GAAJ,IAAI,CAAsB;QAFtC,WAAM,GAAG,IAAI,eAAM,CAAC,uBAAqB,CAAC,IAAI,CAAC,CAAC;IAEN,CAAC;IAItD,AAAN,KAAK,CAAC,KAAK,CAA2B,KAAqB;QACzD,IAAI,CAAC;YACH,IAAI,CAAC,KAAK,EAAE,MAAM,IAAI,CAAC,KAAK,EAAE,KAAK;gBAAE,OAAO;YAC5C,MAAM,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACnC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC;IAIK,AAAN,KAAK,CAAC,GAAG,CAA+B,KAAc;QACpD,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;CACF,CAAA;AArBY,sDAAqB;AAO1B;IADL,IAAA,qBAAY,EAAC,2BAAmB,EAAE,wBAAgB,CAAC,YAAY,EAAE,OAAO,CAAC;IAC7D,WAAA,IAAA,oBAAW,EAAC,WAAW,CAAC,CAAA;;;;kDAOpC;AAIK;IADL,IAAA,qBAAY,EAAC,2BAAmB,EAAE,wBAAgB,CAAC,UAAU,EAAE,KAAK,CAAC;IAC3D,WAAA,IAAA,oBAAW,EAAC,MAAM,EAAE,OAAO,CAAC,CAAA;;;;gDAEtC;gCApBU,qBAAqB;IADjC,IAAA,mBAAU,GAAE;qCAIwB,6CAAoB;GAH5C,qBAAqB,CAqBjC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { PaginationModel } from '../../../common';
|
|
2
|
+
import { PathDefinition } from '../../proxy/config/path-definition.config';
|
|
3
|
+
import { HttpPathRepository, StoredHttpPath } from '../repository/http-path.repository';
|
|
4
|
+
export declare class GatewayPathService {
|
|
5
|
+
private readonly repo;
|
|
6
|
+
private readonly logger;
|
|
7
|
+
constructor(repo: HttpPathRepository);
|
|
8
|
+
create(model: StoredHttpPath): Promise<StoredHttpPath>;
|
|
9
|
+
update(id: string, model: StoredHttpPath): Promise<StoredHttpPath>;
|
|
10
|
+
remove(id: string): Promise<StoredHttpPath>;
|
|
11
|
+
get(id: string): Promise<StoredHttpPath>;
|
|
12
|
+
list(page?: number, limit?: number): Promise<PaginationModel<StoredHttpPath>>;
|
|
13
|
+
export(): Promise<PathDefinition[]>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
var GatewayPathService_1;
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.GatewayPathService = void 0;
|
|
17
|
+
const common_1 = require("@nestjs/common");
|
|
18
|
+
const common_2 = require("../../../common");
|
|
19
|
+
const broker_1 = require("../../broker");
|
|
20
|
+
const const_1 = require("../const");
|
|
21
|
+
const http_path_repository_1 = require("../repository/http-path.repository");
|
|
22
|
+
const path_order_1 = require("../util/path-order");
|
|
23
|
+
let GatewayPathService = GatewayPathService_1 = class GatewayPathService {
|
|
24
|
+
constructor(repo) {
|
|
25
|
+
this.repo = repo;
|
|
26
|
+
this.logger = new common_1.Logger(GatewayPathService_1.name);
|
|
27
|
+
}
|
|
28
|
+
async create(model) {
|
|
29
|
+
if (!model?.name)
|
|
30
|
+
throw new common_2.BadRequestError('name is required');
|
|
31
|
+
if (!model?.method)
|
|
32
|
+
throw new common_2.BadRequestError('method is required');
|
|
33
|
+
if (!model?.path)
|
|
34
|
+
throw new common_2.BadRequestError('path is required');
|
|
35
|
+
if (!model?.topic)
|
|
36
|
+
throw new common_2.BadRequestError('topic is required');
|
|
37
|
+
return this.repo.insert(model);
|
|
38
|
+
}
|
|
39
|
+
async update(id, model) {
|
|
40
|
+
if (!id)
|
|
41
|
+
throw new common_2.BadRequestError('id is required');
|
|
42
|
+
return this.repo.updateById(id, model);
|
|
43
|
+
}
|
|
44
|
+
async remove(id) {
|
|
45
|
+
return this.repo.removeById(id);
|
|
46
|
+
}
|
|
47
|
+
async get(id) {
|
|
48
|
+
return this.repo.findById(id);
|
|
49
|
+
}
|
|
50
|
+
async list(page, limit) {
|
|
51
|
+
return this.repo.filterPaginated({}, Number(page) || 1, Number(limit) || 10);
|
|
52
|
+
}
|
|
53
|
+
async export() {
|
|
54
|
+
const paths = await this.repo.listEnabled();
|
|
55
|
+
return (0, path_order_1.orderPaths)(paths);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
exports.GatewayPathService = GatewayPathService;
|
|
59
|
+
__decorate([
|
|
60
|
+
(0, broker_1.BrokerAction)(const_1.GATEWAY_ADMIN_TOPIC, const_1.GW_ADMIN_ACTIONS.pathCreate, 'rpc'),
|
|
61
|
+
__param(0, (0, broker_1.BrokerParam)('body-full')),
|
|
62
|
+
__metadata("design:type", Function),
|
|
63
|
+
__metadata("design:paramtypes", [Object]),
|
|
64
|
+
__metadata("design:returntype", Promise)
|
|
65
|
+
], GatewayPathService.prototype, "create", null);
|
|
66
|
+
__decorate([
|
|
67
|
+
(0, broker_1.BrokerAction)(const_1.GATEWAY_ADMIN_TOPIC, const_1.GW_ADMIN_ACTIONS.pathUpdate, 'rpc'),
|
|
68
|
+
__param(0, (0, broker_1.BrokerParam)('body', 'id')),
|
|
69
|
+
__param(1, (0, broker_1.BrokerParam)('body-full')),
|
|
70
|
+
__metadata("design:type", Function),
|
|
71
|
+
__metadata("design:paramtypes", [String, Object]),
|
|
72
|
+
__metadata("design:returntype", Promise)
|
|
73
|
+
], GatewayPathService.prototype, "update", null);
|
|
74
|
+
__decorate([
|
|
75
|
+
(0, broker_1.BrokerAction)(const_1.GATEWAY_ADMIN_TOPIC, const_1.GW_ADMIN_ACTIONS.pathDelete, 'rpc'),
|
|
76
|
+
__param(0, (0, broker_1.BrokerParam)('body', 'id')),
|
|
77
|
+
__metadata("design:type", Function),
|
|
78
|
+
__metadata("design:paramtypes", [String]),
|
|
79
|
+
__metadata("design:returntype", Promise)
|
|
80
|
+
], GatewayPathService.prototype, "remove", null);
|
|
81
|
+
__decorate([
|
|
82
|
+
(0, broker_1.BrokerAction)(const_1.GATEWAY_ADMIN_TOPIC, const_1.GW_ADMIN_ACTIONS.pathGet, 'rpc'),
|
|
83
|
+
__param(0, (0, broker_1.BrokerParam)('body', 'id')),
|
|
84
|
+
__metadata("design:type", Function),
|
|
85
|
+
__metadata("design:paramtypes", [String]),
|
|
86
|
+
__metadata("design:returntype", Promise)
|
|
87
|
+
], GatewayPathService.prototype, "get", null);
|
|
88
|
+
__decorate([
|
|
89
|
+
(0, broker_1.BrokerAction)(const_1.GATEWAY_ADMIN_TOPIC, const_1.GW_ADMIN_ACTIONS.pathList, 'rpc'),
|
|
90
|
+
__param(0, (0, broker_1.BrokerParam)('body', 'page')),
|
|
91
|
+
__param(1, (0, broker_1.BrokerParam)('body', 'limit')),
|
|
92
|
+
__metadata("design:type", Function),
|
|
93
|
+
__metadata("design:paramtypes", [Number, Number]),
|
|
94
|
+
__metadata("design:returntype", Promise)
|
|
95
|
+
], GatewayPathService.prototype, "list", null);
|
|
96
|
+
__decorate([
|
|
97
|
+
(0, broker_1.BrokerAction)(const_1.GATEWAY_ADMIN_TOPIC, const_1.GW_ADMIN_ACTIONS.pathExport, 'rpc'),
|
|
98
|
+
__metadata("design:type", Function),
|
|
99
|
+
__metadata("design:paramtypes", []),
|
|
100
|
+
__metadata("design:returntype", Promise)
|
|
101
|
+
], GatewayPathService.prototype, "export", null);
|
|
102
|
+
exports.GatewayPathService = GatewayPathService = GatewayPathService_1 = __decorate([
|
|
103
|
+
(0, common_1.Injectable)(),
|
|
104
|
+
__metadata("design:paramtypes", [http_path_repository_1.HttpPathRepository])
|
|
105
|
+
], GatewayPathService);
|
|
106
|
+
//# sourceMappingURL=gateway-path.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gateway-path.service.js","sourceRoot":"","sources":["../../../../libs/rlb-nestjs-amqp/src/modules/gateway-admin/services/gateway-path.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAoD;AACpD,4CAAmE;AACnE,yCAAyD;AAEzD,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K;IADL,IAAA,qBAAY,EAAC,2BAAmB,EAAE,wBAAgB,CAAC,UAAU,EAAE,KAAK,CAAC;;;;gDAIrE;6BAxCU,kBAAkB;IAD9B,IAAA,mBAAU,GAAE;qCAIwB,yCAAkB;GAH1C,kBAAkB,CAyC9B"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.comparePaths = comparePaths;
|
|
4
|
+
exports.orderPaths = orderPaths;
|
|
5
|
+
function segmentKind(segment) {
|
|
6
|
+
if (segment.startsWith(':'))
|
|
7
|
+
return 1;
|
|
8
|
+
if (segment === '*' || segment.includes('*'))
|
|
9
|
+
return 2;
|
|
10
|
+
return 0;
|
|
11
|
+
}
|
|
12
|
+
function splitSegments(path) {
|
|
13
|
+
return (path || '').split('/').filter(Boolean);
|
|
14
|
+
}
|
|
15
|
+
function comparePaths(a, b) {
|
|
16
|
+
const sa = splitSegments(a);
|
|
17
|
+
const sb = splitSegments(b);
|
|
18
|
+
const len = Math.max(sa.length, sb.length);
|
|
19
|
+
for (let i = 0; i < len; i++) {
|
|
20
|
+
if (i >= sa.length)
|
|
21
|
+
return -1;
|
|
22
|
+
if (i >= sb.length)
|
|
23
|
+
return 1;
|
|
24
|
+
const ka = segmentKind(sa[i]);
|
|
25
|
+
const kb = segmentKind(sb[i]);
|
|
26
|
+
if (ka !== kb)
|
|
27
|
+
return ka - kb;
|
|
28
|
+
if (ka === 0 && sa[i] !== sb[i])
|
|
29
|
+
return sa[i] < sb[i] ? -1 : 1;
|
|
30
|
+
}
|
|
31
|
+
return 0;
|
|
32
|
+
}
|
|
33
|
+
function orderPaths(paths) {
|
|
34
|
+
return [...paths].sort((a, b) => comparePaths(a.path, b.path));
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=path-order.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path-order.js","sourceRoot":"","sources":["../../../../lib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AAC,KAAK,EAAE,CAAC,CAAC,CAAC;YAAE,OAAO,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACjE,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC;AAGD,SAAgB,UAAU,CAAyC,KAAU;IAC3E,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AACjE,CAAC"}
|
|
@@ -27,7 +27,10 @@ export interface WebSocketEvent {
|
|
|
27
27
|
routingKey: string;
|
|
28
28
|
name: string;
|
|
29
29
|
auth?: string;
|
|
30
|
-
|
|
30
|
+
requireAuth?: boolean;
|
|
31
|
+
roles?: string[];
|
|
32
|
+
scopeClaim?: string;
|
|
33
|
+
payloadKey?: string;
|
|
31
34
|
url?: string;
|
|
32
35
|
method?: string;
|
|
33
36
|
headers?: {
|
|
@@ -35,6 +38,13 @@ export interface WebSocketEvent {
|
|
|
35
38
|
};
|
|
36
39
|
timeout?: number;
|
|
37
40
|
}
|
|
41
|
+
export interface WebSocketGatewayOptions {
|
|
42
|
+
maxConnections?: number;
|
|
43
|
+
maxSubscriptionsPerClient?: number;
|
|
44
|
+
heartbeatIntervalMs?: number;
|
|
45
|
+
allowedOrigins?: string[];
|
|
46
|
+
maxMessageBytes?: number;
|
|
47
|
+
}
|
|
38
48
|
export interface GatewayConfigLoader {
|
|
39
49
|
paths?: GatewayConfigSource;
|
|
40
50
|
events?: GatewayConfigSource;
|
|
@@ -49,4 +59,7 @@ export interface GatewayConfig {
|
|
|
49
59
|
loadConfig?: GatewayConfigLoader;
|
|
50
60
|
paths: PathDefinition[];
|
|
51
61
|
events: WebSocketEvent[];
|
|
62
|
+
ws?: WebSocketGatewayOptions;
|
|
63
|
+
reloadTopic?: string;
|
|
64
|
+
metrics?: GatewayConfigSource;
|
|
52
65
|
}
|
|
@@ -1,4 +1,17 @@
|
|
|
1
|
-
import { DynamicModule, Provider } from '@nestjs/common';
|
|
1
|
+
import { DynamicModule, Provider, Type } from '@nestjs/common';
|
|
2
|
+
import { HandlerAuthConfig } from '../broker/config/handler-auth.config';
|
|
3
|
+
import { GatewayConfig } from './config/path-definition.config';
|
|
4
|
+
export interface ProxyModuleOptions {
|
|
5
|
+
authOptions?: HandlerAuthConfig[];
|
|
6
|
+
gatewayOptions?: GatewayConfig;
|
|
7
|
+
}
|
|
8
|
+
export interface ProxyModuleAsyncOptions {
|
|
9
|
+
imports?: Type<any>[];
|
|
10
|
+
inject?: Type<any>[];
|
|
11
|
+
useFactory: (...args: any[]) => Promise<ProxyModuleOptions> | ProxyModuleOptions;
|
|
12
|
+
providers?: Provider[];
|
|
13
|
+
}
|
|
2
14
|
export declare class ProxyModule {
|
|
3
|
-
static forRoot(providers
|
|
15
|
+
static forRoot(options?: ProxyModuleOptions, providers?: Provider[]): DynamicModule;
|
|
16
|
+
static forRootAsync(asyncOptions: ProxyModuleAsyncOptions): DynamicModule;
|
|
4
17
|
}
|
|
@@ -11,17 +11,37 @@ exports.ProxyModule = void 0;
|
|
|
11
11
|
const axios_1 = require("@nestjs/axios");
|
|
12
12
|
const common_1 = require("@nestjs/common");
|
|
13
13
|
const config_1 = require("@nestjs/config");
|
|
14
|
+
const const_1 = require("../broker/const");
|
|
14
15
|
const http_auth_handler_service_1 = require("./services/http-auth-handler.service");
|
|
15
16
|
const http_handler_service_1 = require("./services/http-handler.service");
|
|
16
17
|
const jwt_service_1 = require("./services/jwt.service");
|
|
17
18
|
const websocket_service_1 = require("./services/websocket.service");
|
|
18
19
|
let ProxyModule = ProxyModule_1 = class ProxyModule {
|
|
19
|
-
static forRoot(providers) {
|
|
20
|
+
static forRoot(options = {}, providers = []) {
|
|
21
|
+
const authOptionsProvider = { provide: const_1.RLB_AMQP_AUTH_OPTIONS, useValue: options.authOptions };
|
|
22
|
+
const gatewayOptionsProvider = { provide: const_1.RLB_AMQP_GATEWAY_OPTIONS, useValue: options.gatewayOptions };
|
|
20
23
|
return {
|
|
21
24
|
module: ProxyModule_1,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
providers: [authOptionsProvider, gatewayOptionsProvider, ...(providers || [])],
|
|
26
|
+
exports: [http_handler_service_1.HttpHandlerService, authOptionsProvider, gatewayOptionsProvider],
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
static forRootAsync(asyncOptions) {
|
|
30
|
+
const authOptionsProvider = {
|
|
31
|
+
provide: const_1.RLB_AMQP_AUTH_OPTIONS,
|
|
32
|
+
useFactory: async (...args) => (await asyncOptions.useFactory(...args)).authOptions,
|
|
33
|
+
inject: asyncOptions.inject || [],
|
|
34
|
+
};
|
|
35
|
+
const gatewayOptionsProvider = {
|
|
36
|
+
provide: const_1.RLB_AMQP_GATEWAY_OPTIONS,
|
|
37
|
+
useFactory: async (...args) => (await asyncOptions.useFactory(...args)).gatewayOptions,
|
|
38
|
+
inject: asyncOptions.inject || [],
|
|
39
|
+
};
|
|
40
|
+
return {
|
|
41
|
+
module: ProxyModule_1,
|
|
42
|
+
imports: asyncOptions.imports || [],
|
|
43
|
+
providers: [authOptionsProvider, gatewayOptionsProvider, ...(asyncOptions.providers || [])],
|
|
44
|
+
exports: [http_handler_service_1.HttpHandlerService, authOptionsProvider, gatewayOptionsProvider],
|
|
25
45
|
};
|
|
26
46
|
}
|
|
27
47
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxy.module.js","sourceRoot":"","sources":["../../../libs/rlb-nestjs-amqp/src/modules/proxy/proxy.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,yCAA2C;AAC3C,
|
|
1
|
+
{"version":3,"file":"proxy.module.js","sourceRoot":"","sources":["../../../libs/rlb-nestjs-amqp/src/modules/proxy/proxy.module.ts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