@abyss-project/monitor 1.0.2 → 1.0.4
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/application-cron-task.admin.api.d.ts +10 -10
- package/dist/api/application-cron-task.admin.api.js +40 -40
- package/dist/api/application-cron-task.api.d.ts +10 -10
- package/dist/api/application-cron-task.api.js +40 -40
- package/dist/api/application-log.admin.api.d.ts +3 -3
- package/dist/api/application-log.admin.api.js +12 -12
- package/dist/api/application-log.api.d.ts +4 -4
- package/dist/api/application-log.api.js +16 -16
- package/dist/api/application-stats.admin.api.d.ts +3 -3
- package/dist/api/application-stats.admin.api.js +12 -12
- package/dist/api/application-stats.api.d.ts +4 -4
- package/dist/api/application-stats.api.js +16 -16
- package/dist/api/application-store.admin.api.d.ts +6 -6
- package/dist/api/application-store.admin.api.js +24 -24
- package/dist/api/application-store.api.d.ts +6 -6
- package/dist/api/application-store.api.js +24 -24
- package/dist/api/application-store.public.api.d.ts +3 -3
- package/dist/api/application-store.public.api.js +12 -12
- package/dist/api/application.admin.api.d.ts +7 -7
- package/dist/api/application.admin.api.js +28 -28
- package/dist/api/application.api.d.ts +10 -9
- package/dist/api/application.api.js +40 -36
- package/dist/api/index.d.ts +12 -12
- package/dist/api/index.js +28 -24
- package/dist/api/monitor.api.d.ts +2 -2
- package/dist/api/monitor.api.js +8 -8
- package/dist/frameworks/express/decorators.d.ts +52 -52
- package/dist/frameworks/express/decorators.js +163 -163
- package/dist/frameworks/express/index.d.ts +16 -16
- package/dist/frameworks/express/index.js +170 -166
- package/dist/frameworks/express/metadata.d.ts +9 -9
- package/dist/frameworks/express/metadata.js +12 -12
- package/dist/frameworks/index.d.ts +1 -1
- package/dist/frameworks/index.js +17 -13
- package/dist/index.d.ts +46 -46
- package/dist/index.js +105 -101
- package/dist/middlewares/context.middleware.d.ts +12 -12
- package/dist/middlewares/context.middleware.js +39 -39
- package/dist/middlewares/index.d.ts +3 -3
- package/dist/middlewares/index.js +19 -15
- package/dist/middlewares/logger-endpoint.middleware.d.ts +5 -5
- package/dist/middlewares/logger-endpoint.middleware.js +75 -75
- package/dist/middlewares/logger-setup.middleware.d.ts +5 -5
- package/dist/middlewares/logger-setup.middleware.js +16 -16
- package/dist/models/index.d.ts +1 -1
- package/dist/models/index.js +17 -13
- package/dist/models/logger.model.d.ts +55 -55
- package/dist/models/logger.model.js +201 -201
- package/dist/models/stats-publisher.model.d.ts +20 -20
- package/dist/models/stats-publisher.model.js +113 -113
- package/dist/types/enum/api-error.enum.d.ts +20 -20
- package/dist/types/enum/api-error.enum.js +25 -25
- package/dist/types/enum/api-method.enum.d.ts +7 -7
- package/dist/types/enum/api-method.enum.js +11 -11
- package/dist/types/enum/application-alert-type.enum.d.ts +5 -5
- package/dist/types/enum/application-alert-type.enum.js +9 -9
- package/dist/types/enum/application-stats-type.enum.d.ts +5 -5
- package/dist/types/enum/application-stats-type.enum.js +9 -9
- package/dist/types/enum/index.d.ts +7 -7
- package/dist/types/enum/index.js +23 -19
- package/dist/types/enum/log-level.enum.d.ts +6 -6
- package/dist/types/enum/log-level.enum.js +10 -10
- package/dist/types/enum/log-scenario.enum.d.ts +5 -5
- package/dist/types/enum/log-scenario.enum.js +9 -9
- package/dist/types/enum/webhook-type.enum.d.ts +3 -3
- package/dist/types/enum/webhook-type.enum.js +7 -7
- package/dist/types/index.d.ts +18 -18
- package/dist/types/index.js +18 -14
- package/dist/types/interface/api/index.d.ts +27 -27
- package/dist/types/interface/api/index.js +43 -39
- package/dist/types/interface/api/requests/application-cron-task.admin.request.d.ts +50 -51
- package/dist/types/interface/api/requests/application-cron-task.admin.request.js +2 -2
- package/dist/types/interface/api/requests/application-cron-task.request.d.ts +61 -62
- package/dist/types/interface/api/requests/application-cron-task.request.js +2 -2
- package/dist/types/interface/api/requests/application-log.admin.request.d.ts +19 -20
- package/dist/types/interface/api/requests/application-log.admin.request.js +2 -2
- package/dist/types/interface/api/requests/application-log.request.d.ts +53 -54
- package/dist/types/interface/api/requests/application-log.request.js +2 -2
- package/dist/types/interface/api/requests/application-stats.admin.request.d.ts +13 -14
- package/dist/types/interface/api/requests/application-stats.admin.request.js +2 -2
- package/dist/types/interface/api/requests/application-stats.request.d.ts +31 -32
- package/dist/types/interface/api/requests/application-stats.request.js +2 -2
- package/dist/types/interface/api/requests/application-store.admin.request.d.ts +34 -35
- package/dist/types/interface/api/requests/application-store.admin.request.js +2 -2
- package/dist/types/interface/api/requests/application-store.public.request.d.ts +8 -9
- package/dist/types/interface/api/requests/application-store.public.request.js +2 -2
- package/dist/types/interface/api/requests/application-store.request.d.ts +39 -40
- package/dist/types/interface/api/requests/application-store.request.js +2 -2
- package/dist/types/interface/api/requests/application.admin.request.d.ts +18 -19
- package/dist/types/interface/api/requests/application.admin.request.js +2 -2
- package/dist/types/interface/api/requests/application.request.d.ts +35 -33
- package/dist/types/interface/api/requests/application.request.js +2 -2
- package/dist/types/interface/api/responses/application-cron-task.admin.response.d.ts +30 -30
- package/dist/types/interface/api/responses/application-cron-task.admin.response.js +2 -2
- package/dist/types/interface/api/responses/application-cron-task.response.d.ts +30 -30
- package/dist/types/interface/api/responses/application-cron-task.response.js +2 -2
- package/dist/types/interface/api/responses/application-log.admin.response.d.ts +10 -10
- package/dist/types/interface/api/responses/application-log.admin.response.js +2 -2
- package/dist/types/interface/api/responses/application-log.response.d.ts +10 -10
- package/dist/types/interface/api/responses/application-log.response.js +2 -2
- package/dist/types/interface/api/responses/application-stats.admin.response.d.ts +6 -6
- package/dist/types/interface/api/responses/application-stats.admin.response.js +2 -2
- package/dist/types/interface/api/responses/application-stats.response.d.ts +10 -10
- package/dist/types/interface/api/responses/application-stats.response.js +2 -2
- package/dist/types/interface/api/responses/application-store.admin.response.d.ts +17 -17
- package/dist/types/interface/api/responses/application-store.admin.response.js +2 -2
- package/dist/types/interface/api/responses/application-store.public.response.d.ts +21 -21
- package/dist/types/interface/api/responses/application-store.public.response.js +2 -2
- package/dist/types/interface/api/responses/application-store.response.d.ts +17 -17
- package/dist/types/interface/api/responses/application-store.response.js +2 -2
- package/dist/types/interface/api/responses/application.admin.response.d.ts +33 -33
- package/dist/types/interface/api/responses/application.admin.response.js +2 -2
- package/dist/types/interface/api/responses/application.response.d.ts +129 -121
- package/dist/types/interface/api/responses/application.response.js +2 -2
- package/dist/types/interface/api/responses/monitor.response.d.ts +7 -7
- package/dist/types/interface/api/responses/monitor.response.js +2 -2
- package/dist/types/interface/api/type-message/api-error.d.ts +8 -8
- package/dist/types/interface/api/type-message/api-error.js +2 -2
- package/dist/types/interface/api/type-message/base-order.d.ts +4 -4
- package/dist/types/interface/api/type-message/base-order.js +2 -2
- package/dist/types/interface/api/type-message/base-paginate.d.ts +10 -10
- package/dist/types/interface/api/type-message/base-paginate.js +2 -2
- package/dist/types/interface/api/type-message/response.d.ts +5 -5
- package/dist/types/interface/api/type-message/response.js +2 -2
- package/dist/types/interface/index.d.ts +9 -8
- package/dist/types/interface/index.js +25 -20
- package/dist/types/interface/models/application-cron-task-history.model.d.ts +11 -11
- package/dist/types/interface/models/application-cron-task-history.model.js +2 -2
- package/dist/types/interface/models/application-cron-task.model.d.ts +14 -14
- package/dist/types/interface/models/application-cron-task.model.js +2 -2
- package/dist/types/interface/models/application-event.model.d.ts +18 -0
- package/dist/types/interface/{api/requests/abyss.admin.request.js → models/application-event.model.js} +2 -2
- package/dist/types/interface/models/application-log-endpoint.model.d.ts +20 -20
- package/dist/types/interface/models/application-log-endpoint.model.js +2 -2
- package/dist/types/interface/models/application-log.model.d.ts +23 -21
- package/dist/types/interface/models/application-log.model.js +2 -2
- package/dist/types/interface/models/application-stats.model.d.ts +14 -14
- package/dist/types/interface/models/application-stats.model.js +2 -2
- package/dist/types/interface/models/application-store-entry.model.d.ts +14 -14
- package/dist/types/interface/models/application-store-entry.model.js +2 -2
- package/dist/types/interface/models/application.model.d.ts +17 -15
- package/dist/types/interface/models/application.model.js +2 -2
- package/dist/utils/alert.utils.d.ts +35 -35
- package/dist/utils/alert.utils.js +138 -134
- package/dist/utils/discord-webhook-log-formatter.utils.d.ts +42 -42
- package/dist/utils/discord-webhook-log-formatter.utils.js +319 -319
- package/dist/utils/error.utils.d.ts +15 -15
- package/dist/utils/error.utils.js +24 -24
- package/dist/utils/import.utils.d.ts +1 -1
- package/dist/utils/import.utils.js +7 -7
- package/dist/utils/index.d.ts +5 -5
- package/dist/utils/index.js +21 -17
- package/dist/utils/json.utils.d.ts +1 -1
- package/dist/utils/json.utils.js +13 -13
- package/dist/utils/non-blocking-promise.utils.d.ts +2 -2
- package/dist/utils/non-blocking-promise.utils.js +11 -11
- package/package.json +5 -5
- package/dist/api/abyss.admin.api.d.ts +0 -2
- package/dist/api/abyss.admin.api.js +0 -8
- package/dist/api/application-store-entry.admin.api.d.ts +0 -6
- package/dist/api/application-store-entry.admin.api.js +0 -24
- package/dist/api/application-store-entry.api.d.ts +0 -6
- package/dist/api/application-store-entry.api.js +0 -24
- package/dist/api/application-store-entry.public.api.d.ts +0 -3
- package/dist/api/application-store-entry.public.api.js +0 -12
- package/dist/api/logger.admin.api.d.ts +0 -3
- package/dist/api/logger.admin.api.js +0 -14
- package/dist/api/user-application-alert.admin.api.d.ts +0 -7
- package/dist/api/user-application-alert.admin.api.js +0 -28
- package/dist/api/user-application-alert.api.d.ts +0 -7
- package/dist/api/user-application-alert.api.js +0 -28
- package/dist/api/user-application-cron-task.admin.api.d.ts +0 -9
- package/dist/api/user-application-cron-task.admin.api.js +0 -36
- package/dist/api/user-application-cron-task.api.d.ts +0 -9
- package/dist/api/user-application-cron-task.api.js +0 -36
- package/dist/api/user-application-log.admin.api.d.ts +0 -3
- package/dist/api/user-application-log.admin.api.js +0 -12
- package/dist/api/user-application-log.api.d.ts +0 -4
- package/dist/api/user-application-log.api.js +0 -16
- package/dist/api/user-application-stats.admin.api.d.ts +0 -3
- package/dist/api/user-application-stats.admin.api.js +0 -12
- package/dist/api/user-application-stats.api.d.ts +0 -4
- package/dist/api/user-application-stats.api.js +0 -16
- package/dist/api/user-application.admin.api.d.ts +0 -6
- package/dist/api/user-application.admin.api.js +0 -24
- package/dist/api/user-application.api.d.ts +0 -10
- package/dist/api/user-application.api.js +0 -40
- package/dist/api/user.admin.api.d.ts +0 -5
- package/dist/api/user.admin.api.js +0 -23
- package/dist/api/user.api.d.ts +0 -4
- package/dist/api/user.api.js +0 -17
- package/dist/consts.d.ts +0 -2
- package/dist/consts.js +0 -5
- package/dist/types/enum/log-type.enum.d.ts +0 -6
- package/dist/types/enum/log-type.enum.js +0 -10
- package/dist/types/enum/user-application-alert-type.enum.d.ts +0 -5
- package/dist/types/enum/user-application-alert-type.enum.js +0 -9
- package/dist/types/enum/user-application-stats-type.enum.d.ts +0 -5
- package/dist/types/enum/user-application-stats-type.enum.js +0 -9
- package/dist/types/interface/api/requests/abyss.admin.request.d.ts +0 -4
- package/dist/types/interface/api/requests/logger.admin.request.d.ts +0 -8
- package/dist/types/interface/api/requests/logger.admin.request.js +0 -2
- package/dist/types/interface/api/requests/user-application-alert.admin.request.d.ts +0 -44
- package/dist/types/interface/api/requests/user-application-alert.admin.request.js +0 -2
- package/dist/types/interface/api/requests/user-application-alert.request.d.ts +0 -50
- package/dist/types/interface/api/requests/user-application-alert.request.js +0 -2
- package/dist/types/interface/api/requests/user-application-cron-task.admin.request.d.ts +0 -48
- package/dist/types/interface/api/requests/user-application-cron-task.admin.request.js +0 -2
- package/dist/types/interface/api/requests/user-application-cron-task.request.d.ts +0 -58
- package/dist/types/interface/api/requests/user-application-cron-task.request.js +0 -2
- package/dist/types/interface/api/requests/user-application-log.admin.request.d.ts +0 -20
- package/dist/types/interface/api/requests/user-application-log.admin.request.js +0 -2
- package/dist/types/interface/api/requests/user-application-log.request.d.ts +0 -51
- package/dist/types/interface/api/requests/user-application-log.request.js +0 -2
- package/dist/types/interface/api/requests/user-application-stats.admin.request.d.ts +0 -14
- package/dist/types/interface/api/requests/user-application-stats.admin.request.js +0 -2
- package/dist/types/interface/api/requests/user-application-stats.request.d.ts +0 -29
- package/dist/types/interface/api/requests/user-application-stats.request.js +0 -2
- package/dist/types/interface/api/requests/user-application.admin.request.d.ts +0 -15
- package/dist/types/interface/api/requests/user-application.admin.request.js +0 -2
- package/dist/types/interface/api/requests/user-application.request.d.ts +0 -35
- package/dist/types/interface/api/requests/user-application.request.js +0 -2
- package/dist/types/interface/api/requests/user.admin.request.d.ts +0 -18
- package/dist/types/interface/api/requests/user.admin.request.js +0 -2
- package/dist/types/interface/api/requests/user.request.d.ts +0 -3
- package/dist/types/interface/api/requests/user.request.js +0 -2
- package/dist/types/interface/api/responses/abyss.admin.response.d.ts +0 -6
- package/dist/types/interface/api/responses/abyss.admin.response.js +0 -2
- package/dist/types/interface/api/responses/logger.admin.response.d.ts +0 -7
- package/dist/types/interface/api/responses/logger.admin.response.js +0 -2
- package/dist/types/interface/api/responses/user-application-alert.admin.response.d.ts +0 -22
- package/dist/types/interface/api/responses/user-application-alert.admin.response.js +0 -2
- package/dist/types/interface/api/responses/user-application-alert.response.d.ts +0 -22
- package/dist/types/interface/api/responses/user-application-alert.response.js +0 -2
- package/dist/types/interface/api/responses/user-application-cron-task.admin.response.d.ts +0 -27
- package/dist/types/interface/api/responses/user-application-cron-task.admin.response.js +0 -2
- package/dist/types/interface/api/responses/user-application-cron-task.response.d.ts +0 -27
- package/dist/types/interface/api/responses/user-application-cron-task.response.js +0 -2
- package/dist/types/interface/api/responses/user-application-log.admin.response.d.ts +0 -11
- package/dist/types/interface/api/responses/user-application-log.admin.response.js +0 -2
- package/dist/types/interface/api/responses/user-application-log.response.d.ts +0 -11
- package/dist/types/interface/api/responses/user-application-log.response.js +0 -2
- package/dist/types/interface/api/responses/user-application-stats.admin.response.d.ts +0 -7
- package/dist/types/interface/api/responses/user-application-stats.admin.response.js +0 -2
- package/dist/types/interface/api/responses/user-application-stats.response.d.ts +0 -11
- package/dist/types/interface/api/responses/user-application-stats.response.js +0 -2
- package/dist/types/interface/api/responses/user-application.admin.response.d.ts +0 -17
- package/dist/types/interface/api/responses/user-application.admin.response.js +0 -2
- package/dist/types/interface/api/responses/user-application.response.d.ts +0 -120
- package/dist/types/interface/api/responses/user-application.response.js +0 -2
- package/dist/types/interface/api/responses/user.admin.response.d.ts +0 -15
- package/dist/types/interface/api/responses/user.admin.response.js +0 -2
- package/dist/types/interface/api/responses/user.response.d.ts +0 -13
- package/dist/types/interface/api/responses/user.response.js +0 -2
- package/dist/types/interface/models/cron-task-history.model.d.ts +0 -12
- package/dist/types/interface/models/cron-task-history.model.js +0 -2
- package/dist/types/interface/models/cron-task.model.d.ts +0 -13
- package/dist/types/interface/models/cron-task.model.js +0 -2
- package/dist/types/interface/models/log-console.model.d.ts +0 -17
- package/dist/types/interface/models/log-console.model.js +0 -2
- package/dist/types/interface/models/log-endpoint.model.d.ts +0 -22
- package/dist/types/interface/models/log-endpoint.model.js +0 -2
- package/dist/types/interface/models/user-application-alert.model.d.ts +0 -44
- package/dist/types/interface/models/user-application-alert.model.js +0 -2
- package/dist/types/interface/models/user-application-cron-task-history.model.d.ts +0 -11
- package/dist/types/interface/models/user-application-cron-task-history.model.js +0 -2
- package/dist/types/interface/models/user-application-cron-task.model.d.ts +0 -14
- package/dist/types/interface/models/user-application-cron-task.model.js +0 -2
- package/dist/types/interface/models/user-application-log-endpoint.model.d.ts +0 -20
- package/dist/types/interface/models/user-application-log-endpoint.model.js +0 -2
- package/dist/types/interface/models/user-application-log.model.d.ts +0 -21
- package/dist/types/interface/models/user-application-log.model.js +0 -2
- package/dist/types/interface/models/user-application-stats.model.d.ts +0 -14
- package/dist/types/interface/models/user-application-stats.model.js +0 -2
- package/dist/types/interface/models/user-application.model.d.ts +0 -15
- package/dist/types/interface/models/user-application.model.js +0 -2
- package/dist/types/interface/models/user.model.d.ts +0 -8
- package/dist/types/interface/models/user.model.js +0 -2
|
@@ -1,163 +1,163 @@
|
|
|
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.Query = exports.Params = exports.Body = exports.Middlewares = exports.Middleware = exports.Controller = exports.Patch = exports.Delete = exports.Put = exports.Post = exports.Get = void 0;
|
|
7
|
-
const types_1 = require("../../types");
|
|
8
|
-
const _1 = require(".");
|
|
9
|
-
const joi_to_swagger_1 = __importDefault(require("joi-to-swagger"));
|
|
10
|
-
function Route(options) {
|
|
11
|
-
return function (target, propertyKey, descriptor) {
|
|
12
|
-
Reflect.defineMetadata(_1.ROUTE_WATERMARK, true, target, propertyKey);
|
|
13
|
-
Reflect.defineMetadata(_1.PATH_WATERMARK, options.path, target, propertyKey);
|
|
14
|
-
Reflect.defineMetadata(_1.METHOD_WATERMARK, options.method, target, propertyKey);
|
|
15
|
-
Reflect.defineMetadata(_1.OPTIONS_WATERMARK, options, target, propertyKey);
|
|
16
|
-
if (options.docs) {
|
|
17
|
-
Reflect.defineMetadata(_1.DOCS_WATERMARK, options.docs, target, propertyKey);
|
|
18
|
-
}
|
|
19
|
-
const originalMethod = descriptor.value;
|
|
20
|
-
descriptor.value = function (...args) {
|
|
21
|
-
args[1].locals.shouldNotPublishLog =
|
|
22
|
-
typeof options === 'string' ? false : options.shouldNotPublishLog;
|
|
23
|
-
return originalMethod.apply(target, args);
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
function Get(options, docs) {
|
|
28
|
-
return Route({
|
|
29
|
-
...(typeof options === 'string' ? { path: options } : options),
|
|
30
|
-
docs,
|
|
31
|
-
method: types_1.APIMethod.GET,
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
exports.Get = Get;
|
|
35
|
-
function Post(options, docs) {
|
|
36
|
-
return Route({
|
|
37
|
-
...(typeof options === 'string' ? { path: options } : options),
|
|
38
|
-
docs,
|
|
39
|
-
method: types_1.APIMethod.POST,
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
exports.Post = Post;
|
|
43
|
-
function Put(options, docs) {
|
|
44
|
-
return Route({
|
|
45
|
-
...(typeof options === 'string' ? { path: options } : options),
|
|
46
|
-
docs,
|
|
47
|
-
method: types_1.APIMethod.PUT,
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
exports.Put = Put;
|
|
51
|
-
function Delete(options, docs) {
|
|
52
|
-
return Route({
|
|
53
|
-
...(typeof options === 'string' ? { path: options } : options),
|
|
54
|
-
docs,
|
|
55
|
-
method: types_1.APIMethod.DELETE,
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
exports.Delete = Delete;
|
|
59
|
-
function Patch(options, docs) {
|
|
60
|
-
return Route({
|
|
61
|
-
...(typeof options === 'string' ? { path: options } : options),
|
|
62
|
-
docs,
|
|
63
|
-
method: types_1.APIMethod.PATCH,
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
exports.Patch = Patch;
|
|
67
|
-
function Controller(options) {
|
|
68
|
-
const defaultPath = '/';
|
|
69
|
-
return function (target) {
|
|
70
|
-
var _a;
|
|
71
|
-
Reflect.defineMetadata(_1.CONTROLLER_WATERMARK, true, target);
|
|
72
|
-
Reflect.defineMetadata(_1.MASKED_WATERMARK, (typeof options === 'string' ? false : options.isMasked) || false, target);
|
|
73
|
-
Reflect.defineMetadata(_1.PATH_WATERMARK, (typeof options === 'string' ? options : options.prefixPath) || defaultPath, target);
|
|
74
|
-
const existingMiddlewares = Reflect.getMetadata(_1.MIDDLEWARE_HOOK_WATERMARK, target) || [];
|
|
75
|
-
Reflect.defineMetadata(_1.MIDDLEWARE_HOOK_WATERMARK, (typeof options === 'string'
|
|
76
|
-
? existingMiddlewares
|
|
77
|
-
: [
|
|
78
|
-
...existingMiddlewares,
|
|
79
|
-
...(((_a = options.middlewares) === null || _a === void 0 ? void 0 : _a.map((middleware) => middleware.name)) || []),
|
|
80
|
-
]) || existingMiddlewares, target);
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
exports.Controller = Controller;
|
|
84
|
-
function Middleware() {
|
|
85
|
-
return function (target) {
|
|
86
|
-
Reflect.defineMetadata(_1.MIDDLEWARE_WATERMARK, true, target);
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
exports.Middleware = Middleware;
|
|
90
|
-
function Middlewares(middlewares) {
|
|
91
|
-
return function (target, propertyKey) {
|
|
92
|
-
const existingMiddlewares = Reflect.getMetadata(_1.MIDDLEWARE_HOOK_WATERMARK, target) || [];
|
|
93
|
-
Reflect.defineMetadata(_1.MIDDLEWARE_HOOK_WATERMARK, [...existingMiddlewares, ...((middlewares === null || middlewares === void 0 ? void 0 : middlewares.map((middleware) => middleware.name)) || [])] ||
|
|
94
|
-
existingMiddlewares, target, propertyKey);
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
exports.Middlewares = Middlewares;
|
|
98
|
-
function Body(schema, options) {
|
|
99
|
-
return function (target, propertyKey, descriptor) {
|
|
100
|
-
const existingDocs = Reflect.getMetadata(_1.DOCS_WATERMARK, target, propertyKey) || {};
|
|
101
|
-
if (!existingDocs.body) {
|
|
102
|
-
existingDocs.body = {};
|
|
103
|
-
}
|
|
104
|
-
if (!(options === null || options === void 0 ? void 0 : options.shouldNotGenerateSwagger)) {
|
|
105
|
-
existingDocs.body.content = (0, joi_to_swagger_1.default)(schema).swagger;
|
|
106
|
-
}
|
|
107
|
-
Reflect.defineMetadata(_1.DOCS_WATERMARK, existingDocs, target, propertyKey);
|
|
108
|
-
const originalMethod = descriptor.value;
|
|
109
|
-
descriptor.value = function (...args) {
|
|
110
|
-
const result = schema.options({ presence: 'required' }).validate(args[0].body);
|
|
111
|
-
if (result.error) {
|
|
112
|
-
throw result.error;
|
|
113
|
-
}
|
|
114
|
-
args[0].body = result.value;
|
|
115
|
-
return originalMethod.apply(target, args);
|
|
116
|
-
};
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
exports.Body = Body;
|
|
120
|
-
function Params(schema, options) {
|
|
121
|
-
return function (target, propertyKey, descriptor) {
|
|
122
|
-
const existingDocs = Reflect.getMetadata(_1.DOCS_WATERMARK, target, propertyKey) || {};
|
|
123
|
-
if (!existingDocs.params) {
|
|
124
|
-
existingDocs.params = {};
|
|
125
|
-
}
|
|
126
|
-
if (!(options === null || options === void 0 ? void 0 : options.shouldNotGenerateSwagger)) {
|
|
127
|
-
existingDocs.params.content = (0, joi_to_swagger_1.default)(schema).swagger;
|
|
128
|
-
}
|
|
129
|
-
Reflect.defineMetadata(_1.DOCS_WATERMARK, existingDocs, target, propertyKey);
|
|
130
|
-
const originalMethod = descriptor.value;
|
|
131
|
-
descriptor.value = function (...args) {
|
|
132
|
-
const result = schema.options({ presence: 'required' }).validate(args[0].params);
|
|
133
|
-
if (result.error) {
|
|
134
|
-
throw result.error;
|
|
135
|
-
}
|
|
136
|
-
args[0].params = result.value;
|
|
137
|
-
return originalMethod.apply(target, args);
|
|
138
|
-
};
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
exports.Params = Params;
|
|
142
|
-
function Query(schema, options) {
|
|
143
|
-
return function (target, propertyKey, descriptor) {
|
|
144
|
-
const existingDocs = Reflect.getMetadata(_1.DOCS_WATERMARK, target, propertyKey) || {};
|
|
145
|
-
if (!existingDocs.query) {
|
|
146
|
-
existingDocs.query = {};
|
|
147
|
-
}
|
|
148
|
-
if (!(options === null || options === void 0 ? void 0 : options.shouldNotGenerateSwagger)) {
|
|
149
|
-
existingDocs.query.content = (0, joi_to_swagger_1.default)(schema).swagger;
|
|
150
|
-
}
|
|
151
|
-
Reflect.defineMetadata(_1.DOCS_WATERMARK, existingDocs, target, propertyKey);
|
|
152
|
-
const originalMethod = descriptor.value;
|
|
153
|
-
descriptor.value = function (...args) {
|
|
154
|
-
const result = schema.options({ presence: 'required' }).validate(args[0].query);
|
|
155
|
-
if (result.error) {
|
|
156
|
-
throw result.error;
|
|
157
|
-
}
|
|
158
|
-
args[0].query = result.value;
|
|
159
|
-
return originalMethod.apply(target, args);
|
|
160
|
-
};
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
exports.Query = Query;
|
|
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.Query = exports.Params = exports.Body = exports.Middlewares = exports.Middleware = exports.Controller = exports.Patch = exports.Delete = exports.Put = exports.Post = exports.Get = void 0;
|
|
7
|
+
const types_1 = require("../../types");
|
|
8
|
+
const _1 = require(".");
|
|
9
|
+
const joi_to_swagger_1 = __importDefault(require("joi-to-swagger"));
|
|
10
|
+
function Route(options) {
|
|
11
|
+
return function (target, propertyKey, descriptor) {
|
|
12
|
+
Reflect.defineMetadata(_1.ROUTE_WATERMARK, true, target, propertyKey);
|
|
13
|
+
Reflect.defineMetadata(_1.PATH_WATERMARK, options.path, target, propertyKey);
|
|
14
|
+
Reflect.defineMetadata(_1.METHOD_WATERMARK, options.method, target, propertyKey);
|
|
15
|
+
Reflect.defineMetadata(_1.OPTIONS_WATERMARK, options, target, propertyKey);
|
|
16
|
+
if (options.docs) {
|
|
17
|
+
Reflect.defineMetadata(_1.DOCS_WATERMARK, options.docs, target, propertyKey);
|
|
18
|
+
}
|
|
19
|
+
const originalMethod = descriptor.value;
|
|
20
|
+
descriptor.value = function (...args) {
|
|
21
|
+
args[1].locals.shouldNotPublishLog =
|
|
22
|
+
typeof options === 'string' ? false : options.shouldNotPublishLog;
|
|
23
|
+
return originalMethod.apply(target, args);
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function Get(options, docs) {
|
|
28
|
+
return Route({
|
|
29
|
+
...(typeof options === 'string' ? { path: options } : options),
|
|
30
|
+
docs,
|
|
31
|
+
method: types_1.APIMethod.GET,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
exports.Get = Get;
|
|
35
|
+
function Post(options, docs) {
|
|
36
|
+
return Route({
|
|
37
|
+
...(typeof options === 'string' ? { path: options } : options),
|
|
38
|
+
docs,
|
|
39
|
+
method: types_1.APIMethod.POST,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
exports.Post = Post;
|
|
43
|
+
function Put(options, docs) {
|
|
44
|
+
return Route({
|
|
45
|
+
...(typeof options === 'string' ? { path: options } : options),
|
|
46
|
+
docs,
|
|
47
|
+
method: types_1.APIMethod.PUT,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
exports.Put = Put;
|
|
51
|
+
function Delete(options, docs) {
|
|
52
|
+
return Route({
|
|
53
|
+
...(typeof options === 'string' ? { path: options } : options),
|
|
54
|
+
docs,
|
|
55
|
+
method: types_1.APIMethod.DELETE,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
exports.Delete = Delete;
|
|
59
|
+
function Patch(options, docs) {
|
|
60
|
+
return Route({
|
|
61
|
+
...(typeof options === 'string' ? { path: options } : options),
|
|
62
|
+
docs,
|
|
63
|
+
method: types_1.APIMethod.PATCH,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
exports.Patch = Patch;
|
|
67
|
+
function Controller(options) {
|
|
68
|
+
const defaultPath = '/';
|
|
69
|
+
return function (target) {
|
|
70
|
+
var _a;
|
|
71
|
+
Reflect.defineMetadata(_1.CONTROLLER_WATERMARK, true, target);
|
|
72
|
+
Reflect.defineMetadata(_1.MASKED_WATERMARK, (typeof options === 'string' ? false : options.isMasked) || false, target);
|
|
73
|
+
Reflect.defineMetadata(_1.PATH_WATERMARK, (typeof options === 'string' ? options : options.prefixPath) || defaultPath, target);
|
|
74
|
+
const existingMiddlewares = Reflect.getMetadata(_1.MIDDLEWARE_HOOK_WATERMARK, target) || [];
|
|
75
|
+
Reflect.defineMetadata(_1.MIDDLEWARE_HOOK_WATERMARK, (typeof options === 'string'
|
|
76
|
+
? existingMiddlewares
|
|
77
|
+
: [
|
|
78
|
+
...existingMiddlewares,
|
|
79
|
+
...(((_a = options.middlewares) === null || _a === void 0 ? void 0 : _a.map((middleware) => middleware.name)) || []),
|
|
80
|
+
]) || existingMiddlewares, target);
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
exports.Controller = Controller;
|
|
84
|
+
function Middleware() {
|
|
85
|
+
return function (target) {
|
|
86
|
+
Reflect.defineMetadata(_1.MIDDLEWARE_WATERMARK, true, target);
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
exports.Middleware = Middleware;
|
|
90
|
+
function Middlewares(middlewares) {
|
|
91
|
+
return function (target, propertyKey) {
|
|
92
|
+
const existingMiddlewares = Reflect.getMetadata(_1.MIDDLEWARE_HOOK_WATERMARK, target) || [];
|
|
93
|
+
Reflect.defineMetadata(_1.MIDDLEWARE_HOOK_WATERMARK, [...existingMiddlewares, ...((middlewares === null || middlewares === void 0 ? void 0 : middlewares.map((middleware) => middleware.name)) || [])] ||
|
|
94
|
+
existingMiddlewares, target, propertyKey);
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
exports.Middlewares = Middlewares;
|
|
98
|
+
function Body(schema, options) {
|
|
99
|
+
return function (target, propertyKey, descriptor) {
|
|
100
|
+
const existingDocs = Reflect.getMetadata(_1.DOCS_WATERMARK, target, propertyKey) || {};
|
|
101
|
+
if (!existingDocs.body) {
|
|
102
|
+
existingDocs.body = {};
|
|
103
|
+
}
|
|
104
|
+
if (!(options === null || options === void 0 ? void 0 : options.shouldNotGenerateSwagger)) {
|
|
105
|
+
existingDocs.body.content = (0, joi_to_swagger_1.default)(schema).swagger;
|
|
106
|
+
}
|
|
107
|
+
Reflect.defineMetadata(_1.DOCS_WATERMARK, existingDocs, target, propertyKey);
|
|
108
|
+
const originalMethod = descriptor.value;
|
|
109
|
+
descriptor.value = function (...args) {
|
|
110
|
+
const result = schema.options({ presence: 'required' }).validate(args[0].body);
|
|
111
|
+
if (result.error) {
|
|
112
|
+
throw result.error;
|
|
113
|
+
}
|
|
114
|
+
args[0].body = result.value;
|
|
115
|
+
return originalMethod.apply(target, args);
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
exports.Body = Body;
|
|
120
|
+
function Params(schema, options) {
|
|
121
|
+
return function (target, propertyKey, descriptor) {
|
|
122
|
+
const existingDocs = Reflect.getMetadata(_1.DOCS_WATERMARK, target, propertyKey) || {};
|
|
123
|
+
if (!existingDocs.params) {
|
|
124
|
+
existingDocs.params = {};
|
|
125
|
+
}
|
|
126
|
+
if (!(options === null || options === void 0 ? void 0 : options.shouldNotGenerateSwagger)) {
|
|
127
|
+
existingDocs.params.content = (0, joi_to_swagger_1.default)(schema).swagger;
|
|
128
|
+
}
|
|
129
|
+
Reflect.defineMetadata(_1.DOCS_WATERMARK, existingDocs, target, propertyKey);
|
|
130
|
+
const originalMethod = descriptor.value;
|
|
131
|
+
descriptor.value = function (...args) {
|
|
132
|
+
const result = schema.options({ presence: 'required' }).validate(args[0].params);
|
|
133
|
+
if (result.error) {
|
|
134
|
+
throw result.error;
|
|
135
|
+
}
|
|
136
|
+
args[0].params = result.value;
|
|
137
|
+
return originalMethod.apply(target, args);
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
exports.Params = Params;
|
|
142
|
+
function Query(schema, options) {
|
|
143
|
+
return function (target, propertyKey, descriptor) {
|
|
144
|
+
const existingDocs = Reflect.getMetadata(_1.DOCS_WATERMARK, target, propertyKey) || {};
|
|
145
|
+
if (!existingDocs.query) {
|
|
146
|
+
existingDocs.query = {};
|
|
147
|
+
}
|
|
148
|
+
if (!(options === null || options === void 0 ? void 0 : options.shouldNotGenerateSwagger)) {
|
|
149
|
+
existingDocs.query.content = (0, joi_to_swagger_1.default)(schema).swagger;
|
|
150
|
+
}
|
|
151
|
+
Reflect.defineMetadata(_1.DOCS_WATERMARK, existingDocs, target, propertyKey);
|
|
152
|
+
const originalMethod = descriptor.value;
|
|
153
|
+
descriptor.value = function (...args) {
|
|
154
|
+
const result = schema.options({ presence: 'required' }).validate(args[0].query);
|
|
155
|
+
if (result.error) {
|
|
156
|
+
throw result.error;
|
|
157
|
+
}
|
|
158
|
+
args[0].query = result.value;
|
|
159
|
+
return originalMethod.apply(target, args);
|
|
160
|
+
};
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
exports.Query = Query;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
export * from './decorators';
|
|
2
|
-
export * from './metadata';
|
|
3
|
-
import 'reflect-metadata';
|
|
4
|
-
import express, { Router } from 'express-serve-static-core';
|
|
5
|
-
|
|
6
|
-
prefix: string;
|
|
7
|
-
middlewares: any[];
|
|
8
|
-
controllers: any[];
|
|
9
|
-
router: (option: any) => Router;
|
|
10
|
-
};
|
|
11
|
-
export declare const controllerLoader: (app: express.Application, options: Options) => Promise<{
|
|
12
|
-
swagger: {
|
|
13
|
-
tags: string[];
|
|
14
|
-
paths: Record<string, any>;
|
|
15
|
-
};
|
|
16
|
-
}>;
|
|
1
|
+
export * from './decorators';
|
|
2
|
+
export * from './metadata';
|
|
3
|
+
import 'reflect-metadata';
|
|
4
|
+
import express, { Router } from 'express-serve-static-core';
|
|
5
|
+
type Options = {
|
|
6
|
+
prefix: string;
|
|
7
|
+
middlewares: any[];
|
|
8
|
+
controllers: any[];
|
|
9
|
+
router: (option: any) => Router;
|
|
10
|
+
};
|
|
11
|
+
export declare const controllerLoader: (app: express.Application, options: Options) => Promise<{
|
|
12
|
+
swagger: {
|
|
13
|
+
tags: string[];
|
|
14
|
+
paths: Record<string, any>;
|
|
15
|
+
};
|
|
16
|
+
}>;
|