@abyss-project/console 1.0.6 → 1.0.7
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/api/index.d.ts +3 -0
- package/dist/api/index.js +3 -0
- package/dist/api/secret-access.api.d.ts +9 -0
- package/dist/api/secret-access.api.js +44 -0
- package/dist/api/secret-public.api.d.ts +2 -0
- package/dist/api/secret-public.api.js +9 -0
- package/dist/api/secret.api.d.ts +11 -0
- package/dist/api/secret.api.js +54 -0
- package/dist/index.d.ts +33 -1
- package/dist/index.js +34 -3
- package/dist/types/dto/workflow.dto.d.ts +0 -1
- package/dist/types/interface/api/index.d.ts +6 -0
- package/dist/types/interface/api/index.js +6 -0
- package/dist/types/interface/api/requests/secret-access.request.d.ts +48 -0
- package/dist/types/interface/api/requests/secret-public.request.d.ts +3 -0
- package/dist/types/interface/api/requests/secret.request.d.ts +57 -0
- package/dist/types/interface/api/responses/secret-access.response.d.ts +25 -0
- package/dist/types/interface/api/responses/secret-public.response.d.ts +5 -0
- package/dist/types/interface/api/responses/secret.response.d.ts +39 -0
- package/dist/types/interface/api/responses/workflow-webhook.public.response.d.ts +4 -2
- package/dist/types/interface/index.d.ts +6 -0
- package/dist/types/interface/index.js +6 -0
- package/dist/types/interface/models/secret-access-ip-address.model.d.ts +12 -0
- package/dist/types/interface/models/secret-access-log.model.d.ts +14 -0
- package/dist/types/interface/models/secret-access-secret.model.d.ts +11 -0
- package/dist/types/interface/models/secret-access.model.d.ts +19 -0
- package/dist/types/interface/models/secret-version.model.d.ts +11 -0
- package/dist/types/interface/models/secret.model.d.ts +15 -0
- package/dist/utils/cidr.util.d.ts +3 -0
- package/dist/utils/cidr.util.js +22 -0
- package/dist/utils/webhook-trigger.utils.d.ts +1 -1
- package/package.json +1 -1
- package/dist/api/application-cron-task.admin.api.d.ts +0 -10
- package/dist/api/application-cron-task.admin.api.js +0 -40
- package/dist/api/application-cron-task.api.d.ts +0 -10
- package/dist/api/application-cron-task.api.js +0 -40
- package/dist/api/application-event.admin.api.d.ts +0 -4
- package/dist/api/application-event.admin.api.js +0 -16
- package/dist/api/application-event.api.d.ts +0 -8
- package/dist/api/application-event.api.js +0 -32
- package/dist/api/application-log.admin.api.d.ts +0 -3
- package/dist/api/application-log.admin.api.js +0 -12
- package/dist/api/application-log.api.d.ts +0 -4
- package/dist/api/application-log.api.js +0 -16
- package/dist/api/application-sentinel.admin.api.d.ts +0 -9
- package/dist/api/application-sentinel.admin.api.js +0 -36
- package/dist/api/application-sentinel.api.d.ts +0 -10
- package/dist/api/application-sentinel.api.js +0 -40
- package/dist/api/application-stats.admin.api.d.ts +0 -3
- package/dist/api/application-stats.admin.api.js +0 -12
- package/dist/api/application-stats.api.d.ts +0 -4
- package/dist/api/application-stats.api.js +0 -16
- package/dist/api/application-webhook-history.admin.api.d.ts +0 -3
- package/dist/api/application-webhook-history.admin.api.js +0 -12
- package/dist/api/application-webhook-history.api.d.ts +0 -3
- package/dist/api/application-webhook-history.api.js +0 -12
- package/dist/api/application-webhook.admin.api.d.ts +0 -7
- package/dist/api/application-webhook.admin.api.js +0 -28
- package/dist/api/application-webhook.api.d.ts +0 -7
- package/dist/api/application-webhook.api.js +0 -28
- package/dist/api/application.admin.api.d.ts +0 -7
- package/dist/api/application.admin.api.js +0 -28
- package/dist/api/application.api.d.ts +0 -10
- package/dist/api/application.api.js +0 -40
- package/dist/api/hourly-metrics.api.d.ts +0 -2
- package/dist/api/hourly-metrics.api.js +0 -8
- package/dist/api/infrastructure.admin.api.d.ts +0 -3
- package/dist/api/infrastructure.admin.api.js +0 -12
- package/dist/api/metrics.api.d.ts +0 -4
- package/dist/api/metrics.api.js +0 -16
- package/dist/api/report.admin.api.d.ts +0 -2
- package/dist/api/report.admin.api.js +0 -9
- package/dist/frameworks/express/decorators.d.ts +0 -52
- package/dist/frameworks/express/decorators.js +0 -163
- package/dist/frameworks/express/index.d.ts +0 -17
- package/dist/frameworks/express/index.js +0 -173
- package/dist/frameworks/express/metadata.d.ts +0 -9
- package/dist/frameworks/express/metadata.js +0 -12
- package/dist/frameworks/index.d.ts +0 -1
- package/dist/frameworks/index.js +0 -17
- package/dist/middlewares/context.middleware.d.ts +0 -12
- package/dist/middlewares/context.middleware.js +0 -39
- package/dist/middlewares/index.d.ts +0 -3
- package/dist/middlewares/index.js +0 -19
- package/dist/middlewares/logger-endpoint.middleware.d.ts +0 -5
- package/dist/middlewares/logger-endpoint.middleware.js +0 -86
- package/dist/middlewares/logger-setup.middleware.d.ts +0 -5
- package/dist/middlewares/logger-setup.middleware.js +0 -16
- package/dist/models/index.d.ts +0 -1
- package/dist/models/index.js +0 -17
- package/dist/models/logger.model.d.ts +0 -61
- package/dist/models/logger.model.js +0 -201
- package/dist/models/stats-publisher.model.d.ts +0 -20
- package/dist/models/stats-publisher.model.js +0 -113
- package/dist/types/constants/webhook-trigger.constants.d.ts +0 -0
- package/dist/types/constants/webhook-trigger.constants.js +0 -1
- package/dist/types/enum/api-method.enum.d.ts +0 -7
- package/dist/types/enum/api-method.enum.js +0 -11
- package/dist/types/enum/application-alert-type.enum.d.ts +0 -5
- package/dist/types/enum/application-alert-type.enum.js +0 -9
- package/dist/types/enum/application-sentinel-type.enum.d.ts +0 -5
- package/dist/types/enum/application-sentinel-type.enum.js +0 -9
- package/dist/types/enum/application-stats-type.enum.d.ts +0 -5
- package/dist/types/enum/application-stats-type.enum.js +0 -9
- package/dist/types/enum/application-webhook-scope.enum.d.ts +0 -4
- package/dist/types/enum/application-webhook-scope.enum.js +0 -8
- package/dist/types/enum/log-level.enum.d.ts +0 -6
- package/dist/types/enum/log-level.enum.js +0 -10
- package/dist/types/enum/log-scenario.enum.d.ts +0 -5
- package/dist/types/enum/log-scenario.enum.js +0 -9
- package/dist/types/enum/time-period.enum.d.ts +0 -0
- package/dist/types/enum/time-period.enum.js +0 -1
- package/dist/types/interface/api/requests/application-cron-task.admin.request.d.ts +0 -50
- package/dist/types/interface/api/requests/application-cron-task.request.d.ts +0 -61
- package/dist/types/interface/api/requests/application-event.admin.request.d.ts +0 -16
- package/dist/types/interface/api/requests/application-event.request.d.ts +0 -50
- package/dist/types/interface/api/requests/application-log.admin.request.d.ts +0 -19
- package/dist/types/interface/api/requests/application-log.request.d.ts +0 -59
- package/dist/types/interface/api/requests/application-sentinel.admin.request.d.ts +0 -52
- package/dist/types/interface/api/requests/application-sentinel.request.d.ts +0 -71
- package/dist/types/interface/api/requests/application-stats.admin.request.d.ts +0 -13
- package/dist/types/interface/api/requests/application-stats.request.d.ts +0 -31
- package/dist/types/interface/api/requests/application-webhook-history.admin.request.d.ts +0 -16
- package/dist/types/interface/api/requests/application-webhook-history.request.d.ts +0 -21
- package/dist/types/interface/api/requests/application-webhook.admin.request.d.ts +0 -39
- package/dist/types/interface/api/requests/application-webhook.admin.request.js +0 -2
- package/dist/types/interface/api/requests/application-webhook.request.d.ts +0 -45
- package/dist/types/interface/api/requests/application-webhook.request.js +0 -2
- package/dist/types/interface/api/requests/application.admin.request.d.ts +0 -23
- package/dist/types/interface/api/requests/application.admin.request.js +0 -2
- package/dist/types/interface/api/requests/application.request.d.ts +0 -64
- package/dist/types/interface/api/requests/application.request.js +0 -2
- package/dist/types/interface/api/requests/hourly-metrics.request.d.ts +0 -10
- package/dist/types/interface/api/requests/hourly-metrics.request.js +0 -2
- package/dist/types/interface/api/requests/infrastructure.admin.request.d.ts +0 -4
- package/dist/types/interface/api/requests/infrastructure.admin.request.js +0 -2
- package/dist/types/interface/api/requests/metrics.admin.request.d.ts +0 -14
- package/dist/types/interface/api/requests/metrics.admin.request.js +0 -2
- package/dist/types/interface/api/requests/metrics.request.d.ts +0 -23
- package/dist/types/interface/api/requests/metrics.request.js +0 -2
- package/dist/types/interface/api/requests/report.admin.request.d.ts +0 -6
- package/dist/types/interface/api/requests/report.admin.request.js +0 -2
- package/dist/types/interface/api/requests/webhook-public.request.d.ts +0 -0
- package/dist/types/interface/api/requests/webhook-public.request.js +0 -1
- package/dist/types/interface/api/requests/workflow-webhook-trigger.request.d.ts +0 -66
- package/dist/types/interface/api/requests/workflow-webhook-trigger.request.js +0 -2
- package/dist/types/interface/api/requests/workflow-webhook.request.d.ts +0 -123
- package/dist/types/interface/api/requests/workflow-webhook.request.js +0 -2
- package/dist/types/interface/api/responses/application-cron-task.admin.response.d.ts +0 -30
- package/dist/types/interface/api/responses/application-cron-task.admin.response.js +0 -2
- package/dist/types/interface/api/responses/application-cron-task.response.d.ts +0 -30
- package/dist/types/interface/api/responses/application-cron-task.response.js +0 -2
- package/dist/types/interface/api/responses/application-event.admin.response.d.ts +0 -9
- package/dist/types/interface/api/responses/application-event.admin.response.js +0 -2
- package/dist/types/interface/api/responses/application-event.response.d.ts +0 -33
- package/dist/types/interface/api/responses/application-event.response.js +0 -2
- package/dist/types/interface/api/responses/application-log.admin.response.d.ts +0 -10
- package/dist/types/interface/api/responses/application-log.admin.response.js +0 -2
- package/dist/types/interface/api/responses/application-log.response.d.ts +0 -10
- package/dist/types/interface/api/responses/application-log.response.js +0 -2
- package/dist/types/interface/api/responses/application-sentinel.admin.response.d.ts +0 -26
- package/dist/types/interface/api/responses/application-sentinel.admin.response.js +0 -2
- package/dist/types/interface/api/responses/application-sentinel.response.d.ts +0 -33
- package/dist/types/interface/api/responses/application-sentinel.response.js +0 -2
- package/dist/types/interface/api/responses/application-stats.admin.response.d.ts +0 -6
- package/dist/types/interface/api/responses/application-stats.admin.response.js +0 -2
- package/dist/types/interface/api/responses/application-stats.response.d.ts +0 -10
- package/dist/types/interface/api/responses/application-stats.response.js +0 -2
- package/dist/types/interface/api/responses/application-webhook-history.admin.response.d.ts +0 -7
- package/dist/types/interface/api/responses/application-webhook-history.admin.response.js +0 -2
- package/dist/types/interface/api/responses/application-webhook-history.response.d.ts +0 -7
- package/dist/types/interface/api/responses/application-webhook-history.response.js +0 -2
- package/dist/types/interface/api/responses/application-webhook.admin.response.d.ts +0 -21
- package/dist/types/interface/api/responses/application-webhook.admin.response.js +0 -2
- package/dist/types/interface/api/responses/application-webhook.response.d.ts +0 -21
- package/dist/types/interface/api/responses/application-webhook.response.js +0 -2
- package/dist/types/interface/api/responses/application.admin.response.d.ts +0 -34
- package/dist/types/interface/api/responses/application.admin.response.js +0 -2
- package/dist/types/interface/api/responses/application.response.d.ts +0 -130
- package/dist/types/interface/api/responses/application.response.js +0 -2
- package/dist/types/interface/api/responses/hourly-metrics.response.d.ts +0 -70
- package/dist/types/interface/api/responses/hourly-metrics.response.js +0 -2
- package/dist/types/interface/api/responses/infrastructure.admin.response.d.ts +0 -18
- package/dist/types/interface/api/responses/infrastructure.admin.response.js +0 -2
- package/dist/types/interface/api/responses/metrics.admin.response.d.ts +0 -19
- package/dist/types/interface/api/responses/metrics.admin.response.js +0 -2
- package/dist/types/interface/api/responses/metrics.response.d.ts +0 -29
- package/dist/types/interface/api/responses/metrics.response.js +0 -2
- package/dist/types/interface/api/responses/report.admin.response.d.ts +0 -87
- package/dist/types/interface/api/responses/report.admin.response.js +0 -2
- package/dist/types/interface/api/responses/webhook-public.response.d.ts +0 -0
- package/dist/types/interface/api/responses/webhook-public.response.js +0 -1
- package/dist/types/interface/api/responses/workflow-webhook-action.response.d.ts +0 -24
- package/dist/types/interface/api/responses/workflow-webhook-action.response.js +0 -2
- package/dist/types/interface/api/responses/workflow-webhook-public.response.d.ts +0 -7
- package/dist/types/interface/api/responses/workflow-webhook-public.response.js +0 -2
- package/dist/types/interface/api/responses/workflow-webhook-trigger.response.d.ts +0 -41
- package/dist/types/interface/api/responses/workflow-webhook-trigger.response.js +0 -2
- package/dist/types/interface/api/responses/workflow-webhook.response.d.ts +0 -56
- package/dist/types/interface/api/responses/workflow-webhook.response.js +0 -2
- package/dist/types/interface/dto/application-sentinel-configuration.dto.d.ts +0 -68
- package/dist/types/interface/dto/application-sentinel-configuration.dto.js +0 -4
- package/dist/types/interface/dto/index.d.ts +0 -2
- package/dist/types/interface/dto/index.js +0 -18
- package/dist/types/interface/dto/webhook.dto.d.ts +0 -27
- package/dist/types/interface/dto/webhook.dto.js +0 -2
- package/dist/types/interface/models/application-cron-task-history.model.d.ts +0 -17
- package/dist/types/interface/models/application-cron-task-history.model.js +0 -2
- package/dist/types/interface/models/application-cron-task.model.d.ts +0 -14
- package/dist/types/interface/models/application-cron-task.model.js +0 -2
- package/dist/types/interface/models/application-event.model.d.ts +0 -19
- package/dist/types/interface/models/application-event.model.js +0 -2
- package/dist/types/interface/models/application-hourly-metrics.model.d.ts +0 -14
- package/dist/types/interface/models/application-hourly-metrics.model.js +0 -2
- package/dist/types/interface/models/application-lifetime-metrics.model.d.ts +0 -8
- package/dist/types/interface/models/application-lifetime-metrics.model.js +0 -2
- package/dist/types/interface/models/application-log-endpoint.model.d.ts +0 -20
- package/dist/types/interface/models/application-log-endpoint.model.js +0 -2
- package/dist/types/interface/models/application-log.model.d.ts +0 -23
- package/dist/types/interface/models/application-log.model.js +0 -2
- package/dist/types/interface/models/application-sentinel-history.model.d.ts +0 -16
- package/dist/types/interface/models/application-sentinel-history.model.js +0 -2
- package/dist/types/interface/models/application-sentinel.model.d.ts +0 -20
- package/dist/types/interface/models/application-sentinel.model.js +0 -2
- package/dist/types/interface/models/application-stats.model.d.ts +0 -14
- package/dist/types/interface/models/application-stats.model.js +0 -2
- package/dist/types/interface/models/application-webhook-history.model.d.ts +0 -22
- package/dist/types/interface/models/application-webhook-history.model.js +0 -2
- package/dist/types/interface/models/application-webhook.model.d.ts +0 -32
- package/dist/types/interface/models/application-webhook.model.js +0 -3
- package/dist/types/interface/models/application.model.d.ts +0 -19
- package/dist/types/interface/models/application.model.js +0 -2
- package/dist/types/interface/models/ip-whitelist.model.d.ts +0 -19
- package/dist/types/interface/models/ip-whitelist.model.js +0 -9
- package/dist/types/interface/models/partition-optimization-history.model.d.ts +0 -11
- package/dist/types/interface/models/partition-optimization-history.model.js +0 -2
- package/dist/types/interface/models/trigger-filter.model.d.ts +0 -0
- package/dist/types/interface/models/trigger-filter.model.js +0 -1
- package/dist/types/interface/models/webhook-action-log.model.d.ts +0 -22
- package/dist/types/interface/models/webhook-action-log.model.js +0 -9
- package/dist/types/interface/models/webhook-trigger-log.model.d.ts +0 -23
- package/dist/types/interface/models/webhook-trigger-log.model.js +0 -9
- package/dist/types/interface/models/workflow-execution-step.model.d.ts +0 -59
- package/dist/types/interface/models/workflow-execution-step.model.js +0 -12
- package/dist/types/interface/models/workflow-step-config.model.d.ts +0 -0
- package/dist/types/interface/models/workflow-step-config.model.js +0 -1
- package/dist/types/interface/models/workflow-step-data.model.d.ts +0 -0
- package/dist/types/interface/models/workflow-step-data.model.js +0 -1
- package/dist/types/interface/models/workflow-trigger-config.model.d.ts +0 -0
- package/dist/types/interface/models/workflow-trigger-config.model.js +0 -1
- package/dist/types/interface/models/workflow-webhook-action.model.d.ts +0 -27
- package/dist/types/interface/models/workflow-webhook-action.model.js +0 -2
- package/dist/types/interface/models/workflow-webhook-incoming-log.model.d.ts +0 -19
- package/dist/types/interface/models/workflow-webhook-incoming-log.model.js +0 -2
- package/dist/types/interface/models/workflow-webhook-outgoing-log.model.d.ts +0 -21
- package/dist/types/interface/models/workflow-webhook-outgoing-log.model.js +0 -2
- package/dist/types/interface/models/workflow-webhook-trigger-allowed-ip.model.d.ts +0 -10
- package/dist/types/interface/models/workflow-webhook-trigger-allowed-ip.model.js +0 -2
- package/dist/types/interface/models/workflow-webhook-trigger.model.d.ts +0 -20
- package/dist/types/interface/models/workflow-webhook-trigger.model.js +0 -2
- package/dist/typing-examples.d.ts +0 -1
- package/dist/typing-examples.js +0 -48
- package/dist/utils/__tests__/ip-address-reference.utils.test.d.ts +0 -0
- package/dist/utils/__tests__/ip-address-reference.utils.test.js +0 -1
- package/dist/utils/__tests__/reference-resolver.examples.d.ts +0 -0
- package/dist/utils/__tests__/reference-resolver.examples.js +0 -1
- package/dist/utils/alert.utils.d.ts +0 -35
- package/dist/utils/alert.utils.js +0 -138
- package/dist/utils/discord-webhook-log-formatter.utils.d.ts +0 -48
- package/dist/utils/discord-webhook-log-formatter.utils.js +0 -332
- package/dist/utils/import.utils.d.ts +0 -1
- package/dist/utils/import.utils.js +0 -7
- package/dist/utils/ip-address-reference.utils.d.ts +0 -0
- package/dist/utils/ip-address-reference.utils.js +0 -1
- package/dist/utils/json.utils.d.ts +0 -1
- package/dist/utils/json.utils.js +0 -13
- package/dist/utils/non-blocking-promise.utils.d.ts +0 -2
- package/dist/utils/non-blocking-promise.utils.js +0 -11
- /package/dist/types/interface/api/requests/{application-cron-task.admin.request.js → secret-access.request.js} +0 -0
- /package/dist/types/interface/api/requests/{application-cron-task.request.js → secret-public.request.js} +0 -0
- /package/dist/types/interface/api/requests/{application-event.admin.request.js → secret.request.js} +0 -0
- /package/dist/types/interface/api/{requests/application-event.request.js → responses/secret-access.response.js} +0 -0
- /package/dist/types/interface/api/{requests/application-log.admin.request.js → responses/secret-public.response.js} +0 -0
- /package/dist/types/interface/api/{requests/application-log.request.js → responses/secret.response.js} +0 -0
- /package/dist/types/interface/{api/requests/application-sentinel.admin.request.js → models/secret-access-ip-address.model.js} +0 -0
- /package/dist/types/interface/{api/requests/application-sentinel.request.js → models/secret-access-log.model.js} +0 -0
- /package/dist/types/interface/{api/requests/application-stats.admin.request.js → models/secret-access-secret.model.js} +0 -0
- /package/dist/types/interface/{api/requests/application-stats.request.js → models/secret-access.model.js} +0 -0
- /package/dist/types/interface/{api/requests/application-webhook-history.admin.request.js → models/secret-version.model.js} +0 -0
- /package/dist/types/interface/{api/requests/application-webhook-history.request.js → models/secret.model.js} +0 -0
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.loggerEndpointMiddleware = exports.CONTROLLER_FILE_ENDS_WITH = void 0;
|
|
7
|
-
const lodash_1 = require("lodash");
|
|
8
|
-
const context_middleware_1 = require("./context.middleware");
|
|
9
|
-
const types_1 = require("../types");
|
|
10
|
-
const net_1 = __importDefault(require("net"));
|
|
11
|
-
const import_utils_1 = require("../utils/import.utils");
|
|
12
|
-
exports.CONTROLLER_FILE_ENDS_WITH = `.controller${(0, import_utils_1.extensionFileToImport)()}`;
|
|
13
|
-
const loggerEndpointMiddleware = async (logger, req, res, next, callback) => {
|
|
14
|
-
res.locals.timer = {
|
|
15
|
-
start: new Date(),
|
|
16
|
-
startTime: process.hrtime(),
|
|
17
|
-
};
|
|
18
|
-
const requestId = (0, context_middleware_1.getRequestContext)().requestId;
|
|
19
|
-
res.on('close', async () => {
|
|
20
|
-
var _a;
|
|
21
|
-
try {
|
|
22
|
-
res.locals.timer.durationToClose = getDurationInMilliseconds(res.locals.timer.startTime);
|
|
23
|
-
if (!res.locals.shouldNotPublishLog) {
|
|
24
|
-
const ips = [];
|
|
25
|
-
const forwardedFor = req.headers['x-forwarded-for'];
|
|
26
|
-
if (forwardedFor) {
|
|
27
|
-
if (Array.isArray(forwardedFor)) {
|
|
28
|
-
ips.push(...forwardedFor);
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
ips.push(forwardedFor);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
if (req.socket.remoteAddress) {
|
|
35
|
-
ips.push(req.socket.remoteAddress);
|
|
36
|
-
}
|
|
37
|
-
if (req.ip) {
|
|
38
|
-
ips.push(req.ip);
|
|
39
|
-
}
|
|
40
|
-
await logger.log('', {
|
|
41
|
-
requestId,
|
|
42
|
-
context: 'API',
|
|
43
|
-
applicationLogEndpoint: {
|
|
44
|
-
responseHttpCode: res.statusCode,
|
|
45
|
-
responseTime: Math.round(res.locals.timer.durationToClose),
|
|
46
|
-
ip: (0, lodash_1.uniq)(ips).filter(net_1.default.isIP),
|
|
47
|
-
endpoint: res.locals.path || ((_a = req.route) === null || _a === void 0 ? void 0 : _a.path) || req.path,
|
|
48
|
-
controller: res.locals.controller || 'Unknown Controller',
|
|
49
|
-
method: types_1.APIMethod[req.method.toUpperCase()],
|
|
50
|
-
requestParams: req.params,
|
|
51
|
-
requestQuery: req.query,
|
|
52
|
-
requestBody: res.locals.shouldNotSaveRequestBody
|
|
53
|
-
? null
|
|
54
|
-
: req.body
|
|
55
|
-
? JSON.parse(JSON.stringify(req.body))
|
|
56
|
-
: null,
|
|
57
|
-
responseBody: res.locals.shouldNotSaveResponseBody
|
|
58
|
-
? null
|
|
59
|
-
: res.locals.responseBody
|
|
60
|
-
? JSON.parse(JSON.stringify(res.locals.responseBody))
|
|
61
|
-
: null,
|
|
62
|
-
},
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
try {
|
|
66
|
-
if (callback) {
|
|
67
|
-
await callback(req, res, next);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
catch (error) {
|
|
71
|
-
throw error;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
catch (error) {
|
|
75
|
-
logger.error(error);
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
next();
|
|
79
|
-
};
|
|
80
|
-
exports.loggerEndpointMiddleware = loggerEndpointMiddleware;
|
|
81
|
-
const getDurationInMilliseconds = (start) => {
|
|
82
|
-
const NS_PER_SEC = 1e9;
|
|
83
|
-
const NS_TO_MS = 1e6;
|
|
84
|
-
const diff = process.hrtime(start);
|
|
85
|
-
return (diff[0] * NS_PER_SEC + diff[1]) / NS_TO_MS;
|
|
86
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.loggerSetupMiddleware = void 0;
|
|
4
|
-
const loggerSetupMiddleware = async (req, res, next) => {
|
|
5
|
-
const originalJson = res.json;
|
|
6
|
-
const originalSend = res.send;
|
|
7
|
-
res.send = function (...args) {
|
|
8
|
-
return originalSend.apply(res, args);
|
|
9
|
-
};
|
|
10
|
-
res.json = function (...args) {
|
|
11
|
-
res.locals.responseBody = args[0];
|
|
12
|
-
return originalJson.apply(res, args);
|
|
13
|
-
};
|
|
14
|
-
next();
|
|
15
|
-
};
|
|
16
|
-
exports.loggerSetupMiddleware = loggerSetupMiddleware;
|
package/dist/models/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './logger.model';
|
package/dist/models/index.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
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("./logger.model"), exports);
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { APIMethod, ICreateApplicationLogBody, LogLevel } from '../types';
|
|
2
|
-
export type LogData = ICreateApplicationLogBody;
|
|
3
|
-
export type PayloadLog = {
|
|
4
|
-
context?: string | null;
|
|
5
|
-
scenario?: string | null;
|
|
6
|
-
requestId?: string | null;
|
|
7
|
-
data?: Record<string, unknown> | null;
|
|
8
|
-
applicationLogEndpoint?: {
|
|
9
|
-
controller: string;
|
|
10
|
-
endpoint: string;
|
|
11
|
-
ip: string[];
|
|
12
|
-
method: APIMethod;
|
|
13
|
-
responseTime: number;
|
|
14
|
-
responseHttpCode: number;
|
|
15
|
-
requestParams?: Record<string, string> | null;
|
|
16
|
-
requestQuery?: Record<string, string | string[]> | null;
|
|
17
|
-
requestBody?: Record<string, unknown> | string | null;
|
|
18
|
-
responseBody?: Record<string, unknown> | string | null;
|
|
19
|
-
};
|
|
20
|
-
applicationEvent?: {
|
|
21
|
-
event: string;
|
|
22
|
-
level: LogLevel;
|
|
23
|
-
message?: string | null;
|
|
24
|
-
data?: Record<string, unknown> | null;
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
type Options = {
|
|
28
|
-
shouldSaveStack?: boolean;
|
|
29
|
-
customerConsoleLogger?: (data: LogData) => void;
|
|
30
|
-
compact?: boolean;
|
|
31
|
-
};
|
|
32
|
-
export type PayloadSendLog = PayloadLog & {
|
|
33
|
-
level: LogLevel;
|
|
34
|
-
message: string;
|
|
35
|
-
stack?: string;
|
|
36
|
-
};
|
|
37
|
-
type PayloadConstructor = {
|
|
38
|
-
shouldDisableConsoleLogging?: boolean;
|
|
39
|
-
shouldDisableConsoleResponseBodyLogging?: boolean;
|
|
40
|
-
shouldDisableRemoteLogging?: boolean;
|
|
41
|
-
customConsoleLogger?: (data: LogData) => void;
|
|
42
|
-
customPublishLog?: (payload: LogData, options?: Options) => Promise<void>;
|
|
43
|
-
processId?: string;
|
|
44
|
-
};
|
|
45
|
-
export declare class Logger {
|
|
46
|
-
private shouldDisableConsoleLogging;
|
|
47
|
-
private shouldDisableRemoteLogging;
|
|
48
|
-
private shouldDisableConsoleResponseBodyLogging;
|
|
49
|
-
private customConsoleLogger?;
|
|
50
|
-
private customPublishLog?;
|
|
51
|
-
private processId;
|
|
52
|
-
constructor(payload: PayloadConstructor);
|
|
53
|
-
log(message: string, payload?: PayloadLog, options?: Options): Promise<void>;
|
|
54
|
-
debug(message: string, payload?: PayloadLog, options?: Omit<Options, 'shouldSaveStack'>): Promise<void>;
|
|
55
|
-
error(message: string | Error, payload?: PayloadLog, options?: Options): Promise<void>;
|
|
56
|
-
info(message: string, payload?: PayloadLog, options?: Options): Promise<void>;
|
|
57
|
-
warn(message: string, payload?: PayloadLog, options?: Options): Promise<void>;
|
|
58
|
-
private publishLog;
|
|
59
|
-
private console;
|
|
60
|
-
}
|
|
61
|
-
export {};
|
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.Logger = void 0;
|
|
7
|
-
const api_1 = require("../api");
|
|
8
|
-
const types_1 = require("../types");
|
|
9
|
-
const dayjs_1 = __importDefault(require("dayjs"));
|
|
10
|
-
const __1 = require("..");
|
|
11
|
-
const lodash_1 = require("lodash");
|
|
12
|
-
const alert_utils_1 = require("../utils/alert.utils");
|
|
13
|
-
const MAXIMUM_BODY_SIZE = 1024 * 1024 * 1024;
|
|
14
|
-
const MAXIMUM_FIELD_LENGTH = 255;
|
|
15
|
-
let chalk;
|
|
16
|
-
if (typeof window === 'undefined') {
|
|
17
|
-
chalk = require('chalk');
|
|
18
|
-
}
|
|
19
|
-
const INFO_LEVEL = {
|
|
20
|
-
ERROR: chalk === null || chalk === void 0 ? void 0 : chalk.red('ERROR'),
|
|
21
|
-
WARN: chalk === null || chalk === void 0 ? void 0 : chalk.bgYellow.black('WARN'),
|
|
22
|
-
INFO: chalk === null || chalk === void 0 ? void 0 : chalk.blueBright('INFO'),
|
|
23
|
-
DEBUG: chalk === null || chalk === void 0 ? void 0 : chalk.grey('DEBUG'),
|
|
24
|
-
LOG: chalk === null || chalk === void 0 ? void 0 : chalk.grey('LOG'),
|
|
25
|
-
};
|
|
26
|
-
class Logger {
|
|
27
|
-
constructor(payload) {
|
|
28
|
-
this.shouldDisableRemoteLogging = payload.shouldDisableRemoteLogging || false;
|
|
29
|
-
this.shouldDisableConsoleLogging = payload.shouldDisableConsoleLogging || false;
|
|
30
|
-
this.shouldDisableConsoleResponseBodyLogging =
|
|
31
|
-
payload.shouldDisableConsoleResponseBodyLogging || false;
|
|
32
|
-
this.processId = payload.processId || process.pid.toString();
|
|
33
|
-
this.customConsoleLogger = payload.customConsoleLogger;
|
|
34
|
-
this.customPublishLog = payload.customPublishLog;
|
|
35
|
-
}
|
|
36
|
-
async log(message, payload = {}, options) {
|
|
37
|
-
this.publishLog({ ...payload, message, level: types_1.LogLevel.LOG }, options);
|
|
38
|
-
}
|
|
39
|
-
async debug(message, payload = {}, options) {
|
|
40
|
-
this.publishLog({ ...payload, message, stack: new Error().stack, level: types_1.LogLevel.LOG }, options);
|
|
41
|
-
}
|
|
42
|
-
async error(message, payload = {}, options) {
|
|
43
|
-
if (message instanceof Error) {
|
|
44
|
-
this.publishLog({
|
|
45
|
-
...payload,
|
|
46
|
-
message: `${message.name} ${message.message}`,
|
|
47
|
-
stack: message.stack,
|
|
48
|
-
level: types_1.LogLevel.ERROR,
|
|
49
|
-
data: {
|
|
50
|
-
...payload.data,
|
|
51
|
-
errorName: message.name,
|
|
52
|
-
},
|
|
53
|
-
}, options);
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
this.publishLog({ ...payload, message, level: types_1.LogLevel.ERROR }, options);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
async info(message, payload = {}, options) {
|
|
60
|
-
this.publishLog({ ...payload, message, level: types_1.LogLevel.INFO }, options);
|
|
61
|
-
}
|
|
62
|
-
async warn(message, payload = {}, options) {
|
|
63
|
-
this.publishLog({ ...payload, message, level: types_1.LogLevel.WARN }, options);
|
|
64
|
-
}
|
|
65
|
-
async publishLog(payload, options) {
|
|
66
|
-
var _a, _b;
|
|
67
|
-
const log = {
|
|
68
|
-
...payload,
|
|
69
|
-
dateValue: new Date(),
|
|
70
|
-
processId: this.processId,
|
|
71
|
-
};
|
|
72
|
-
try {
|
|
73
|
-
this.console(log, options === null || options === void 0 ? void 0 : options.customerConsoleLogger);
|
|
74
|
-
if (this.customPublishLog) {
|
|
75
|
-
await this.customPublishLog(log, options);
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
const { applicationId, secretPublishToken } = __1.AbyssMonitorCore.getConfig();
|
|
79
|
-
if (!this.shouldDisableRemoteLogging && applicationId && secretPublishToken) {
|
|
80
|
-
const size = Buffer.byteLength(JSON.stringify(log));
|
|
81
|
-
const body = log;
|
|
82
|
-
let isBodyTruncated = false;
|
|
83
|
-
if (size >= MAXIMUM_BODY_SIZE) {
|
|
84
|
-
isBodyTruncated = true;
|
|
85
|
-
if ((_a = body.applicationLogEndpoint) === null || _a === void 0 ? void 0 : _a.requestBody) {
|
|
86
|
-
body.applicationLogEndpoint.requestBody = 'Payload Too Large';
|
|
87
|
-
}
|
|
88
|
-
if ((_b = body.applicationLogEndpoint) === null || _b === void 0 ? void 0 : _b.responseBody) {
|
|
89
|
-
body.applicationLogEndpoint.responseBody = 'Payload Too Large';
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
const newSize = Buffer.byteLength(JSON.stringify(body));
|
|
93
|
-
if (newSize >= MAXIMUM_BODY_SIZE) {
|
|
94
|
-
this.warn(`Unable to save log because payload is too big (more than 1Mo even after removing responseBody and requestBody)`, {
|
|
95
|
-
requestId: body.requestId
|
|
96
|
-
? (0, lodash_1.truncate)(body.requestId, { length: MAXIMUM_FIELD_LENGTH })
|
|
97
|
-
: undefined,
|
|
98
|
-
context: body.context
|
|
99
|
-
? (0, lodash_1.truncate)(body.context, { length: MAXIMUM_FIELD_LENGTH })
|
|
100
|
-
: undefined,
|
|
101
|
-
scenario: body.scenario
|
|
102
|
-
? (0, lodash_1.truncate)(body.scenario, { length: MAXIMUM_FIELD_LENGTH })
|
|
103
|
-
: undefined,
|
|
104
|
-
});
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
const applicationLog = await (0, api_1.createApplicationLog)({ applicationId }, { token: secretPublishToken }, body);
|
|
108
|
-
(0, __1.nonBlockingPromise)((async () => {
|
|
109
|
-
(0, alert_utils_1.sendLogAlert)({
|
|
110
|
-
...payload,
|
|
111
|
-
logData: log,
|
|
112
|
-
logger: this,
|
|
113
|
-
applicationLogId: applicationLog.data.applicationLog.id || '',
|
|
114
|
-
compact: options === null || options === void 0 ? void 0 : options.compact,
|
|
115
|
-
});
|
|
116
|
-
})(), this);
|
|
117
|
-
if (isBodyTruncated) {
|
|
118
|
-
this.warn(`Endpoint log ${applicationLog.data.applicationLog.id} has been truncated (requestBody & responseBody) because payload was too big (more than 1Mo)`, {
|
|
119
|
-
requestId: body.requestId
|
|
120
|
-
? (0, lodash_1.truncate)(body.requestId, { length: MAXIMUM_FIELD_LENGTH })
|
|
121
|
-
: undefined,
|
|
122
|
-
context: body.context
|
|
123
|
-
? (0, lodash_1.truncate)(body.context, { length: MAXIMUM_FIELD_LENGTH })
|
|
124
|
-
: undefined,
|
|
125
|
-
scenario: body.scenario
|
|
126
|
-
? (0, lodash_1.truncate)(body.scenario, { length: MAXIMUM_FIELD_LENGTH })
|
|
127
|
-
: undefined,
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
catch (error) {
|
|
134
|
-
console.error(`Unable to publish log. Error: ${error}`);
|
|
135
|
-
(0, alert_utils_1.sendLogAlert)({
|
|
136
|
-
...payload,
|
|
137
|
-
logData: log,
|
|
138
|
-
logger: this,
|
|
139
|
-
author: 'AbyssMonitor Logger',
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
console(data, customConsoleLogger) {
|
|
144
|
-
if (this.shouldDisableConsoleLogging) {
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
if (customConsoleLogger) {
|
|
148
|
-
customConsoleLogger(data);
|
|
149
|
-
}
|
|
150
|
-
else if (this.customConsoleLogger) {
|
|
151
|
-
this.customConsoleLogger(data);
|
|
152
|
-
}
|
|
153
|
-
else if (data.applicationLogEndpoint) {
|
|
154
|
-
let message = `${chalk.grey((0, dayjs_1.default)().format('DD/MM/YYYY HH:mm:ss'))} | ${chalk.bgBlueBright(' API ')} | `;
|
|
155
|
-
message += `${chalk.grey(data.requestId)} | ${chalk.greenBright(types_1.APIMethod[data.applicationLogEndpoint.method])} | ${data.applicationLogEndpoint.controller} ${data.applicationLogEndpoint.endpoint} | `;
|
|
156
|
-
if (data.applicationLogEndpoint.responseHttpCode >= 100 &&
|
|
157
|
-
data.applicationLogEndpoint.responseHttpCode <= 199) {
|
|
158
|
-
message += `${chalk.blue(data.applicationLogEndpoint.responseHttpCode)}`;
|
|
159
|
-
}
|
|
160
|
-
else if (data.applicationLogEndpoint.responseHttpCode >= 200 &&
|
|
161
|
-
data.applicationLogEndpoint.responseHttpCode <= 299) {
|
|
162
|
-
message += `${chalk.green(data.applicationLogEndpoint.responseHttpCode)}`;
|
|
163
|
-
}
|
|
164
|
-
else if (data.applicationLogEndpoint.responseHttpCode >= 300 &&
|
|
165
|
-
data.applicationLogEndpoint.responseHttpCode <= 399) {
|
|
166
|
-
message += `${chalk.magenta(data.applicationLogEndpoint.responseHttpCode)}`;
|
|
167
|
-
}
|
|
168
|
-
else if (data.applicationLogEndpoint.responseHttpCode >= 400 &&
|
|
169
|
-
data.applicationLogEndpoint.responseHttpCode <= 499) {
|
|
170
|
-
message += `${chalk.yellow(data.applicationLogEndpoint.responseHttpCode)}`;
|
|
171
|
-
}
|
|
172
|
-
else if (data.applicationLogEndpoint.responseHttpCode >= 500 &&
|
|
173
|
-
data.applicationLogEndpoint.responseHttpCode <= 599) {
|
|
174
|
-
message += `${chalk.red(data.applicationLogEndpoint.responseHttpCode)}`;
|
|
175
|
-
}
|
|
176
|
-
else {
|
|
177
|
-
message += `${chalk.bgCyanBright.black(data.applicationLogEndpoint.responseHttpCode)}`;
|
|
178
|
-
}
|
|
179
|
-
if (data.applicationLogEndpoint.responseTime < 50) {
|
|
180
|
-
message += ` | ${chalk.greenBright(data.applicationLogEndpoint.responseTime, 'ms')} | `;
|
|
181
|
-
}
|
|
182
|
-
else if (data.applicationLogEndpoint.responseTime < 150) {
|
|
183
|
-
message += ` | ${chalk.yellow(data.applicationLogEndpoint.responseTime, 'ms')} | `;
|
|
184
|
-
}
|
|
185
|
-
else {
|
|
186
|
-
message += ` | ${chalk.red(data.applicationLogEndpoint.responseTime, 'ms')} | `;
|
|
187
|
-
}
|
|
188
|
-
message += `${(data.applicationLogEndpoint.ip || []).join(' ')} | `;
|
|
189
|
-
if (!this.shouldDisableConsoleResponseBodyLogging &&
|
|
190
|
-
(data.applicationLogEndpoint.responseHttpCode < 200 ||
|
|
191
|
-
data.applicationLogEndpoint.responseHttpCode > 399)) {
|
|
192
|
-
message += `${JSON.stringify(data.applicationLogEndpoint.responseBody)}`;
|
|
193
|
-
}
|
|
194
|
-
console.log(message);
|
|
195
|
-
}
|
|
196
|
-
else {
|
|
197
|
-
console.log(`${chalk.grey((0, dayjs_1.default)().format('DD/MM/YYYY HH:mm:ss'))} | ${INFO_LEVEL[types_1.LogLevel[data.level]]} | ${data.processId}${data.requestId ? ` | ${data.requestId}` : ''}${data.context ? ` | ${data.context}` : ''} | ${data.message || data.stack} `);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
exports.Logger = Logger;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { Logger, ApplicationStatsType } from '..';
|
|
3
|
-
type StartOptions = {
|
|
4
|
-
interval?: number;
|
|
5
|
-
customCallback?: (values: {
|
|
6
|
-
type: ApplicationStatsType;
|
|
7
|
-
dateValue: Date;
|
|
8
|
-
processId: string;
|
|
9
|
-
value: number;
|
|
10
|
-
percentValue: number;
|
|
11
|
-
}[]) => Promise<void>;
|
|
12
|
-
logger?: Logger;
|
|
13
|
-
processId?: string;
|
|
14
|
-
};
|
|
15
|
-
export declare class StatsPublisher {
|
|
16
|
-
static interval: NodeJS.Timeout | null;
|
|
17
|
-
static start(options?: StartOptions): void;
|
|
18
|
-
static stop(): void;
|
|
19
|
-
}
|
|
20
|
-
export {};
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.StatsPublisher = void 0;
|
|
7
|
-
const axios_1 = require("axios");
|
|
8
|
-
const __1 = require("..");
|
|
9
|
-
const node_os_utils_1 = __importDefault(require("node-os-utils"));
|
|
10
|
-
const INTERVAL_BETWEEN_STATS_PUBLISH = 30000;
|
|
11
|
-
class StatsPublisher {
|
|
12
|
-
static start(options) {
|
|
13
|
-
if (typeof window !== 'undefined') {
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
const si = require('systeminformation');
|
|
17
|
-
const checkDiskSpace = require('check-disk-space').default;
|
|
18
|
-
const interval = setInterval(async () => {
|
|
19
|
-
var _a, _b, _c, _d, _e;
|
|
20
|
-
try {
|
|
21
|
-
const devices = await si.blockDevices();
|
|
22
|
-
const dateValue = new Date();
|
|
23
|
-
const [cpuUsage, cpuSpeed, cpu, { usedMemMb, totalMemMb }, ...devicesSpace] = await Promise.all([
|
|
24
|
-
node_os_utils_1.default.cpu.usage(),
|
|
25
|
-
si.cpuCurrentSpeed(),
|
|
26
|
-
si.cpu(),
|
|
27
|
-
node_os_utils_1.default.mem.used(),
|
|
28
|
-
...devices.map((device) => checkDiskSpace(device.mount)),
|
|
29
|
-
]);
|
|
30
|
-
const totalDisk = devicesSpace.reduce((acc, drive) => acc + drive.size, 0);
|
|
31
|
-
const totalDiskFree = devicesSpace.reduce((acc, drive) => acc + drive.free, 0);
|
|
32
|
-
const totalDiskUSage = totalDisk - totalDiskFree;
|
|
33
|
-
const totalDiskUSagePerCent = (totalDiskUSage / totalDisk) * 100 || 0;
|
|
34
|
-
const payload = {
|
|
35
|
-
cpuUsage: (cpuSpeed.avg * (cpu.cores || 1) * 1000 * 1000 * 1000 * cpuUsage) / 100,
|
|
36
|
-
cpuPercentUsage: cpuUsage,
|
|
37
|
-
ramUsage: usedMemMb * 1024 * 1024,
|
|
38
|
-
ramPercentUsage: ((usedMemMb * 1024 * 1024) / (totalMemMb * 1024 * 1024)) * 100,
|
|
39
|
-
diskUsage: totalDiskUSage,
|
|
40
|
-
diskPercentUsage: totalDiskUSagePerCent,
|
|
41
|
-
};
|
|
42
|
-
const stats = [
|
|
43
|
-
{
|
|
44
|
-
type: __1.ApplicationStatsType.CPU_USAGE,
|
|
45
|
-
dateValue,
|
|
46
|
-
value: payload.cpuUsage,
|
|
47
|
-
percentValue: payload.cpuPercentUsage,
|
|
48
|
-
processId: (options === null || options === void 0 ? void 0 : options.processId) || process.pid.toString(),
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
type: __1.ApplicationStatsType.RAM_USAGE,
|
|
52
|
-
dateValue,
|
|
53
|
-
value: payload.ramUsage,
|
|
54
|
-
percentValue: payload.ramPercentUsage,
|
|
55
|
-
processId: (options === null || options === void 0 ? void 0 : options.processId) || process.pid.toString(),
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
type: __1.ApplicationStatsType.DISK_USAGE,
|
|
59
|
-
dateValue,
|
|
60
|
-
value: payload.diskUsage,
|
|
61
|
-
percentValue: payload.diskPercentUsage,
|
|
62
|
-
processId: (options === null || options === void 0 ? void 0 : options.processId) || process.pid.toString(),
|
|
63
|
-
},
|
|
64
|
-
];
|
|
65
|
-
if (options === null || options === void 0 ? void 0 : options.customCallback) {
|
|
66
|
-
await options.customCallback(stats);
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
const applicationId = __1.AbyssMonitorCore.getConfig().applicationId;
|
|
70
|
-
const secretPublishToken = __1.AbyssMonitorCore.getConfig().secretPublishToken;
|
|
71
|
-
if (!applicationId) {
|
|
72
|
-
(_a = options === null || options === void 0 ? void 0 : options.logger) === null || _a === void 0 ? void 0 : _a.warn(`No applicationId provided on AbyssMonitorCore. Skipping publish stats`);
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
if (!secretPublishToken) {
|
|
76
|
-
(_b = options === null || options === void 0 ? void 0 : options.logger) === null || _b === void 0 ? void 0 : _b.warn(`No secretPublishToken provided on AbyssMonitorCore. Skipping publish stats`);
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
await (0, __1.createApplicationStats)({ applicationId }, { token: secretPublishToken }, { stats: stats });
|
|
80
|
-
await (0, __1.sendStatsAlert)({
|
|
81
|
-
...payload,
|
|
82
|
-
logger: options === null || options === void 0 ? void 0 : options.logger,
|
|
83
|
-
statsData: {
|
|
84
|
-
cpu: { percentValue: payload.cpuPercentUsage, value: payload.cpuUsage },
|
|
85
|
-
ram: { percentValue: payload.ramPercentUsage, value: payload.ramUsage },
|
|
86
|
-
disk: { percentValue: payload.diskPercentUsage, value: payload.diskUsage },
|
|
87
|
-
},
|
|
88
|
-
processId: (options === null || options === void 0 ? void 0 : options.processId) || process.pid.toString(),
|
|
89
|
-
dateValue,
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
catch (error) {
|
|
94
|
-
console.log(error);
|
|
95
|
-
(_c = options === null || options === void 0 ? void 0 : options.logger) === null || _c === void 0 ? void 0 : _c.error(`Failed to publish stats. Error ${error}`, { data: { error } });
|
|
96
|
-
if ((0, axios_1.isAxiosError)(error) && ((_d = error.response) === null || _d === void 0 ? void 0 : _d.status) === 401) {
|
|
97
|
-
(_e = options === null || options === void 0 ? void 0 : options.logger) === null || _e === void 0 ? void 0 : _e.warn(`Unauthorized to publish stats, disabling stats publisher.`);
|
|
98
|
-
this.stop();
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}, (options === null || options === void 0 ? void 0 : options.interval) && (options === null || options === void 0 ? void 0 : options.interval) >= INTERVAL_BETWEEN_STATS_PUBLISH
|
|
102
|
-
? options === null || options === void 0 ? void 0 : options.interval
|
|
103
|
-
: INTERVAL_BETWEEN_STATS_PUBLISH);
|
|
104
|
-
StatsPublisher.interval = interval;
|
|
105
|
-
}
|
|
106
|
-
static stop() {
|
|
107
|
-
if (StatsPublisher.interval) {
|
|
108
|
-
clearInterval(StatsPublisher.interval);
|
|
109
|
-
}
|
|
110
|
-
StatsPublisher.interval = null;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
exports.StatsPublisher = StatsPublisher;
|
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.APIMethod = void 0;
|
|
4
|
-
var APIMethod;
|
|
5
|
-
(function (APIMethod) {
|
|
6
|
-
APIMethod[APIMethod["GET"] = 1] = "GET";
|
|
7
|
-
APIMethod[APIMethod["POST"] = 2] = "POST";
|
|
8
|
-
APIMethod[APIMethod["DELETE"] = 3] = "DELETE";
|
|
9
|
-
APIMethod[APIMethod["PUT"] = 4] = "PUT";
|
|
10
|
-
APIMethod[APIMethod["PATCH"] = 5] = "PATCH";
|
|
11
|
-
})(APIMethod || (exports.APIMethod = APIMethod = {}));
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ApplicationAlertType = void 0;
|
|
4
|
-
var ApplicationAlertType;
|
|
5
|
-
(function (ApplicationAlertType) {
|
|
6
|
-
ApplicationAlertType["CRON_TASK"] = "CRON_TASK";
|
|
7
|
-
ApplicationAlertType["LOG"] = "LOG";
|
|
8
|
-
ApplicationAlertType["STATS"] = "STATS";
|
|
9
|
-
})(ApplicationAlertType || (exports.ApplicationAlertType = ApplicationAlertType = {}));
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ApplicationSentinelType = void 0;
|
|
4
|
-
var ApplicationSentinelType;
|
|
5
|
-
(function (ApplicationSentinelType) {
|
|
6
|
-
ApplicationSentinelType["PING"] = "PING";
|
|
7
|
-
ApplicationSentinelType["HTTP"] = "HTTP";
|
|
8
|
-
ApplicationSentinelType["TCP"] = "TCP";
|
|
9
|
-
})(ApplicationSentinelType || (exports.ApplicationSentinelType = ApplicationSentinelType = {}));
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ApplicationStatsType = void 0;
|
|
4
|
-
var ApplicationStatsType;
|
|
5
|
-
(function (ApplicationStatsType) {
|
|
6
|
-
ApplicationStatsType[ApplicationStatsType["CPU_USAGE"] = 10] = "CPU_USAGE";
|
|
7
|
-
ApplicationStatsType[ApplicationStatsType["RAM_USAGE"] = 20] = "RAM_USAGE";
|
|
8
|
-
ApplicationStatsType[ApplicationStatsType["DISK_USAGE"] = 30] = "DISK_USAGE";
|
|
9
|
-
})(ApplicationStatsType || (exports.ApplicationStatsType = ApplicationStatsType = {}));
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ApplicationWebhookScope = void 0;
|
|
4
|
-
var ApplicationWebhookScope;
|
|
5
|
-
(function (ApplicationWebhookScope) {
|
|
6
|
-
ApplicationWebhookScope["EVENT"] = "EVENT";
|
|
7
|
-
ApplicationWebhookScope["SENTINEL"] = "SENTINEL";
|
|
8
|
-
})(ApplicationWebhookScope || (exports.ApplicationWebhookScope = ApplicationWebhookScope = {}));
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LogLevel = void 0;
|
|
4
|
-
var LogLevel;
|
|
5
|
-
(function (LogLevel) {
|
|
6
|
-
LogLevel[LogLevel["ERROR"] = 1] = "ERROR";
|
|
7
|
-
LogLevel[LogLevel["WARN"] = 2] = "WARN";
|
|
8
|
-
LogLevel[LogLevel["INFO"] = 3] = "INFO";
|
|
9
|
-
LogLevel[LogLevel["LOG"] = 4] = "LOG";
|
|
10
|
-
})(LogLevel || (exports.LogLevel = LogLevel = {}));
|