@alacard-project/shared 1.0.0 → 1.0.3
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/config/base-config.service.d.ts +25 -0
- package/dist/config/base-config.service.js +87 -0
- package/dist/config/base-config.service.js.map +1 -0
- package/dist/constants/auth-config.constants.d.ts +8 -0
- package/dist/constants/auth-config.constants.js +12 -0
- package/dist/constants/auth-config.constants.js.map +1 -0
- package/dist/constants/auth.constants.d.ts +31 -0
- package/dist/constants/auth.constants.js +35 -0
- package/dist/constants/auth.constants.js.map +1 -0
- package/dist/constants/common.constants.d.ts +8 -0
- package/dist/constants/common.constants.js +12 -0
- package/dist/constants/common.constants.js.map +1 -0
- package/dist/constants/env.constants.d.ts +21 -4
- package/dist/constants/env.constants.js +21 -4
- package/dist/constants/env.constants.js.map +1 -1
- package/dist/constants/error-messages.d.ts +1 -0
- package/dist/constants/error-messages.js +13 -0
- package/dist/constants/error-messages.js.map +1 -0
- package/dist/constants/grpc.constants.d.ts +26 -0
- package/dist/constants/grpc.constants.js +26 -0
- package/dist/constants/grpc.constants.js.map +1 -1
- package/dist/constants/index.d.ts +10 -2
- package/dist/constants/index.js +10 -2
- package/dist/constants/index.js.map +1 -1
- package/dist/constants/logging-messages.constants.d.ts +12 -0
- package/dist/constants/logging-messages.constants.js +16 -0
- package/dist/constants/logging-messages.constants.js.map +1 -0
- package/dist/constants/microservices.constants.d.ts +18 -0
- package/dist/constants/microservices.constants.js +22 -0
- package/dist/constants/microservices.constants.js.map +1 -0
- package/dist/constants/monitoring.constants.d.ts +51 -0
- package/dist/constants/monitoring.constants.js +55 -0
- package/dist/constants/monitoring.constants.js.map +1 -0
- package/dist/constants/routes.constants.d.ts +20 -0
- package/dist/constants/routes.constants.js +24 -0
- package/dist/constants/routes.constants.js.map +1 -0
- package/dist/constants/tokens.constants.d.ts +6 -0
- package/dist/constants/tokens.constants.js +10 -0
- package/dist/constants/tokens.constants.js.map +1 -0
- package/dist/contracts/auth.contract.d.ts +88 -0
- package/dist/contracts/auth.contract.js +3 -0
- package/dist/contracts/auth.contract.js.map +1 -0
- package/dist/contracts/index.d.ts +1 -0
- package/dist/contracts/index.js +1 -0
- package/dist/contracts/index.js.map +1 -1
- package/dist/decorators/scopes.decorator.d.ts +2 -0
- package/dist/decorators/scopes.decorator.js +8 -0
- package/dist/decorators/scopes.decorator.js.map +1 -0
- package/dist/dto/auth.dto.d.ts +41 -0
- package/dist/dto/auth.dto.js +53 -0
- package/dist/dto/auth.dto.js.map +1 -0
- package/dist/dto/index.d.ts +2 -0
- package/dist/dto/index.js +19 -0
- package/dist/dto/index.js.map +1 -0
- package/dist/dto/logging.dto.d.ts +29 -0
- package/dist/dto/logging.dto.js +146 -0
- package/dist/dto/logging.dto.js.map +1 -0
- package/dist/enums/{environment.enum.js → env.enum.js} +1 -1
- package/dist/enums/env.enum.js.map +1 -0
- package/dist/enums/error.enum.d.ts +19 -0
- package/dist/enums/error.enum.js +24 -0
- package/dist/enums/error.enum.js.map +1 -0
- package/dist/enums/events.enum.d.ts +20 -0
- package/dist/enums/events.enum.js +14 -0
- package/dist/enums/events.enum.js.map +1 -0
- package/dist/enums/health.enum.d.ts +7 -0
- package/dist/enums/health.enum.js +12 -0
- package/dist/enums/health.enum.js.map +1 -0
- package/dist/enums/index.d.ts +8 -5
- package/dist/enums/index.js +8 -5
- package/dist/enums/index.js.map +1 -1
- package/dist/enums/{log-level.enum.js → logging.enum.js} +1 -1
- package/dist/enums/logging.enum.js.map +1 -0
- package/dist/enums/{notification-type.enum.js → notification.enum.js} +1 -1
- package/dist/enums/notification.enum.js.map +1 -0
- package/dist/enums/permission.enum.d.ts +18 -0
- package/dist/enums/permission.enum.js +23 -0
- package/dist/enums/permission.enum.js.map +1 -0
- package/dist/enums/user.enum.d.ts +8 -0
- package/dist/enums/{user-role.enum.js → user.enum.js} +4 -2
- package/dist/enums/user.enum.js.map +1 -0
- package/dist/errors/app.error.d.ts +17 -0
- package/dist/errors/app.error.js +29 -0
- package/dist/errors/app.error.js.map +1 -0
- package/dist/errors/error-map.d.ts +7 -0
- package/dist/errors/error-map.js +92 -0
- package/dist/errors/error-map.js.map +1 -0
- package/dist/index.d.ts +10 -1
- package/dist/index.js +10 -1
- package/dist/index.js.map +1 -1
- package/dist/types/auth.types.d.ts +5 -0
- package/dist/types/config.types.d.ts +3 -2
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/monitoring.types.d.ts +60 -0
- package/dist/types/monitoring.types.js +3 -0
- package/dist/types/monitoring.types.js.map +1 -0
- package/dist/types/user.types.d.ts +10 -0
- package/dist/types/user.types.js +3 -0
- package/dist/types/user.types.js.map +1 -0
- package/dist/utils/app.utils.d.ts +8 -0
- package/dist/utils/app.utils.js +25 -0
- package/dist/utils/app.utils.js.map +1 -0
- package/dist/utils/health.utils.d.ts +8 -0
- package/dist/utils/health.utils.js +60 -0
- package/dist/utils/health.utils.js.map +1 -0
- package/dist/utils/logging-client.d.ts +7 -0
- package/dist/utils/logging-client.js +22 -0
- package/dist/utils/logging-client.js.map +1 -0
- package/dist/utils/prometheus.utils.d.ts +9 -0
- package/dist/utils/prometheus.utils.js +66 -0
- package/dist/utils/prometheus.utils.js.map +1 -0
- package/dist/utils/user.utils.d.ts +1 -0
- package/dist/utils/user.utils.js +7 -0
- package/dist/utils/user.utils.js.map +1 -0
- package/package.json +9 -8
- package/src/config/base-config.service.ts +101 -0
- package/src/constants/auth-config.constants.ts +9 -0
- package/src/constants/auth.constants.ts +34 -0
- package/src/constants/common.constants.ts +9 -0
- package/src/constants/env.constants.ts +21 -4
- package/src/constants/error-messages.ts +10 -0
- package/src/constants/grpc.constants.ts +26 -0
- package/src/constants/index.ts +10 -2
- package/src/constants/logging-messages.constants.ts +15 -0
- package/src/constants/microservices.constants.ts +18 -0
- package/src/constants/monitoring.constants.ts +71 -0
- package/src/constants/routes.constants.ts +21 -0
- package/src/constants/tokens.constants.ts +6 -0
- package/src/contracts/auth.contract.ts +98 -0
- package/src/contracts/index.ts +1 -0
- package/src/decorators/scopes.decorator.ts +4 -0
- package/src/dto/auth.dto.ts +62 -0
- package/src/dto/index.ts +2 -0
- package/src/{logging/dto/log-filter.dto.ts → dto/logging.dto.ts} +1 -1
- package/src/enums/error.enum.ts +26 -0
- package/src/enums/events.enum.ts +22 -0
- package/src/enums/health.enum.ts +7 -0
- package/src/enums/index.ts +8 -5
- package/src/enums/permission.enum.ts +31 -0
- package/src/enums/{user-role.enum.ts → user.enum.ts} +3 -1
- package/src/errors/app.error.ts +33 -0
- package/src/errors/error-map.ts +95 -0
- package/src/index.ts +10 -1
- package/src/types/auth.types.ts +5 -0
- package/src/types/config.types.ts +4 -2
- package/src/types/index.ts +2 -1
- package/src/types/monitoring.types.ts +79 -0
- package/src/types/user.types.ts +11 -0
- package/src/utils/app.utils.ts +54 -0
- package/src/utils/health.utils.ts +72 -0
- package/src/utils/logging-client.ts +21 -0
- package/src/utils/prometheus.utils.ts +114 -0
- package/src/utils/user.utils.ts +3 -0
- package/dist/constants/services.constants.d.ts +0 -6
- package/dist/constants/services.constants.js +0 -10
- package/dist/constants/services.constants.js.map +0 -1
- package/dist/enums/environment.enum.js.map +0 -1
- package/dist/enums/error-code.enum.d.ts +0 -8
- package/dist/enums/error-code.enum.js +0 -13
- package/dist/enums/error-code.enum.js.map +0 -1
- package/dist/enums/log-level.enum.js.map +0 -1
- package/dist/enums/notification-type.enum.js.map +0 -1
- package/dist/enums/user-role.enum.d.ts +0 -6
- package/dist/enums/user-role.enum.js.map +0 -1
- package/dist/logging/enums/log-level.enum.d.ts +0 -7
- package/dist/logging/enums/log-level.enum.js +0 -12
- package/dist/logging/enums/log-level.enum.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/proto/token.proto +0 -50
- package/src/constants/services.constants.ts +0 -6
- package/src/enums/error-code.enum.ts +0 -8
- package/src/logging/index.ts +0 -1
- /package/dist/enums/{environment.enum.d.ts → env.enum.d.ts} +0 -0
- /package/dist/enums/{log-level.enum.d.ts → logging.enum.d.ts} +0 -0
- /package/dist/enums/{notification-type.enum.d.ts → notification.enum.d.ts} +0 -0
- /package/src/enums/{environment.enum.ts → env.enum.ts} +0 -0
- /package/src/enums/{log-level.enum.ts → logging.enum.ts} +0 -0
- /package/src/enums/{notification-type.enum.ts → notification.enum.ts} +0 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ServiceEventType = void 0;
|
|
4
|
+
var ServiceEventType;
|
|
5
|
+
(function (ServiceEventType) {
|
|
6
|
+
ServiceEventType["AUTH_USER_REGISTERED"] = "auth.user.registered";
|
|
7
|
+
ServiceEventType["AUTH_USER_LOGGED_IN"] = "auth.user.logged_in";
|
|
8
|
+
ServiceEventType["AUTH_PASSWORD_RESET_REQUESTED"] = "auth.password_reset_requested";
|
|
9
|
+
ServiceEventType["AUTH_PASSWORD_RESET_SUCCESS"] = "auth.password_reset_success";
|
|
10
|
+
ServiceEventType["USER_PROFILE_UPDATED"] = "user.profile_updated";
|
|
11
|
+
ServiceEventType["USER_DELETED"] = "user.deleted";
|
|
12
|
+
ServiceEventType["AUTH_USER_BLOCKED"] = "auth.user.blocked";
|
|
13
|
+
})(ServiceEventType || (exports.ServiceEventType = ServiceEventType = {}));
|
|
14
|
+
//# sourceMappingURL=events.enum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.enum.js","sourceRoot":"","sources":["../../src/enums/events.enum.ts"],"names":[],"mappings":";;;AAAA,IAAY,gBAQX;AARD,WAAY,gBAAgB;IACxB,iEAA6C,CAAA;IAC7C,+DAA2C,CAAA;IAC3C,mFAA+D,CAAA;IAC/D,+EAA2D,CAAA;IAC3D,iEAA6C,CAAA;IAC7C,iDAA6B,CAAA;IAC7B,2DAAuC,CAAA;AAC3C,CAAC,EARW,gBAAgB,gCAAhB,gBAAgB,QAQ3B"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ServiceHealth = void 0;
|
|
4
|
+
var ServiceHealth;
|
|
5
|
+
(function (ServiceHealth) {
|
|
6
|
+
ServiceHealth["UP"] = "UP";
|
|
7
|
+
ServiceHealth["HEALTHY"] = "UP";
|
|
8
|
+
ServiceHealth["DOWN"] = "DOWN";
|
|
9
|
+
ServiceHealth["DEGRADED"] = "DEGRADED";
|
|
10
|
+
ServiceHealth["MAINTENANCE"] = "MAINTENANCE";
|
|
11
|
+
})(ServiceHealth || (exports.ServiceHealth = ServiceHealth = {}));
|
|
12
|
+
//# sourceMappingURL=health.enum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"health.enum.js","sourceRoot":"","sources":["../../src/enums/health.enum.ts"],"names":[],"mappings":";;;AAAA,IAAY,aAMX;AAND,WAAY,aAAa;IACrB,0BAAS,CAAA;IACT,+BAAc,CAAA;IACd,8BAAa,CAAA;IACb,sCAAqB,CAAA;IACrB,4CAA2B,CAAA;AAC/B,CAAC,EANW,aAAa,6BAAb,aAAa,QAMxB"}
|
package/dist/enums/index.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './user
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './
|
|
5
|
-
export * from './
|
|
1
|
+
export * from './env.enum';
|
|
2
|
+
export * from './user.enum';
|
|
3
|
+
export * from './health.enum';
|
|
4
|
+
export * from './logging.enum';
|
|
5
|
+
export * from './notification.enum';
|
|
6
|
+
export * from './error.enum';
|
|
7
|
+
export * from './permission.enum';
|
|
8
|
+
export * from './events.enum';
|
package/dist/enums/index.js
CHANGED
|
@@ -14,9 +14,12 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./
|
|
18
|
-
__exportStar(require("./user
|
|
19
|
-
__exportStar(require("./
|
|
20
|
-
__exportStar(require("./
|
|
21
|
-
__exportStar(require("./
|
|
17
|
+
__exportStar(require("./env.enum"), exports);
|
|
18
|
+
__exportStar(require("./user.enum"), exports);
|
|
19
|
+
__exportStar(require("./health.enum"), exports);
|
|
20
|
+
__exportStar(require("./logging.enum"), exports);
|
|
21
|
+
__exportStar(require("./notification.enum"), exports);
|
|
22
|
+
__exportStar(require("./error.enum"), exports);
|
|
23
|
+
__exportStar(require("./permission.enum"), exports);
|
|
24
|
+
__exportStar(require("./events.enum"), exports);
|
|
22
25
|
//# sourceMappingURL=index.js.map
|
package/dist/enums/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/enums/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/enums/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,8CAA4B;AAC5B,gDAA8B;AAC9B,iDAA+B;AAC/B,sDAAoC;AACpC,+CAA6B;AAC7B,oDAAkC;AAClC,gDAA8B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logging.enum.js","sourceRoot":"","sources":["../../src/enums/logging.enum.ts"],"names":[],"mappings":";;;AAAA,IAAY,QAMX;AAND,WAAY,QAAQ;IAChB,2BAAe,CAAA;IACf,yBAAa,CAAA;IACb,yBAAa,CAAA;IACb,2BAAe,CAAA;IACf,2BAAe,CAAA;AACnB,CAAC,EANW,QAAQ,wBAAR,QAAQ,QAMnB"}
|
|
@@ -7,4 +7,4 @@ var NotificationType;
|
|
|
7
7
|
NotificationType["SMS"] = "SMS";
|
|
8
8
|
NotificationType["PUSH"] = "PUSH";
|
|
9
9
|
})(NotificationType || (exports.NotificationType = NotificationType = {}));
|
|
10
|
-
//# sourceMappingURL=notification
|
|
10
|
+
//# sourceMappingURL=notification.enum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notification.enum.js","sourceRoot":"","sources":["../../src/enums/notification.enum.ts"],"names":[],"mappings":";;;AAAA,IAAY,gBAIX;AAJD,WAAY,gBAAgB;IACxB,mCAAe,CAAA;IACf,+BAAW,CAAA;IACX,iCAAa,CAAA;AACjB,CAAC,EAJW,gBAAgB,gCAAhB,gBAAgB,QAI3B"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare enum PermissionScope {
|
|
2
|
+
USERS_VIEW = "users:view",
|
|
3
|
+
USERS_MANAGE = "users:manage",
|
|
4
|
+
ROLES_MANAGE = "roles:manage",
|
|
5
|
+
PERMISSIONS_MANAGE = "permissions:manage",
|
|
6
|
+
CLIENTS_VIEW = "clients:view",
|
|
7
|
+
CLIENTS_MANAGE = "clients:manage",
|
|
8
|
+
PARTNERS_VIEW = "partners:view",
|
|
9
|
+
PARTNERS_MANAGE = "partners:manage",
|
|
10
|
+
INVOICES_VIEW = "invoices:view",
|
|
11
|
+
INVOICES_MANAGE = "invoices:manage",
|
|
12
|
+
TRANSACTIONS_VIEW = "transactions:view",
|
|
13
|
+
TRANSACTIONS_MANAGE = "transactions:manage",
|
|
14
|
+
CONFIG_VIEW = "config:view",
|
|
15
|
+
CONFIG_MANAGE = "config:manage",
|
|
16
|
+
LOGS_VIEW = "logs:view",
|
|
17
|
+
METRICS_VIEW = "metrics:view"
|
|
18
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PermissionScope = void 0;
|
|
4
|
+
var PermissionScope;
|
|
5
|
+
(function (PermissionScope) {
|
|
6
|
+
PermissionScope["USERS_VIEW"] = "users:view";
|
|
7
|
+
PermissionScope["USERS_MANAGE"] = "users:manage";
|
|
8
|
+
PermissionScope["ROLES_MANAGE"] = "roles:manage";
|
|
9
|
+
PermissionScope["PERMISSIONS_MANAGE"] = "permissions:manage";
|
|
10
|
+
PermissionScope["CLIENTS_VIEW"] = "clients:view";
|
|
11
|
+
PermissionScope["CLIENTS_MANAGE"] = "clients:manage";
|
|
12
|
+
PermissionScope["PARTNERS_VIEW"] = "partners:view";
|
|
13
|
+
PermissionScope["PARTNERS_MANAGE"] = "partners:manage";
|
|
14
|
+
PermissionScope["INVOICES_VIEW"] = "invoices:view";
|
|
15
|
+
PermissionScope["INVOICES_MANAGE"] = "invoices:manage";
|
|
16
|
+
PermissionScope["TRANSACTIONS_VIEW"] = "transactions:view";
|
|
17
|
+
PermissionScope["TRANSACTIONS_MANAGE"] = "transactions:manage";
|
|
18
|
+
PermissionScope["CONFIG_VIEW"] = "config:view";
|
|
19
|
+
PermissionScope["CONFIG_MANAGE"] = "config:manage";
|
|
20
|
+
PermissionScope["LOGS_VIEW"] = "logs:view";
|
|
21
|
+
PermissionScope["METRICS_VIEW"] = "metrics:view";
|
|
22
|
+
})(PermissionScope || (exports.PermissionScope = PermissionScope = {}));
|
|
23
|
+
//# sourceMappingURL=permission.enum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permission.enum.js","sourceRoot":"","sources":["../../src/enums/permission.enum.ts"],"names":[],"mappings":";;;AAAA,IAAY,eA8BX;AA9BD,WAAY,eAAe;IAEvB,4CAAyB,CAAA;IACzB,gDAA6B,CAAA;IAG7B,gDAA6B,CAAA;IAC7B,4DAAyC,CAAA;IAGzC,gDAA6B,CAAA;IAC7B,oDAAiC,CAAA;IAGjC,kDAA+B,CAAA;IAC/B,sDAAmC,CAAA;IAGnC,kDAA+B,CAAA;IAC/B,sDAAmC,CAAA;IACnC,0DAAuC,CAAA;IACvC,8DAA2C,CAAA;IAG3C,8CAA2B,CAAA;IAC3B,kDAA+B,CAAA;IAG/B,0CAAuB,CAAA;IACvB,gDAA6B,CAAA;AACjC,CAAC,EA9BW,eAAe,+BAAf,eAAe,QA8B1B"}
|
|
@@ -3,9 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.UserRole = void 0;
|
|
4
4
|
var UserRole;
|
|
5
5
|
(function (UserRole) {
|
|
6
|
+
UserRole["SUPER_ADMIN"] = "SUPER_ADMIN";
|
|
6
7
|
UserRole["ADMIN"] = "ADMIN";
|
|
8
|
+
UserRole["MANAGER"] = "MANAGER";
|
|
9
|
+
UserRole["ACCOUNTANT"] = "ACCOUNTANT";
|
|
7
10
|
UserRole["PARTNER"] = "PARTNER";
|
|
8
11
|
UserRole["CLIENT"] = "CLIENT";
|
|
9
|
-
UserRole["USER"] = "USER";
|
|
10
12
|
})(UserRole || (exports.UserRole = UserRole = {}));
|
|
11
|
-
//# sourceMappingURL=user
|
|
13
|
+
//# sourceMappingURL=user.enum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user.enum.js","sourceRoot":"","sources":["../../src/enums/user.enum.ts"],"names":[],"mappings":";;;AAAA,IAAY,QAOX;AAPD,WAAY,QAAQ;IAChB,uCAA2B,CAAA;IAC3B,2BAAe,CAAA;IACf,+BAAmB,CAAA;IACnB,qCAAyB,CAAA;IACzB,+BAAmB,CAAA;IACnB,6BAAiB,CAAA;AACrB,CAAC,EAPW,QAAQ,wBAAR,QAAQ,QAOnB"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ErrorCode } from '../enums/error.enum';
|
|
2
|
+
export declare class AppError extends Error {
|
|
3
|
+
readonly code: ErrorCode;
|
|
4
|
+
readonly statusCode: number;
|
|
5
|
+
readonly description?: string;
|
|
6
|
+
readonly metadata?: any;
|
|
7
|
+
constructor(code: ErrorCode, customMessage?: string, metadata?: any);
|
|
8
|
+
toJSON(): {
|
|
9
|
+
success: boolean;
|
|
10
|
+
error: {
|
|
11
|
+
code: ErrorCode;
|
|
12
|
+
message: string;
|
|
13
|
+
description: string;
|
|
14
|
+
metadata: any;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AppError = void 0;
|
|
4
|
+
const error_enum_1 = require("../enums/error.enum");
|
|
5
|
+
const error_map_1 = require("./error-map");
|
|
6
|
+
class AppError extends Error {
|
|
7
|
+
constructor(code, customMessage, metadata) {
|
|
8
|
+
const errorDetail = error_map_1.ERROR_MAP[code] || error_map_1.ERROR_MAP[error_enum_1.ErrorCode.INTERNAL_SERVER_ERROR];
|
|
9
|
+
super(customMessage || errorDetail.message);
|
|
10
|
+
this.code = code;
|
|
11
|
+
this.statusCode = errorDetail.statusCode;
|
|
12
|
+
this.description = errorDetail.description;
|
|
13
|
+
this.metadata = metadata;
|
|
14
|
+
Object.setPrototypeOf(this, AppError.prototype);
|
|
15
|
+
}
|
|
16
|
+
toJSON() {
|
|
17
|
+
return {
|
|
18
|
+
success: false,
|
|
19
|
+
error: {
|
|
20
|
+
code: this.code,
|
|
21
|
+
message: this.message,
|
|
22
|
+
description: this.description,
|
|
23
|
+
metadata: this.metadata,
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.AppError = AppError;
|
|
29
|
+
//# sourceMappingURL=app.error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.error.js","sourceRoot":"","sources":["../../src/errors/app.error.ts"],"names":[],"mappings":";;;AAAA,oDAAgD;AAChD,2CAAwC;AAExC,MAAa,QAAS,SAAQ,KAAK;IAM/B,YAAY,IAAe,EAAE,aAAsB,EAAE,QAAc;QAC/D,MAAM,WAAW,GAAG,qBAAS,CAAC,IAAI,CAAC,IAAI,qBAAS,CAAC,sBAAS,CAAC,qBAAqB,CAAC,CAAC;QAClF,KAAK,CAAC,aAAa,IAAI,WAAW,CAAC,OAAO,CAAC,CAAC;QAE5C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,UAAU,GAAG,WAAW,CAAC,UAAU,CAAC;QACzC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC,WAAW,CAAC;QAC3C,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAEzB,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC;IACpD,CAAC;IAED,MAAM;QACF,OAAO;YACH,OAAO,EAAE,KAAK;YACd,KAAK,EAAE;gBACH,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,OAAO,EAAE,IAAI,CAAC,OAAO;gBACrB,WAAW,EAAE,IAAI,CAAC,WAAW;gBAC7B,QAAQ,EAAE,IAAI,CAAC,QAAQ;aAC1B;SACJ,CAAC;IACN,CAAC;CACJ;AA7BD,4BA6BC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ERROR_MAP = void 0;
|
|
4
|
+
const error_enum_1 = require("../enums/error.enum");
|
|
5
|
+
exports.ERROR_MAP = {
|
|
6
|
+
[error_enum_1.ErrorCode.AUTH_USER_NOT_FOUND]: {
|
|
7
|
+
message: 'User not found',
|
|
8
|
+
statusCode: 404,
|
|
9
|
+
description: 'The requested user could not be found in the system.',
|
|
10
|
+
},
|
|
11
|
+
[error_enum_1.ErrorCode.AUTH_USER_ALREADY_EXISTS]: {
|
|
12
|
+
message: 'User already exists',
|
|
13
|
+
statusCode: 409,
|
|
14
|
+
description: 'A user with this email already exists.',
|
|
15
|
+
},
|
|
16
|
+
[error_enum_1.ErrorCode.AUTH_USER_INACTIVE]: {
|
|
17
|
+
message: 'User is inactive',
|
|
18
|
+
statusCode: 403,
|
|
19
|
+
description: 'The user account is currently deactivated.',
|
|
20
|
+
},
|
|
21
|
+
[error_enum_1.ErrorCode.AUTH_INVALID_PASSWORD]: {
|
|
22
|
+
message: 'Invalid password',
|
|
23
|
+
statusCode: 401,
|
|
24
|
+
description: 'The provided password does not match.',
|
|
25
|
+
},
|
|
26
|
+
[error_enum_1.ErrorCode.AUTH_INVALID_TOKEN]: {
|
|
27
|
+
message: 'Invalid token',
|
|
28
|
+
statusCode: 401,
|
|
29
|
+
description: 'The provided authentication token is invalid or malformed.',
|
|
30
|
+
},
|
|
31
|
+
[error_enum_1.ErrorCode.AUTH_TOKEN_EXPIRED]: {
|
|
32
|
+
message: 'Token expired',
|
|
33
|
+
statusCode: 401,
|
|
34
|
+
description: 'The authentication token has expired. Please log in again.',
|
|
35
|
+
},
|
|
36
|
+
[error_enum_1.ErrorCode.AUTH_ACCESS_DENIED]: {
|
|
37
|
+
message: 'Access denied',
|
|
38
|
+
statusCode: 403,
|
|
39
|
+
description: 'You do not have permission to perform this action.',
|
|
40
|
+
},
|
|
41
|
+
[error_enum_1.ErrorCode.AUTH_INSUFFICIENT_SCOPES]: {
|
|
42
|
+
message: 'Insufficient scopes',
|
|
43
|
+
statusCode: 403,
|
|
44
|
+
description: 'Your token does not have the required scopes for this resource.',
|
|
45
|
+
},
|
|
46
|
+
[error_enum_1.ErrorCode.AUTH_INVALID_CREDENTIALS]: {
|
|
47
|
+
message: 'Invalid credentials',
|
|
48
|
+
statusCode: 401,
|
|
49
|
+
description: 'The email or password you entered is incorrect.',
|
|
50
|
+
},
|
|
51
|
+
[error_enum_1.ErrorCode.CONFIG_NOT_FOUND]: {
|
|
52
|
+
message: 'Configuration not found',
|
|
53
|
+
statusCode: 404,
|
|
54
|
+
description: 'The requested configuration key was not found.',
|
|
55
|
+
},
|
|
56
|
+
[error_enum_1.ErrorCode.CONFIG_LOAD_FAILED]: {
|
|
57
|
+
message: 'Configuration load failed',
|
|
58
|
+
statusCode: 500,
|
|
59
|
+
description: 'Failed to load configuration from the source.',
|
|
60
|
+
},
|
|
61
|
+
[error_enum_1.ErrorCode.LOG_WRITE_FAILED]: {
|
|
62
|
+
message: 'Log write failed',
|
|
63
|
+
statusCode: 500,
|
|
64
|
+
description: 'Failed to write log to the destination.',
|
|
65
|
+
},
|
|
66
|
+
[error_enum_1.ErrorCode.LOG_READ_FAILED]: {
|
|
67
|
+
message: 'Log read failed',
|
|
68
|
+
statusCode: 500,
|
|
69
|
+
description: 'Failed to read logs from the source.',
|
|
70
|
+
},
|
|
71
|
+
[error_enum_1.ErrorCode.INTERNAL_SERVER_ERROR]: {
|
|
72
|
+
message: 'Internal server error',
|
|
73
|
+
statusCode: 500,
|
|
74
|
+
description: 'An unexpected error occurred on the server.',
|
|
75
|
+
},
|
|
76
|
+
[error_enum_1.ErrorCode.BAD_REQUEST]: {
|
|
77
|
+
message: 'Bad request',
|
|
78
|
+
statusCode: 400,
|
|
79
|
+
description: 'The request is invalid or cannot be served.',
|
|
80
|
+
},
|
|
81
|
+
[error_enum_1.ErrorCode.NOT_FOUND]: {
|
|
82
|
+
message: 'Resource not found',
|
|
83
|
+
statusCode: 404,
|
|
84
|
+
description: 'The requested resource could not be found.',
|
|
85
|
+
},
|
|
86
|
+
[error_enum_1.ErrorCode.VALIDATION_ERROR]: {
|
|
87
|
+
message: 'Validation error',
|
|
88
|
+
statusCode: 422,
|
|
89
|
+
description: 'The provided data failed validation.',
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
//# sourceMappingURL=error-map.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-map.js","sourceRoot":"","sources":["../../src/errors/error-map.ts"],"names":[],"mappings":";;;AAAA,oDAAgD;AAQnC,QAAA,SAAS,GAAmC;IACrD,CAAC,sBAAS,CAAC,mBAAmB,CAAC,EAAE;QAC7B,OAAO,EAAE,gBAAgB;QACzB,UAAU,EAAE,GAAG;QACf,WAAW,EAAE,sDAAsD;KACtE;IACD,CAAC,sBAAS,CAAC,wBAAwB,CAAC,EAAE;QAClC,OAAO,EAAE,qBAAqB;QAC9B,UAAU,EAAE,GAAG;QACf,WAAW,EAAE,wCAAwC;KACxD;IACD,CAAC,sBAAS,CAAC,kBAAkB,CAAC,EAAE;QAC5B,OAAO,EAAE,kBAAkB;QAC3B,UAAU,EAAE,GAAG;QACf,WAAW,EAAE,4CAA4C;KAC5D;IACD,CAAC,sBAAS,CAAC,qBAAqB,CAAC,EAAE;QAC/B,OAAO,EAAE,kBAAkB;QAC3B,UAAU,EAAE,GAAG;QACf,WAAW,EAAE,uCAAuC;KACvD;IACD,CAAC,sBAAS,CAAC,kBAAkB,CAAC,EAAE;QAC5B,OAAO,EAAE,eAAe;QACxB,UAAU,EAAE,GAAG;QACf,WAAW,EAAE,4DAA4D;KAC5E;IACD,CAAC,sBAAS,CAAC,kBAAkB,CAAC,EAAE;QAC5B,OAAO,EAAE,eAAe;QACxB,UAAU,EAAE,GAAG;QACf,WAAW,EAAE,4DAA4D;KAC5E;IACD,CAAC,sBAAS,CAAC,kBAAkB,CAAC,EAAE;QAC5B,OAAO,EAAE,eAAe;QACxB,UAAU,EAAE,GAAG;QACf,WAAW,EAAE,oDAAoD;KACpE;IACD,CAAC,sBAAS,CAAC,wBAAwB,CAAC,EAAE;QAClC,OAAO,EAAE,qBAAqB;QAC9B,UAAU,EAAE,GAAG;QACf,WAAW,EAAE,iEAAiE;KACjF;IACD,CAAC,sBAAS,CAAC,wBAAwB,CAAC,EAAE;QAClC,OAAO,EAAE,qBAAqB;QAC9B,UAAU,EAAE,GAAG;QACf,WAAW,EAAE,iDAAiD;KACjE;IACD,CAAC,sBAAS,CAAC,gBAAgB,CAAC,EAAE;QAC1B,OAAO,EAAE,yBAAyB;QAClC,UAAU,EAAE,GAAG;QACf,WAAW,EAAE,gDAAgD;KAChE;IACD,CAAC,sBAAS,CAAC,kBAAkB,CAAC,EAAE;QAC5B,OAAO,EAAE,2BAA2B;QACpC,UAAU,EAAE,GAAG;QACf,WAAW,EAAE,+CAA+C;KAC/D;IACD,CAAC,sBAAS,CAAC,gBAAgB,CAAC,EAAE;QAC1B,OAAO,EAAE,kBAAkB;QAC3B,UAAU,EAAE,GAAG;QACf,WAAW,EAAE,yCAAyC;KACzD;IACD,CAAC,sBAAS,CAAC,eAAe,CAAC,EAAE;QACzB,OAAO,EAAE,iBAAiB;QAC1B,UAAU,EAAE,GAAG;QACf,WAAW,EAAE,sCAAsC;KACtD;IACD,CAAC,sBAAS,CAAC,qBAAqB,CAAC,EAAE;QAC/B,OAAO,EAAE,uBAAuB;QAChC,UAAU,EAAE,GAAG;QACf,WAAW,EAAE,6CAA6C;KAC7D;IACD,CAAC,sBAAS,CAAC,WAAW,CAAC,EAAE;QACrB,OAAO,EAAE,aAAa;QACtB,UAAU,EAAE,GAAG;QACf,WAAW,EAAE,6CAA6C;KAC7D;IACD,CAAC,sBAAS,CAAC,SAAS,CAAC,EAAE;QACnB,OAAO,EAAE,oBAAoB;QAC7B,UAAU,EAAE,GAAG;QACf,WAAW,EAAE,4CAA4C;KAC5D;IACD,CAAC,sBAAS,CAAC,gBAAgB,CAAC,EAAE;QAC1B,OAAO,EAAE,kBAAkB;QAC3B,UAAU,EAAE,GAAG;QACf,WAAW,EAAE,sCAAsC;KACtD;CACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,5 +2,14 @@ export * from './enums';
|
|
|
2
2
|
export * from './constants';
|
|
3
3
|
export * from './types';
|
|
4
4
|
export * from './contracts';
|
|
5
|
+
export * from './dto';
|
|
6
|
+
export * from './errors/app.error';
|
|
7
|
+
export * from './errors/error-map';
|
|
8
|
+
export * from './decorators/scopes.decorator';
|
|
5
9
|
export * from './utils/proto-path';
|
|
6
|
-
export * from './logging';
|
|
10
|
+
export * from './utils/logging-client';
|
|
11
|
+
export * from './config/base-config.service';
|
|
12
|
+
export * from './utils/user.utils';
|
|
13
|
+
export * from './utils/prometheus.utils';
|
|
14
|
+
export * from './utils/app.utils';
|
|
15
|
+
export * from './utils/health.utils';
|
package/dist/index.js
CHANGED
|
@@ -18,6 +18,15 @@ __exportStar(require("./enums"), exports);
|
|
|
18
18
|
__exportStar(require("./constants"), exports);
|
|
19
19
|
__exportStar(require("./types"), exports);
|
|
20
20
|
__exportStar(require("./contracts"), exports);
|
|
21
|
+
__exportStar(require("./dto"), exports);
|
|
22
|
+
__exportStar(require("./errors/app.error"), exports);
|
|
23
|
+
__exportStar(require("./errors/error-map"), exports);
|
|
24
|
+
__exportStar(require("./decorators/scopes.decorator"), exports);
|
|
21
25
|
__exportStar(require("./utils/proto-path"), exports);
|
|
22
|
-
__exportStar(require("./logging"), exports);
|
|
26
|
+
__exportStar(require("./utils/logging-client"), exports);
|
|
27
|
+
__exportStar(require("./config/base-config.service"), exports);
|
|
28
|
+
__exportStar(require("./utils/user.utils"), exports);
|
|
29
|
+
__exportStar(require("./utils/prometheus.utils"), exports);
|
|
30
|
+
__exportStar(require("./utils/app.utils"), exports);
|
|
31
|
+
__exportStar(require("./utils/health.utils"), exports);
|
|
23
32
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,8CAA4B;AAC5B,0CAAwB;AACxB,8CAA4B;AAC5B,qDAAmC;AACnC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,8CAA4B;AAC5B,0CAAwB;AACxB,8CAA4B;AAC5B,wCAAsB;AACtB,qDAAmC;AACnC,qDAAmC;AACnC,gEAA8C;AAC9C,qDAAmC;AACnC,yDAAuC;AACvC,+DAA6C;AAC7C,qDAAmC;AACnC,2DAAyC;AACzC,oDAAkC;AAClC,uDAAqC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { Environment } from '../enums/env.enum';
|
|
1
2
|
export interface IBaseConfig {
|
|
2
|
-
environment:
|
|
3
|
+
environment: Environment;
|
|
3
4
|
}
|
|
4
5
|
export interface DbConfig {
|
|
5
6
|
url: string;
|
|
@@ -17,7 +18,7 @@ export interface AppConfig {
|
|
|
17
18
|
port: number;
|
|
18
19
|
host?: string;
|
|
19
20
|
serviceName: string;
|
|
20
|
-
environment?:
|
|
21
|
+
environment?: Environment;
|
|
21
22
|
version?: string;
|
|
22
23
|
description?: string;
|
|
23
24
|
databaseUrl?: string;
|
package/dist/types/index.d.ts
CHANGED
package/dist/types/index.js
CHANGED
|
@@ -16,4 +16,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./config.types"), exports);
|
|
18
18
|
__exportStar(require("./auth.types"), exports);
|
|
19
|
+
__exportStar(require("./user.types"), exports);
|
|
20
|
+
__exportStar(require("./monitoring.types"), exports);
|
|
19
21
|
//# sourceMappingURL=index.js.map
|
package/dist/types/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,+CAA6B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,+CAA6B;AAC7B,+CAA6B;AAC7B,qDAAmC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export interface PrometheusMetric {
|
|
2
|
+
name: string;
|
|
3
|
+
help: string;
|
|
4
|
+
type: 'counter' | 'gauge' | 'histogram' | 'summary';
|
|
5
|
+
labelNames?: string[];
|
|
6
|
+
}
|
|
7
|
+
export interface MetricValue {
|
|
8
|
+
value: number;
|
|
9
|
+
labels?: Record<string, string>;
|
|
10
|
+
timestamp?: number;
|
|
11
|
+
}
|
|
12
|
+
export interface ServiceMetrics {
|
|
13
|
+
serviceName: string;
|
|
14
|
+
timestamp: Date;
|
|
15
|
+
metrics: {
|
|
16
|
+
httpRequestsTotal?: number;
|
|
17
|
+
httpRequestDuration?: number;
|
|
18
|
+
httpErrorsTotal?: number;
|
|
19
|
+
dbConnectionsActive?: number;
|
|
20
|
+
dbConnectionsIdle?: number;
|
|
21
|
+
dbQueryDuration?: number;
|
|
22
|
+
dbQueriesTotal?: number;
|
|
23
|
+
cpuUsage?: number;
|
|
24
|
+
memoryUsage?: number;
|
|
25
|
+
heapUsed?: number;
|
|
26
|
+
heapTotal?: number;
|
|
27
|
+
activeUsers?: number;
|
|
28
|
+
requestsPerSecond?: number;
|
|
29
|
+
errorRate?: number;
|
|
30
|
+
[key: string]: number | undefined;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export interface HealthCheckResult {
|
|
34
|
+
status: 'healthy' | 'unhealthy' | 'degraded';
|
|
35
|
+
checks: {
|
|
36
|
+
[component: string]: {
|
|
37
|
+
status: 'up' | 'down';
|
|
38
|
+
message?: string;
|
|
39
|
+
responseTime?: number;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
timestamp: Date;
|
|
43
|
+
}
|
|
44
|
+
export interface GrafanaDashboard {
|
|
45
|
+
id: string;
|
|
46
|
+
title: string;
|
|
47
|
+
panels: GrafanaPanel[];
|
|
48
|
+
tags: string[];
|
|
49
|
+
}
|
|
50
|
+
export interface GrafanaPanel {
|
|
51
|
+
id: number;
|
|
52
|
+
title: string;
|
|
53
|
+
type: 'graph' | 'singlestat' | 'table' | 'heatmap';
|
|
54
|
+
targets: GrafanaTarget[];
|
|
55
|
+
}
|
|
56
|
+
export interface GrafanaTarget {
|
|
57
|
+
expr: string;
|
|
58
|
+
legendFormat?: string;
|
|
59
|
+
refId: string;
|
|
60
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"monitoring.types.js","sourceRoot":"","sources":["../../src/types/monitoring.types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
import { UserResponse } from '../dto/auth.dto';
|
|
3
|
+
import { GetUserByIdGrpcRequest, GetUserByEmailGrpcRequest } from '../contracts/auth.contract';
|
|
4
|
+
export interface IUserService {
|
|
5
|
+
getUserById(data: GetUserByIdGrpcRequest): Observable<UserResponse>;
|
|
6
|
+
getUserByEmail(data: GetUserByEmailGrpcRequest): Observable<UserResponse>;
|
|
7
|
+
createUser(data: any): Observable<UserResponse>;
|
|
8
|
+
updateUser(data: any): Observable<UserResponse>;
|
|
9
|
+
deleteUser(data: any): Observable<any>;
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user.types.js","sourceRoot":"","sources":["../../src/types/user.types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { INestApplication } from '@nestjs/common';
|
|
2
|
+
export interface AppSetupOptions {
|
|
3
|
+
corsOrigins?: string[];
|
|
4
|
+
apiPrefix?: string;
|
|
5
|
+
helmet?: boolean;
|
|
6
|
+
validation?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function setupStandardApp(app: INestApplication, options?: AppSetupOptions): void;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setupStandardApp = setupStandardApp;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const http_constants_1 = require("../constants/http.constants");
|
|
6
|
+
const helmet_1 = require("helmet");
|
|
7
|
+
function setupStandardApp(app, options = {}) {
|
|
8
|
+
const { corsOrigins = ['*'], apiPrefix = http_constants_1.API_PREFIX.V1, helmet: useHelmet = true, validation = true, } = options;
|
|
9
|
+
app.enableCors({
|
|
10
|
+
origin: corsOrigins,
|
|
11
|
+
credentials: true,
|
|
12
|
+
});
|
|
13
|
+
app.setGlobalPrefix(apiPrefix);
|
|
14
|
+
if (useHelmet) {
|
|
15
|
+
app.use((0, helmet_1.default)());
|
|
16
|
+
}
|
|
17
|
+
if (validation) {
|
|
18
|
+
app.useGlobalPipes(new common_1.ValidationPipe({
|
|
19
|
+
whitelist: true,
|
|
20
|
+
forbidNonWhitelisted: true,
|
|
21
|
+
transform: true,
|
|
22
|
+
}));
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=app.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.utils.js","sourceRoot":"","sources":["../../src/utils/app.utils.ts"],"names":[],"mappings":";;AAkBA,4CAmCC;AAjDD,2CAAkE;AAClE,gEAAyD;AACzD,mCAA4B;AAY5B,SAAgB,gBAAgB,CAC5B,GAAqB,EACrB,UAA2B,EAAE;IAE7B,MAAM,EACF,WAAW,GAAG,CAAC,GAAG,CAAC,EACnB,SAAS,GAAG,2BAAU,CAAC,EAAE,EACzB,MAAM,EAAE,SAAS,GAAG,IAAI,EACxB,UAAU,GAAG,IAAI,GACpB,GAAG,OAAO,CAAC;IAGZ,GAAG,CAAC,UAAU,CAAC;QACX,MAAM,EAAE,WAAW;QACnB,WAAW,EAAE,IAAI;KACpB,CAAC,CAAC;IAGH,GAAG,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;IAG/B,IAAI,SAAS,EAAE,CAAC;QACZ,GAAG,CAAC,GAAG,CAAC,IAAA,gBAAM,GAAE,CAAC,CAAC;IACtB,CAAC;IAGD,IAAI,UAAU,EAAE,CAAC;QACb,GAAG,CAAC,cAAc,CACd,IAAI,uBAAc,CAAC;YACf,SAAS,EAAE,IAAI;YACf,oBAAoB,EAAE,IAAI;YAC1B,SAAS,EAAE,IAAI;SAClB,CAAC,CACL,CAAC;IACN,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface ComponentHealth {
|
|
2
|
+
status: 'up' | 'down';
|
|
3
|
+
message?: string;
|
|
4
|
+
responseTime?: number;
|
|
5
|
+
}
|
|
6
|
+
export declare function createPrismaHealthCheck(prisma: any): () => Promise<ComponentHealth>;
|
|
7
|
+
export declare function createRedisHealthCheck(redis: any): () => Promise<ComponentHealth>;
|
|
8
|
+
export declare function createGrpcHealthCheck(client: any, methodName?: string): () => Promise<ComponentHealth>;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createPrismaHealthCheck = createPrismaHealthCheck;
|
|
4
|
+
exports.createRedisHealthCheck = createRedisHealthCheck;
|
|
5
|
+
exports.createGrpcHealthCheck = createGrpcHealthCheck;
|
|
6
|
+
function createPrismaHealthCheck(prisma) {
|
|
7
|
+
return async () => {
|
|
8
|
+
const start = Date.now();
|
|
9
|
+
try {
|
|
10
|
+
await prisma.$queryRaw `SELECT 1`;
|
|
11
|
+
return {
|
|
12
|
+
status: 'up',
|
|
13
|
+
responseTime: Date.now() - start,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
return {
|
|
18
|
+
status: 'down',
|
|
19
|
+
message: error.message,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function createRedisHealthCheck(redis) {
|
|
25
|
+
return async () => {
|
|
26
|
+
const start = Date.now();
|
|
27
|
+
try {
|
|
28
|
+
await redis.ping();
|
|
29
|
+
return {
|
|
30
|
+
status: 'up',
|
|
31
|
+
responseTime: Date.now() - start,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
return {
|
|
36
|
+
status: 'down',
|
|
37
|
+
message: error.message,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function createGrpcHealthCheck(client, methodName = 'ping') {
|
|
43
|
+
return async () => {
|
|
44
|
+
const start = Date.now();
|
|
45
|
+
try {
|
|
46
|
+
await client[methodName]({});
|
|
47
|
+
return {
|
|
48
|
+
status: 'up',
|
|
49
|
+
responseTime: Date.now() - start,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
return {
|
|
54
|
+
status: 'down',
|
|
55
|
+
message: error.message,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=health.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"health.utils.js","sourceRoot":"","sources":["../../src/utils/health.utils.ts"],"names":[],"mappings":";;AAaA,0DAgBC;AAKD,wDAgBC;AAKD,sDAgBC;AA1DD,SAAgB,uBAAuB,CAAC,MAAW;IAC/C,OAAO,KAAK,IAA8B,EAAE;QACxC,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACzB,IAAI,CAAC;YACD,MAAM,MAAM,CAAC,SAAS,CAAA,UAAU,CAAC;YACjC,OAAO;gBACH,MAAM,EAAE,IAAI;gBACZ,YAAY,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK;aACnC,CAAC;QACN,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YAClB,OAAO;gBACH,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE,KAAK,CAAC,OAAO;aACzB,CAAC;QACN,CAAC;IACL,CAAC,CAAC;AACN,CAAC;AAKD,SAAgB,sBAAsB,CAAC,KAAU;IAC7C,OAAO,KAAK,IAA8B,EAAE;QACxC,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACzB,IAAI,CAAC;YACD,MAAM,KAAK,CAAC,IAAI,EAAE,CAAC;YACnB,OAAO;gBACH,MAAM,EAAE,IAAI;gBACZ,YAAY,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK;aACnC,CAAC;QACN,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YAClB,OAAO;gBACH,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE,KAAK,CAAC,OAAO;aACzB,CAAC;QACN,CAAC;IACL,CAAC,CAAC;AACN,CAAC;AAKD,SAAgB,qBAAqB,CAAC,MAAW,EAAE,aAAqB,MAAM;IAC1E,OAAO,KAAK,IAA8B,EAAE;QACxC,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACzB,IAAI,CAAC;YACD,MAAM,MAAM,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC;YAC7B,OAAO;gBACH,MAAM,EAAE,IAAI;gBACZ,YAAY,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK;aACnC,CAAC;QACN,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YAClB,OAAO;gBACH,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE,KAAK,CAAC,OAAO;aACzB,CAAC;QACN,CAAC;IACL,CAAC,CAAC;AACN,CAAC"}
|