@xrystal/core 3.32.1 → 3.37.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/README.md +651 -136
- package/package.json +27 -24
- package/tsconfig.base.json +15 -0
- package/x/bin/commands/create.mjs +34 -5
- package/x/bin/commands/doctor.mjs +115 -25
- package/x/bin/commands/hooks.mjs +55 -0
- package/x/bin/commands/project.mjs +75 -42
- package/x/bin/commands/release.mjs +8 -3
- package/x/bin/commands/sync-toolchain.mjs +43 -0
- package/x/bin/commands/tmp.mjs +13 -4
- package/x/bin/helpers/.generated/.generated-from +1 -0
- package/x/bin/helpers/.generated/tmp-schema.mjs +192 -0
- package/x/bin/helpers/banner.mjs +66 -12
- package/x/bin/helpers/build-config.mjs +342 -0
- package/x/bin/helpers/cli-help.mjs +164 -0
- package/x/bin/helpers/create-target.mjs +18 -2
- package/x/bin/helpers/project-artifacts.mjs +140 -0
- package/x/bin/helpers/runtime-info.mjs +172 -0
- package/x/bin/helpers/tmp-config.mjs +11 -10
- package/x/bin/helpers/tmp-layout.mjs +10 -16
- package/x/bin/helpers/tmp-schema.mjs +9 -0
- package/x/bin/helpers/toolchain-config.mjs +233 -0
- package/x/bin/main-cli.js +31 -3
- package/x/bin/scripts/clean-source-types.mjs +19 -0
- package/x/bin/scripts/fix-dist-imports.mjs +80 -0
- package/x/bin/scripts/install-git-hooks.mjs +86 -0
- package/x/bin/scripts/minify-dist.mjs +50 -0
- package/x/bin/scripts/prepare-npm-publish.mjs +49 -0
- package/x/bin/scripts/unpublish-leaked-versions.mjs +62 -0
- package/x/bin/scripts/verify-npm-pack.mjs +45 -0
- package/x/bin/scripts/verify-version-bump.mjs +27 -0
- package/x/bin/scripts/version-check.mjs +173 -0
- package/x/dist/index.d.ts +3 -0
- package/x/dist/index.js +1 -0
- package/x/dist/loader/clients/index.js +1 -0
- package/x/dist/loader/configs/index.js +1 -0
- package/{source → x/dist}/loader/controller/index.d.ts +20 -17
- package/x/dist/loader/controller/index.js +1 -0
- package/x/dist/loader/dto/index.js +1 -0
- package/x/dist/loader/events/index.js +1 -0
- package/x/dist/loader/index.d.ts +11 -0
- package/x/dist/loader/index.js +1 -0
- package/{source → x/dist}/loader/kafka/index.d.ts +1 -0
- package/x/dist/loader/kafka/index.js +1 -0
- package/x/dist/loader/localizations/index.js +1 -0
- package/{source → x/dist}/loader/logger/index.d.ts +1 -0
- package/x/dist/loader/logger/index.js +2 -0
- package/x/dist/loader/service/index.js +1 -0
- package/x/dist/loader/system/index.js +1 -0
- package/x/dist/project/index.js +1 -0
- package/x/dist/utils/constants/defaults.json +44 -0
- package/x/dist/utils/constants/index.js +1 -0
- package/x/dist/utils/helpers/configs/index.js +1 -0
- package/x/dist/utils/helpers/context/controller-store.js +1 -0
- package/x/dist/utils/helpers/context/index.js +1 -0
- package/{source → x/dist}/utils/helpers/core/index.d.ts +1 -1
- package/x/dist/utils/helpers/core/index.js +1 -0
- package/x/dist/utils/helpers/core/paths.js +1 -0
- package/x/dist/utils/helpers/core/tmp-layout.js +1 -0
- package/x/dist/utils/helpers/date/index.js +1 -0
- package/x/dist/utils/helpers/dispatch/index.js +1 -0
- package/x/dist/utils/helpers/dto/index.js +1 -0
- package/x/dist/utils/helpers/filters/index.js +1 -0
- package/x/dist/utils/helpers/framework/index.js +1 -0
- package/x/dist/utils/helpers/handlers/adapters.js +1 -0
- package/x/dist/utils/helpers/handlers/execute.js +1 -0
- package/x/dist/utils/helpers/handlers/index.js +1 -0
- package/x/dist/utils/helpers/hash/crypto.js +1 -0
- package/x/dist/utils/helpers/id/index.js +1 -0
- package/x/dist/utils/helpers/index.js +1 -0
- package/x/dist/utils/helpers/ip/index.js +1 -0
- package/x/dist/utils/helpers/is/index.js +1 -0
- package/x/dist/utils/helpers/locales/index.js +1 -0
- package/x/dist/utils/helpers/math/index.js +1 -0
- package/{source → x/dist}/utils/helpers/middleware/index.d.ts +2 -2
- package/x/dist/utils/helpers/middleware/index.js +1 -0
- package/x/dist/utils/helpers/objects/index.js +1 -0
- package/x/dist/utils/helpers/path/index.js +1 -0
- package/{source → x/dist}/utils/helpers/protocol/index.d.ts +2 -10
- package/x/dist/utils/helpers/protocol/index.js +1 -0
- package/x/dist/utils/helpers/protocol/options.js +1 -0
- package/x/dist/utils/helpers/regex/checkSpecialRegexControl.js +1 -0
- package/x/dist/utils/helpers/runtime/dto-access.js +1 -0
- package/x/dist/utils/helpers/runtime/dto-types.js +1 -0
- package/{source → x/dist}/utils/helpers/runtime/index.d.ts +1 -0
- package/x/dist/utils/helpers/runtime/index.js +1 -0
- package/x/dist/utils/helpers/runtime/shutdown.d.ts +3 -0
- package/x/dist/utils/helpers/runtime/shutdown.js +1 -0
- package/x/dist/utils/helpers/state/index.js +1 -0
- package/x/dist/utils/helpers/state/props-from-tmp.js +1 -0
- package/x/dist/utils/helpers/state/request-key-guard.js +1 -0
- package/x/dist/utils/helpers/state/scopes.js +1 -0
- package/x/dist/utils/helpers/string/index.js +1 -0
- package/x/dist/utils/helpers/tests/tmp-schema.test.js +1 -0
- package/x/dist/utils/helpers/tests/tmp-watch.test.js +1 -0
- package/x/dist/utils/helpers/timer/index.js +1 -0
- package/x/dist/utils/helpers/tmp/index.d.ts +5 -0
- package/x/dist/utils/helpers/tmp/index.js +1 -0
- package/x/dist/utils/helpers/tmp/loader-tmp-sync.js +1 -0
- package/{source → x/dist}/utils/helpers/tmp/runtime-tmp.d.ts +2 -6
- package/x/dist/utils/helpers/tmp/runtime-tmp.js +1 -0
- package/{source → x/dist}/utils/helpers/tmp/tmp-loader.d.ts +1 -0
- package/x/dist/utils/helpers/tmp/tmp-loader.js +1 -0
- package/x/dist/utils/helpers/tmp/tmp-schema.d.ts +47 -0
- package/x/dist/utils/helpers/tmp/tmp-schema.js +1 -0
- package/x/dist/utils/helpers/tmp/tmp-watch.d.ts +1 -0
- package/x/dist/utils/helpers/tmp/tmp-watch.js +1 -0
- package/x/dist/utils/helpers/validates/index.js +1 -0
- package/x/dist/utils/index.js +1 -0
- package/x/dist/utils/models/classes/class.clients.js +1 -0
- package/x/dist/utils/models/classes/class.interfaces.js +1 -0
- package/x/dist/utils/models/classes/class.service-locator.js +1 -0
- package/{source → x/dist}/utils/models/classes/class.tmp-file-loader.d.ts +3 -2
- package/x/dist/utils/models/classes/class.tmp-file-loader.js +1 -0
- package/x/dist/utils/models/classes/class.x.js +1 -0
- package/x/dist/utils/models/enums/index.js +1 -0
- package/x/dist/utils/models/index.js +1 -0
- package/x/dist/utils/models/types/index.js +1 -0
- package/x/dist/utils/package-root.js +1 -0
- package/x/tmp.yml +51 -42
- package/source/index.js +0 -11
- package/source/loader/clients/index.js +0 -22
- package/source/loader/configs/index.js +0 -88
- package/source/loader/controller/index.js +0 -236
- package/source/loader/dto/index.js +0 -92
- package/source/loader/events/index.js +0 -44
- package/source/loader/index.d.ts +0 -11
- package/source/loader/index.js +0 -11
- package/source/loader/kafka/index.js +0 -137
- package/source/loader/localizations/index.js +0 -46
- package/source/loader/logger/index.js +0 -217
- package/source/loader/service/index.js +0 -7
- package/source/loader/system/index.js +0 -25
- package/source/project/index.js +0 -70
- package/source/utils/constants/defaults.json +0 -15
- package/source/utils/constants/defaults.mjs +0 -10
- package/source/utils/constants/index.js +0 -22
- package/source/utils/helpers/configs/index.js +0 -1
- package/source/utils/helpers/context/controller-store.js +0 -12
- package/source/utils/helpers/context/index.js +0 -24
- package/source/utils/helpers/core/index.js +0 -58
- package/source/utils/helpers/core/paths.js +0 -78
- package/source/utils/helpers/core/tmp-layout.js +0 -241
- package/source/utils/helpers/date/index.js +0 -48
- package/source/utils/helpers/dispatch/index.js +0 -53
- package/source/utils/helpers/dto/index.js +0 -10
- package/source/utils/helpers/filters/index.js +0 -44
- package/source/utils/helpers/framework/index.js +0 -17
- package/source/utils/helpers/handlers/adapters.js +0 -40
- package/source/utils/helpers/handlers/execute.js +0 -82
- package/source/utils/helpers/handlers/index.js +0 -31
- package/source/utils/helpers/hash/crypto.js +0 -22
- package/source/utils/helpers/id/index.js +0 -24
- package/source/utils/helpers/index.js +0 -26
- package/source/utils/helpers/ip/index.js +0 -21
- package/source/utils/helpers/is/index.js +0 -35
- package/source/utils/helpers/locales/index.js +0 -82
- package/source/utils/helpers/math/index.js +0 -14
- package/source/utils/helpers/middleware/index.js +0 -36
- package/source/utils/helpers/objects/index.js +0 -55
- package/source/utils/helpers/path/index.js +0 -4
- package/source/utils/helpers/protocol/index.js +0 -99
- package/source/utils/helpers/protocol/options.js +0 -13
- package/source/utils/helpers/regex/checkSpecialRegexControl.js +0 -3
- package/source/utils/helpers/runtime/dto-access.js +0 -5
- package/source/utils/helpers/runtime/index.js +0 -1
- package/source/utils/helpers/state/index.js +0 -185
- package/source/utils/helpers/state/props-from-tmp.js +0 -44
- package/source/utils/helpers/state/request-key-guard.js +0 -42
- package/source/utils/helpers/state/scopes.js +0 -69
- package/source/utils/helpers/string/index.js +0 -9
- package/source/utils/helpers/timer/index.js +0 -5
- package/source/utils/helpers/tmp/index.d.ts +0 -3
- package/source/utils/helpers/tmp/index.js +0 -3
- package/source/utils/helpers/tmp/loader-tmp-sync.js +0 -13
- package/source/utils/helpers/tmp/runtime-tmp.js +0 -30
- package/source/utils/helpers/tmp/tmp-loader.js +0 -48
- package/source/utils/helpers/validates/index.js +0 -20
- package/source/utils/index.js +0 -3
- package/source/utils/models/classes/class.clients.js +0 -142
- package/source/utils/models/classes/class.interfaces.js +0 -10
- package/source/utils/models/classes/class.service-locator.js +0 -16
- package/source/utils/models/classes/class.tmp-file-loader.js +0 -38
- package/source/utils/models/classes/class.x.js +0 -180
- package/source/utils/models/enums/index.js +0 -148
- package/source/utils/models/index.js +0 -9
- package/source/utils/models/types/index.js +0 -2
- package/source/utils/models/types/shims.d.ts +0 -123
- package/source/utils/package-root.js +0 -5
- package/x/tests/cli.test.ts +0 -85
- package/x/tests/context.test.ts +0 -25
- package/x/tests/dispatch.test.ts +0 -84
- package/x/tests/fixtures/locales/en/translation.json +0 -8
- package/x/tests/fixtures/locales/tr/translation.json +0 -8
- package/x/tests/frameworks.integration.test.ts +0 -185
- package/x/tests/helpers/i18n-setup.ts +0 -52
- package/x/tests/helpers/middleware.ts +0 -23
- package/x/tests/helpers/register-test-dto.ts +0 -52
- package/x/tests/i18n.integration.test.ts +0 -77
- package/x/tests/i18n.test.ts +0 -96
- package/x/tests/middleware.test.ts +0 -83
- package/x/tests/project-layout.test.ts +0 -65
- package/x/tests/protocol.test.ts +0 -75
- package/x/tests/realtime.examples.test.ts +0 -198
- package/x/tests/runtime-tmp.test.ts +0 -49
- package/x/tests/socket.integration.test.ts +0 -174
- package/x/tests/state.test.ts +0 -183
- package/x/tests/tmp-layout-guard.test.ts +0 -40
- /package/{source → x/dist}/loader/clients/index.d.ts +0 -0
- /package/{source → x/dist}/loader/configs/index.d.ts +0 -0
- /package/{source → x/dist}/loader/dto/index.d.ts +0 -0
- /package/{source → x/dist}/loader/events/index.d.ts +0 -0
- /package/{source → x/dist}/loader/localizations/index.d.ts +0 -0
- /package/{source → x/dist}/loader/service/index.d.ts +0 -0
- /package/{source → x/dist}/loader/system/index.d.ts +0 -0
- /package/{source → x/dist}/project/index.d.ts +0 -0
- /package/{source → x/dist}/utils/constants/index.d.ts +0 -0
- /package/{source → x/dist}/utils/helpers/configs/index.d.ts +0 -0
- /package/{source → x/dist}/utils/helpers/context/controller-store.d.ts +0 -0
- /package/{source → x/dist}/utils/helpers/context/index.d.ts +0 -0
- /package/{source → x/dist}/utils/helpers/core/paths.d.ts +0 -0
- /package/{source → x/dist}/utils/helpers/core/tmp-layout.d.ts +0 -0
- /package/{source → x/dist}/utils/helpers/date/index.d.ts +0 -0
- /package/{source → x/dist}/utils/helpers/dispatch/index.d.ts +0 -0
- /package/{source → x/dist}/utils/helpers/dto/index.d.ts +0 -0
- /package/{source → x/dist}/utils/helpers/filters/index.d.ts +0 -0
- /package/{source → x/dist}/utils/helpers/framework/index.d.ts +0 -0
- /package/{source → x/dist}/utils/helpers/handlers/adapters.d.ts +0 -0
- /package/{source → x/dist}/utils/helpers/handlers/execute.d.ts +0 -0
- /package/{source → x/dist}/utils/helpers/handlers/index.d.ts +0 -0
- /package/{source → x/dist}/utils/helpers/hash/crypto.d.ts +0 -0
- /package/{source → x/dist}/utils/helpers/id/index.d.ts +0 -0
- /package/{source → x/dist}/utils/helpers/index.d.ts +0 -0
- /package/{source → x/dist}/utils/helpers/ip/index.d.ts +0 -0
- /package/{source → x/dist}/utils/helpers/is/index.d.ts +0 -0
- /package/{source → x/dist}/utils/helpers/locales/index.d.ts +0 -0
- /package/{source → x/dist}/utils/helpers/math/index.d.ts +0 -0
- /package/{source → x/dist}/utils/helpers/objects/index.d.ts +0 -0
- /package/{source → x/dist}/utils/helpers/path/index.d.ts +0 -0
- /package/{source → x/dist}/utils/helpers/protocol/options.d.ts +0 -0
- /package/{source → x/dist}/utils/helpers/regex/checkSpecialRegexControl.d.ts +0 -0
- /package/{source → x/dist}/utils/helpers/runtime/dto-access.d.ts +0 -0
- /package/{source → x/dist}/utils/helpers/runtime/dto-types.d.ts +0 -0
- /package/{source → x/dist}/utils/helpers/state/index.d.ts +0 -0
- /package/{source → x/dist}/utils/helpers/state/props-from-tmp.d.ts +0 -0
- /package/{source → x/dist}/utils/helpers/state/request-key-guard.d.ts +0 -0
- /package/{source → x/dist}/utils/helpers/state/scopes.d.ts +0 -0
- /package/{source → x/dist}/utils/helpers/string/index.d.ts +0 -0
- /package/{source/index.d.ts → x/dist/utils/helpers/tests/tmp-schema.test.d.ts} +0 -0
- /package/{source/utils/helpers/runtime/dto-types.js → x/dist/utils/helpers/tests/tmp-watch.test.d.ts} +0 -0
- /package/{source → x/dist}/utils/helpers/timer/index.d.ts +0 -0
- /package/{source → x/dist}/utils/helpers/tmp/loader-tmp-sync.d.ts +0 -0
- /package/{source → x/dist}/utils/helpers/validates/index.d.ts +0 -0
- /package/{source → x/dist}/utils/index.d.ts +0 -0
- /package/{source → x/dist}/utils/models/classes/class.clients.d.ts +0 -0
- /package/{source → x/dist}/utils/models/classes/class.interfaces.d.ts +0 -0
- /package/{source → x/dist}/utils/models/classes/class.service-locator.d.ts +0 -0
- /package/{source → x/dist}/utils/models/classes/class.x.d.ts +0 -0
- /package/{source → x/dist}/utils/models/enums/index.d.ts +0 -0
- /package/{source → x/dist}/utils/models/index.d.ts +0 -0
- /package/{source → x/dist}/utils/models/types/index.d.ts +0 -0
- /package/{source → x/dist}/utils/package-root.d.ts +0 -0
package/x/tmp.yml
CHANGED
|
@@ -1,49 +1,58 @@
|
|
|
1
|
-
# configs = proje ayarları (servis tmp.yml — tek kaynak)
|
|
2
|
-
# @xrystal/core paketinde default rootFolderPath: x (servislerde değiştir)
|
|
3
1
|
project:
|
|
4
2
|
name: x
|
|
5
3
|
|
|
6
4
|
configs:
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
5
|
+
service:
|
|
6
|
+
name: example-service
|
|
7
|
+
framework: elysia
|
|
8
|
+
|
|
9
|
+
paths:
|
|
10
|
+
root: ./x
|
|
11
|
+
source: ./source
|
|
12
|
+
special:
|
|
13
|
+
tests: tests
|
|
14
|
+
environments: environments
|
|
15
|
+
dist: dist
|
|
16
|
+
|
|
17
|
+
protocols:
|
|
18
|
+
- http
|
|
19
|
+
- ws
|
|
20
|
+
|
|
21
|
+
loaders:
|
|
22
|
+
configs:
|
|
23
|
+
loadPath: '@/source/utils/helpers/configs/index'
|
|
24
|
+
|
|
25
|
+
system:
|
|
26
|
+
gStore:
|
|
27
|
+
options:
|
|
28
|
+
bootstrap: true
|
|
29
|
+
autoCreateProps: true
|
|
30
|
+
vars:
|
|
31
|
+
test: false
|
|
32
|
+
|
|
33
|
+
loggers:
|
|
34
|
+
loadPath: logs
|
|
35
|
+
logLevel: debug
|
|
36
|
+
|
|
37
|
+
localization:
|
|
38
|
+
loadPath: assets/langs
|
|
39
|
+
fallbackLang: en
|
|
40
|
+
preloadLangs:
|
|
41
|
+
- en
|
|
42
|
+
- tr
|
|
43
|
+
|
|
44
|
+
dto:
|
|
45
|
+
withDefaultHeaders: true
|
|
46
|
+
|
|
47
|
+
controller:
|
|
48
|
+
|
|
49
|
+
build:
|
|
50
|
+
typecheck: true
|
|
51
|
+
minify: true
|
|
52
|
+
|
|
53
|
+
core:
|
|
54
|
+
tmp:
|
|
55
|
+
fileWatchIntervalMs: 500
|
|
47
56
|
|
|
48
57
|
end:
|
|
49
58
|
version: 1
|
package/source/index.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import coreLoader from './project/index.js';
|
|
2
|
-
import { ensureCoreTmpEntry, isCorePackageRoot } from './utils/helpers/core/tmp-layout';
|
|
3
|
-
import { getTmpSnapshot } from './utils/helpers/tmp/tmp-loader';
|
|
4
|
-
await (async () => {
|
|
5
|
-
const root = process.cwd();
|
|
6
|
-
if (isCorePackageRoot(root)) {
|
|
7
|
-
ensureCoreTmpEntry(root);
|
|
8
|
-
}
|
|
9
|
-
getTmpSnapshot();
|
|
10
|
-
await coreLoader({});
|
|
11
|
-
})();
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { BaseApiClient, CoreClientsEnum } from "../../utils";
|
|
2
|
-
import { bindLoaderTmpSync } from '../../utils';
|
|
3
|
-
export default class Clients {
|
|
4
|
-
_instances = {};
|
|
5
|
-
#configs;
|
|
6
|
-
constructor({ configs }) {
|
|
7
|
-
this.#configs = configs;
|
|
8
|
-
}
|
|
9
|
-
async onInit() {
|
|
10
|
-
await this.syncFromTmp();
|
|
11
|
-
bindLoaderTmpSync(this);
|
|
12
|
-
}
|
|
13
|
-
syncFromTmp = async () => {
|
|
14
|
-
this._instances[CoreClientsEnum.BASE_API_CLIENT] = new BaseApiClient({
|
|
15
|
-
clientName: CoreClientsEnum.BASE_API_CLIENT,
|
|
16
|
-
baseURL: this.#configs.all.baseApiUri || '',
|
|
17
|
-
});
|
|
18
|
-
};
|
|
19
|
-
get instances() {
|
|
20
|
-
return this._instances;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import { isArray, mergeWith } from 'lodash';
|
|
3
|
-
import { pathToFileURL } from 'node:url';
|
|
4
|
-
import { bindLoaderTmpSync } from '../../utils';
|
|
5
|
-
import { Constants } from '../../utils';
|
|
6
|
-
export default class Configs {
|
|
7
|
-
publicFolderName = Constants.publicFolderName;
|
|
8
|
-
kafkaLogsTopic = Constants.kafkaLogsTopic;
|
|
9
|
-
#system;
|
|
10
|
-
#config;
|
|
11
|
-
constructor({ system }) {
|
|
12
|
-
this.#system = system;
|
|
13
|
-
const proxy = new Proxy(this, {
|
|
14
|
-
get: (target, prop) => {
|
|
15
|
-
return target[prop] || target.config?.[prop];
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
return proxy;
|
|
19
|
-
}
|
|
20
|
-
onInit = async () => {
|
|
21
|
-
await this.syncFromTmp();
|
|
22
|
-
bindLoaderTmpSync(this);
|
|
23
|
-
};
|
|
24
|
-
syncFromTmp = async () => {
|
|
25
|
-
const cwd = process.cwd();
|
|
26
|
-
const tmp = this.#system.tmp;
|
|
27
|
-
const extendConfigs = tmp.configs.loaders.configs.loadPath;
|
|
28
|
-
const fullPath = extendConfigs.startsWith('@/')
|
|
29
|
-
? path.join(process.cwd(), extendConfigs.slice(2))
|
|
30
|
-
: path.resolve(tmp.configs.rootFolderPath, extendConfigs);
|
|
31
|
-
const fileUrl = pathToFileURL(fullPath).href;
|
|
32
|
-
const modulePromise = import(fileUrl);
|
|
33
|
-
this.#config = {
|
|
34
|
-
worker: process.env.WORKER === 'true' ? true : false || false,
|
|
35
|
-
mode: process.env.MODE,
|
|
36
|
-
nodeEnv: process.env.NODE_ENV ?? 'development',
|
|
37
|
-
debug: process.env.SYSTEM_LOGGER_LAYER ?? '',
|
|
38
|
-
https: process.env.HTTPS ?? 'false',
|
|
39
|
-
httpsfileEncoding: process.env.ENCODING || 'utf8',
|
|
40
|
-
httpsCertfile: process.env.HTTPS_CERT_FILE ?? '',
|
|
41
|
-
httpsKeyfile: process.env.HTTPS_KEY_FILE ?? '',
|
|
42
|
-
rootFolderPath: tmp.configs.rootFolderPath || 'x',
|
|
43
|
-
projectName: tmp.project.name,
|
|
44
|
-
serviceName: tmp.configs.service,
|
|
45
|
-
projectNamePrefixEnv: process.env.PROJECT_NAME_PREFIX || '',
|
|
46
|
-
projectNameEnv: process.env.PROJECT_NAME || '',
|
|
47
|
-
projectNameSuffixEnv: process.env.PROJECT_NAME_SUFFIX || '',
|
|
48
|
-
systemStaticFolderPath: path.resolve(tmp.configs.rootFolderPath, this.publicFolderName),
|
|
49
|
-
systemLoggerLayer: process.env.SYSTEM_LOGGER_LAYER ?? 'info',
|
|
50
|
-
isKafkaPassive: process.env.IS_KAFKA_PASSIVE === 'true' ? true : false,
|
|
51
|
-
kafkaClientId: tmp.configs.service,
|
|
52
|
-
kafkaBrokers: process.env.KAFKA_BROKERS ?? '',
|
|
53
|
-
kafkaUsername: process.env.KAFKA_USERNAME ?? '',
|
|
54
|
-
kafkaPassword: process.env.KAFKA_PASSWORD ?? '',
|
|
55
|
-
kafkaTopics: [],
|
|
56
|
-
kafkaLogsTopic: this.kafkaLogsTopic,
|
|
57
|
-
baseApiUri: process.env.HTTPS === 'true' ? (process.env.SYSTEM_HTTPS_BASE_API_URI ?? '') : (process.env.SYSTEM_BASE_API_URI ?? ''),
|
|
58
|
-
port: Number(process.env.PORT),
|
|
59
|
-
internalSecret: process.env.INTERNAL_SECRET ?? '',
|
|
60
|
-
secret: process.env.SECRET ?? '',
|
|
61
|
-
cwd,
|
|
62
|
-
env: process.env.NODE_ENV ?? 'development',
|
|
63
|
-
};
|
|
64
|
-
try {
|
|
65
|
-
const moduleData = await modulePromise;
|
|
66
|
-
const importedConfigs = moduleData?.default || moduleData?.configs || moduleData || {};
|
|
67
|
-
const merged = mergeWith({}, this.#config, importedConfigs, (objValue, srcValue) => {
|
|
68
|
-
if (isArray(objValue)) {
|
|
69
|
-
return objValue.concat(srcValue);
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
this.#config = Object.freeze(merged);
|
|
73
|
-
}
|
|
74
|
-
catch {
|
|
75
|
-
this.#config = Object.freeze(this.#config);
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
setConfig(newConfigs) {
|
|
79
|
-
const mergedDObj = Object.assign(this.#config, newConfigs);
|
|
80
|
-
this.#config = Object.freeze(mergedDObj);
|
|
81
|
-
}
|
|
82
|
-
_(key) {
|
|
83
|
-
return this.#config[key];
|
|
84
|
-
}
|
|
85
|
-
get all() {
|
|
86
|
-
return this.#config;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
@@ -1,236 +0,0 @@
|
|
|
1
|
-
import qs from 'qs';
|
|
2
|
-
import Logger from '../../loader/logger';
|
|
3
|
-
import System from '../../loader/system';
|
|
4
|
-
import { bindLoaderTmpSync, getClientIp, getConfiguredProtocols, isRealtimeProtocol, LoggerLayerEnum, parseResponseMessage, ProtocolEnum, x, controllerContextStorage, getControllerCtx, runControllerStore, adapterBagFromRequest, isFetchRequest, toHandler, toRealtimeHandler, resolveCtrOptions, } from '../../utils';
|
|
5
|
-
export { controllerContextStorage, getControllerCtx };
|
|
6
|
-
export const runController = runControllerStore;
|
|
7
|
-
function isRawResponse(value) {
|
|
8
|
-
return value instanceof Response || value instanceof Blob || value instanceof Uint8Array || value instanceof ArrayBuffer;
|
|
9
|
-
}
|
|
10
|
-
function applyResultMeta(builder, obj) {
|
|
11
|
-
if (!obj || typeof obj !== 'object')
|
|
12
|
-
return;
|
|
13
|
-
if (obj.statusCode !== undefined)
|
|
14
|
-
return void builder.httpStatus(Number(obj.statusCode));
|
|
15
|
-
if (obj.code !== undefined) {
|
|
16
|
-
const code = Number(obj.code);
|
|
17
|
-
if (code >= 100)
|
|
18
|
-
builder.httpStatus(code);
|
|
19
|
-
else
|
|
20
|
-
builder.code(code);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
function extractPayload(obj) {
|
|
24
|
-
if (!obj || typeof obj !== 'object')
|
|
25
|
-
return { data: undefined, extraData: undefined, message: undefined };
|
|
26
|
-
if (obj.payload && typeof obj.payload === 'object') {
|
|
27
|
-
return { data: obj.payload.data !== undefined ? obj.payload.data : obj.payload, extraData: obj.payload.extraData, message: obj.message };
|
|
28
|
-
}
|
|
29
|
-
if (obj.data !== undefined || obj.extraData !== undefined)
|
|
30
|
-
return { data: obj.data, extraData: obj.extraData, message: obj.message };
|
|
31
|
-
const hasMeta = obj.status !== undefined || obj.message !== undefined || obj.code !== undefined || obj.statusCode !== undefined;
|
|
32
|
-
if (!hasMeta && Object.keys(obj).length > 0)
|
|
33
|
-
return { data: obj, extraData: undefined, message: obj.message };
|
|
34
|
-
return { data: undefined, extraData: undefined, message: obj.message };
|
|
35
|
-
}
|
|
36
|
-
export function resolveBuilder(store) {
|
|
37
|
-
const attached = store.ctx?.builder ?? store.res?.builder ?? store.socket?.builder;
|
|
38
|
-
if (attached)
|
|
39
|
-
return attached;
|
|
40
|
-
throw new Error('[xrystal] use dtoMiddleware() — builder attaches at request start via @xrystal/dto adapter');
|
|
41
|
-
}
|
|
42
|
-
export class BaseController {
|
|
43
|
-
system = x.get(System);
|
|
44
|
-
logger = x.get(Logger);
|
|
45
|
-
supportedProtocols = [ProtocolEnum.HTTP, ProtocolEnum.WEBSOCKET];
|
|
46
|
-
get store() {
|
|
47
|
-
return getControllerCtx();
|
|
48
|
-
}
|
|
49
|
-
get protocol() {
|
|
50
|
-
return this.store?.protocol || ProtocolEnum.HTTP;
|
|
51
|
-
}
|
|
52
|
-
get req() {
|
|
53
|
-
const store = this.store;
|
|
54
|
-
const ctx = store?.ctx || {};
|
|
55
|
-
const req = store?.req || {};
|
|
56
|
-
const fetchRequest = isFetchRequest(ctx.request) ? ctx.request : undefined;
|
|
57
|
-
const ctxReq = adapterBagFromRequest(ctx.request);
|
|
58
|
-
const headerSource = ctx.headers ?? req.headers ?? fetchRequest?.headers ?? ctxReq?.headers;
|
|
59
|
-
const headers = headerSource instanceof Headers
|
|
60
|
-
? Object.fromEntries(headerSource.entries())
|
|
61
|
-
: (headerSource ?? {});
|
|
62
|
-
const url = fetchRequest?.url ?? ctxReq?.url ?? req.url ?? ctx.url ?? "";
|
|
63
|
-
let query = (store?.metadata?.parsedQuery || ctx.query || req.query || ctxReq?.query || {});
|
|
64
|
-
if (!Object.keys(query).length && url.includes('?'))
|
|
65
|
-
query = qs.parse(url.split('?')[1]);
|
|
66
|
-
let cookies = (ctx.cookies || req.cookies || ctxReq?.cookies || {});
|
|
67
|
-
if (!Object.keys(cookies).length && headers.cookie) {
|
|
68
|
-
cookies = Object.fromEntries(headers.cookie.split(';').map((part) => {
|
|
69
|
-
const [k, v] = part.trim().split('=');
|
|
70
|
-
return [decodeURIComponent(k), decodeURIComponent(v || '')];
|
|
71
|
-
}));
|
|
72
|
-
}
|
|
73
|
-
return {
|
|
74
|
-
url,
|
|
75
|
-
method: (ctx.method || req.method || fetchRequest?.method || ctxReq?.method || '').toUpperCase(),
|
|
76
|
-
headers,
|
|
77
|
-
body: store?.metadata?.parsedBody || ctx.body || req.body || ctxReq?.body || {},
|
|
78
|
-
query,
|
|
79
|
-
params: { ...req.params, ...ctx.params, ...ctxReq?.params, ...ctxReq?.routeParams },
|
|
80
|
-
cookies,
|
|
81
|
-
ip: getClientIp(req, ctx),
|
|
82
|
-
lang: ctx.lang || req.lang || 'en',
|
|
83
|
-
requestId: store?.requestId ?? ctx.requestId ?? req.ctx?.requestId ?? String(headers['x-request-id'] ?? headers['x-correlation-id'] ?? ''),
|
|
84
|
-
startTime: (ctx.startTime ?? req.ctx?.startTime ?? Date.now()),
|
|
85
|
-
t: ctx.t || req.t || ((k) => k),
|
|
86
|
-
accounts: ctx.accounts || req.accounts || ctx.user,
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
get res() {
|
|
90
|
-
const store = this.store;
|
|
91
|
-
if (!store)
|
|
92
|
-
throw new Error('[xrystal] controller context missing');
|
|
93
|
-
const locals = store.metadata?.locals ?? {};
|
|
94
|
-
return { builder: resolveBuilder(store), locals: locals };
|
|
95
|
-
}
|
|
96
|
-
async parseRequestBody() {
|
|
97
|
-
const store = this.store;
|
|
98
|
-
if (!store)
|
|
99
|
-
return;
|
|
100
|
-
const ctxRequest = store.ctx?.request;
|
|
101
|
-
const raw = store.req || ctxRequest || store.ctx?.req;
|
|
102
|
-
const base = this.req;
|
|
103
|
-
const type = (base.headers['content-type'] || '').toLowerCase();
|
|
104
|
-
const length = parseInt(base.headers['content-length'] || '-1', 10);
|
|
105
|
-
let body = base.body;
|
|
106
|
-
const parse = (text) => {
|
|
107
|
-
if (!text)
|
|
108
|
-
return {};
|
|
109
|
-
if (type.includes('application/json'))
|
|
110
|
-
try {
|
|
111
|
-
return JSON.parse(text);
|
|
112
|
-
}
|
|
113
|
-
catch {
|
|
114
|
-
return text;
|
|
115
|
-
}
|
|
116
|
-
if (type.includes('application/x-www-form-urlencoded'))
|
|
117
|
-
return qs.parse(text);
|
|
118
|
-
try {
|
|
119
|
-
return JSON.parse(text);
|
|
120
|
-
}
|
|
121
|
-
catch {
|
|
122
|
-
try {
|
|
123
|
-
return qs.parse(text);
|
|
124
|
-
}
|
|
125
|
-
catch {
|
|
126
|
-
return text;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
const isStream = (v) => v instanceof ReadableStream || typeof v?.getReader === 'function';
|
|
131
|
-
const ready = body && typeof body === 'object' && !isStream(body) && Object.keys(body).length > 0;
|
|
132
|
-
if (!isRealtimeProtocol(this.protocol) && !['GET', 'HEAD', 'OPTIONS'].includes(base.method) && !ready) {
|
|
133
|
-
if (raw instanceof Request && (isStream(body) || length > 0)) {
|
|
134
|
-
try {
|
|
135
|
-
body = parse(await raw.clone().text());
|
|
136
|
-
}
|
|
137
|
-
catch {
|
|
138
|
-
if (typeof body === 'string')
|
|
139
|
-
body = parse(body);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
else if (raw && typeof raw === 'object' && 'on' in raw && typeof raw.on === 'function' && length !== 0) {
|
|
143
|
-
const stream = raw;
|
|
144
|
-
body = await new Promise((resolve) => {
|
|
145
|
-
let text = '';
|
|
146
|
-
const timer = setTimeout(() => resolve({}), 200);
|
|
147
|
-
stream.on('data', (chunk) => { text += String(chunk); });
|
|
148
|
-
stream.on('end', () => { clearTimeout(timer); resolve(parse(text)); });
|
|
149
|
-
stream.on('error', () => { clearTimeout(timer); resolve({}); });
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
else if (typeof body === 'string' && body.length) {
|
|
153
|
-
body = parse(body);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
if (body?.constructor?.name === 'FormData')
|
|
157
|
-
body = Object.fromEntries(body.entries());
|
|
158
|
-
if (!store.metadata)
|
|
159
|
-
store.metadata = { locals: {} };
|
|
160
|
-
store.metadata.parsedBody = body || {};
|
|
161
|
-
store.metadata.parsedQuery = base.query;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
export default class Controller extends BaseController {
|
|
165
|
-
async onInit() {
|
|
166
|
-
await this.syncFromTmp();
|
|
167
|
-
bindLoaderTmpSync(this);
|
|
168
|
-
}
|
|
169
|
-
syncFromTmp = () => {
|
|
170
|
-
this.supportedProtocols = getConfiguredProtocols();
|
|
171
|
-
};
|
|
172
|
-
parseMessage(msg, t, isError = false) {
|
|
173
|
-
return parseResponseMessage(msg, t, isError);
|
|
174
|
-
}
|
|
175
|
-
args(builder) {
|
|
176
|
-
const req = this.req;
|
|
177
|
-
const locals = this.store.metadata?.locals ?? {};
|
|
178
|
-
return { req, res: { builder, locals }, builder, body: req.body, query: req.query, queries: req.query, params: req.params, cookies: req.cookies, locals, t: req.t };
|
|
179
|
-
}
|
|
180
|
-
fail(builder, source, t) {
|
|
181
|
-
applyResultMeta(builder, source);
|
|
182
|
-
const { data, extraData } = extractPayload(source);
|
|
183
|
-
const message = this.parseMessage(source?.message ?? source, t, true);
|
|
184
|
-
const extras = data !== undefined || extraData !== undefined ? { data, extraData } : undefined;
|
|
185
|
-
const terminal = data !== undefined ? builder.as.fail(data, message, extras) : builder.as.fail(message, extras);
|
|
186
|
-
return terminal.build();
|
|
187
|
-
}
|
|
188
|
-
ok(builder, resResult, logicResult, t) {
|
|
189
|
-
let message = 'success_process';
|
|
190
|
-
let source = resResult !== undefined ? resResult : logicResult;
|
|
191
|
-
if (typeof resResult === 'string') {
|
|
192
|
-
message = resResult;
|
|
193
|
-
source = logicResult;
|
|
194
|
-
}
|
|
195
|
-
const { data, extraData, message: custom } = extractPayload(source);
|
|
196
|
-
if (custom)
|
|
197
|
-
message = custom;
|
|
198
|
-
applyResultMeta(builder, source);
|
|
199
|
-
return builder.as.ok(data, this.parseMessage(message, t, false), extraData !== undefined ? { extraData } : undefined).build();
|
|
200
|
-
}
|
|
201
|
-
async schema({ checks, logic, response }) {
|
|
202
|
-
const builder = resolveBuilder(this.store);
|
|
203
|
-
try {
|
|
204
|
-
await this.parseRequestBody();
|
|
205
|
-
const args = this.args(builder);
|
|
206
|
-
if (checks) {
|
|
207
|
-
const check = await checks(args);
|
|
208
|
-
if (check !== true)
|
|
209
|
-
return this.fail(builder, check, args.req.t);
|
|
210
|
-
}
|
|
211
|
-
let result = logic ? await logic(args) : {};
|
|
212
|
-
if (result?.response)
|
|
213
|
-
result = await result.response();
|
|
214
|
-
if (isRawResponse(result))
|
|
215
|
-
return result;
|
|
216
|
-
if (result?.status === false)
|
|
217
|
-
return this.fail(builder, result, args.req.t);
|
|
218
|
-
const out = response ? await response({ ...args, logicResult: result }) : result;
|
|
219
|
-
if (isRawResponse(out))
|
|
220
|
-
return out;
|
|
221
|
-
return this.ok(builder, out, result, args.req.t);
|
|
222
|
-
}
|
|
223
|
-
catch (error) {
|
|
224
|
-
this.logger?.log(LoggerLayerEnum.ERROR, `Controller Error: ${error.message}`);
|
|
225
|
-
return builder.as.internalServerError(this.parseMessage(error.message, this.req.t, true)).build();
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
ctr(definition, opts) {
|
|
229
|
-
const { framework, protocol } = resolveCtrOptions(opts);
|
|
230
|
-
const action = () => this.schema(definition);
|
|
231
|
-
if (isRealtimeProtocol(protocol)) {
|
|
232
|
-
return toRealtimeHandler(action, protocol);
|
|
233
|
-
}
|
|
234
|
-
return toHandler(action, framework);
|
|
235
|
-
}
|
|
236
|
-
}
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { DTO } from '@xrystal/dto/dto';
|
|
2
|
-
import { bindLoaderTmpSync } from '../../utils';
|
|
3
|
-
import { FrameworkEnum, parseFramework } from '../../utils';
|
|
4
|
-
export const DEFAULT_DTO_CONFIG = {
|
|
5
|
-
withDefaultHeaders: true,
|
|
6
|
-
};
|
|
7
|
-
function mergeDtoConfig(base, patch) {
|
|
8
|
-
return {
|
|
9
|
-
...base,
|
|
10
|
-
...patch,
|
|
11
|
-
codes: patch.codes ? { ...base.codes, ...patch.codes } : base.codes,
|
|
12
|
-
defaultHeaders: patch.defaultHeaders
|
|
13
|
-
? { ...base.defaultHeaders, ...patch.defaultHeaders }
|
|
14
|
-
: base.defaultHeaders,
|
|
15
|
-
socket: patch.socket ? { ...base.socket, ...patch.socket } : base.socket,
|
|
16
|
-
hooks: patch.hooks ?? base.hooks,
|
|
17
|
-
plugins: patch.plugins ? [...(base.plugins ?? []), ...patch.plugins] : base.plugins,
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
export default class DtoRuntime {
|
|
21
|
-
_runtime;
|
|
22
|
-
_system;
|
|
23
|
-
_config = { ...DEFAULT_DTO_CONFIG };
|
|
24
|
-
_framework = FrameworkEnum.ELYSIA;
|
|
25
|
-
_bootConfig = {};
|
|
26
|
-
constructor({ system }) {
|
|
27
|
-
this._system = system;
|
|
28
|
-
}
|
|
29
|
-
async onInit(props = {}) {
|
|
30
|
-
this._bootConfig = props.config ?? {};
|
|
31
|
-
await this.syncFromTmp();
|
|
32
|
-
bindLoaderTmpSync(this);
|
|
33
|
-
}
|
|
34
|
-
syncFromTmp = async () => {
|
|
35
|
-
this._framework = parseFramework(this._system?.tmp?.configs?.framework);
|
|
36
|
-
this.applyConfig(DEFAULT_DTO_CONFIG, this._system?.tmp?.configs?.loaders?.dto ?? {}, this._bootConfig, { rebuild: true });
|
|
37
|
-
};
|
|
38
|
-
get instance() {
|
|
39
|
-
return this._runtime;
|
|
40
|
-
}
|
|
41
|
-
get config() {
|
|
42
|
-
return this._config;
|
|
43
|
-
}
|
|
44
|
-
get framework() {
|
|
45
|
-
return this._framework;
|
|
46
|
-
}
|
|
47
|
-
configure(config = {}, options = {}) {
|
|
48
|
-
this.applyConfig(this._config, config, options);
|
|
49
|
-
return this;
|
|
50
|
-
}
|
|
51
|
-
use(...plugins) {
|
|
52
|
-
this._runtime.use(...plugins);
|
|
53
|
-
this._config = mergeDtoConfig(this._config, { plugins });
|
|
54
|
-
return this;
|
|
55
|
-
}
|
|
56
|
-
express() {
|
|
57
|
-
return this._runtime.express();
|
|
58
|
-
}
|
|
59
|
-
elysia() {
|
|
60
|
-
return this._runtime.elysia();
|
|
61
|
-
}
|
|
62
|
-
node() {
|
|
63
|
-
return this._runtime.node();
|
|
64
|
-
}
|
|
65
|
-
websocket() {
|
|
66
|
-
return this._runtime.websocket();
|
|
67
|
-
}
|
|
68
|
-
socketIo() {
|
|
69
|
-
return this._runtime.socketIo();
|
|
70
|
-
}
|
|
71
|
-
attachWebSocket(socket, requestId) {
|
|
72
|
-
return this._runtime.attachWebSocket(socket, requestId);
|
|
73
|
-
}
|
|
74
|
-
attachSocketIo(socket) {
|
|
75
|
-
return this._runtime.attachSocketIo(socket);
|
|
76
|
-
}
|
|
77
|
-
fetch() {
|
|
78
|
-
return this._runtime.fetch();
|
|
79
|
-
}
|
|
80
|
-
forRequest(request) {
|
|
81
|
-
return this._runtime.forRequest(request);
|
|
82
|
-
}
|
|
83
|
-
applyConfig(...sources) {
|
|
84
|
-
const last = sources[sources.length - 1];
|
|
85
|
-
const options = last && 'rebuild' in last ? sources.pop() : {};
|
|
86
|
-
const merged = sources.reduce((acc, part) => mergeDtoConfig(acc, part), { ...DEFAULT_DTO_CONFIG });
|
|
87
|
-
this._config = merged;
|
|
88
|
-
if (!this._runtime || options.rebuild !== false) {
|
|
89
|
-
this._runtime = new DTO(this._config);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { LoggerLayerEnum, x } from '../../utils';
|
|
2
|
-
export default class Events {
|
|
3
|
-
#logger;
|
|
4
|
-
constructor({ logger }) {
|
|
5
|
-
this.#logger = logger;
|
|
6
|
-
}
|
|
7
|
-
onInit = ({}) => {
|
|
8
|
-
this._globalLoader();
|
|
9
|
-
this._DILoader();
|
|
10
|
-
};
|
|
11
|
-
_globalLoader = () => {
|
|
12
|
-
process.on("uncaughtException", (error, origin) => {
|
|
13
|
-
this.#logger.log({
|
|
14
|
-
level: LoggerLayerEnum.CRITICAL,
|
|
15
|
-
message: `Uncaught Exception: ${error.message}`,
|
|
16
|
-
payload: {
|
|
17
|
-
stack: error.stack,
|
|
18
|
-
origin: origin
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
|
-
process.on("unhandledRejection", (reason, promise) => {
|
|
23
|
-
const error = reason instanceof Error ? reason : new Error(String(reason));
|
|
24
|
-
this.#logger.log({
|
|
25
|
-
level: LoggerLayerEnum.CRITICAL,
|
|
26
|
-
message: `Unhandled Rejection: ${error.message}`,
|
|
27
|
-
payload: {
|
|
28
|
-
stack: error.stack,
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
};
|
|
33
|
-
_DILoader = () => {
|
|
34
|
-
process.on('SIGTERM', () => {
|
|
35
|
-
x.shutdown();
|
|
36
|
-
});
|
|
37
|
-
process.on('SIGINT', () => {
|
|
38
|
-
x.shutdown();
|
|
39
|
-
});
|
|
40
|
-
};
|
|
41
|
-
get global() {
|
|
42
|
-
return this._globalLoader();
|
|
43
|
-
}
|
|
44
|
-
}
|
package/source/loader/index.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import System from "../loader/system";
|
|
2
|
-
import Configs from "../loader/configs";
|
|
3
|
-
import KafkaForCore from "../loader/kafka";
|
|
4
|
-
import Logger from "../loader/logger";
|
|
5
|
-
import Events from "../loader/events";
|
|
6
|
-
import Localizations from "../loader/localizations";
|
|
7
|
-
import DtoRuntime from "../loader/dto";
|
|
8
|
-
import Controller from "../loader/controller";
|
|
9
|
-
import Service from "../loader/service";
|
|
10
|
-
import Clients from "../loader/clients";
|
|
11
|
-
export { System, Configs, Logger, Events, Localizations, DtoRuntime, Controller, Service, Clients, KafkaForCore };
|
package/source/loader/index.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import System from "../loader/system";
|
|
2
|
-
import Configs from "../loader/configs";
|
|
3
|
-
import KafkaForCore from "../loader/kafka";
|
|
4
|
-
import Logger from "../loader/logger";
|
|
5
|
-
import Events from "../loader/events";
|
|
6
|
-
import Localizations from "../loader/localizations";
|
|
7
|
-
import DtoRuntime from "../loader/dto";
|
|
8
|
-
import Controller from "../loader/controller";
|
|
9
|
-
import Service from "../loader/service";
|
|
10
|
-
import Clients from "../loader/clients";
|
|
11
|
-
export { System, Configs, Logger, Events, Localizations, DtoRuntime, Controller, Service, Clients, KafkaForCore };
|