plutin 1.0.0
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/base-controller-cec5714c.d.ts +46 -0
- package/dist/core/decorators/controller-http-decorator.cjs +752 -0
- package/dist/core/decorators/controller-http-decorator.cjs.map +1 -0
- package/dist/core/decorators/controller-http-decorator.d.cts +13 -0
- package/dist/core/decorators/controller-http-decorator.d.ts +13 -0
- package/dist/core/decorators/controller-http-decorator.js +735 -0
- package/dist/core/decorators/controller-http-decorator.js.map +1 -0
- package/dist/core/decorators/dependency-container.cjs +92 -0
- package/dist/core/decorators/dependency-container.cjs.map +1 -0
- package/dist/core/decorators/dependency-container.d.cts +22 -0
- package/dist/core/decorators/dependency-container.d.ts +22 -0
- package/dist/core/decorators/dependency-container.js +69 -0
- package/dist/core/decorators/dependency-container.js.map +1 -0
- package/dist/core/entities/aggregate-root.cjs +99 -0
- package/dist/core/entities/aggregate-root.cjs.map +1 -0
- package/dist/core/entities/aggregate-root.d.cts +8 -0
- package/dist/core/entities/aggregate-root.d.ts +8 -0
- package/dist/core/entities/aggregate-root.js +74 -0
- package/dist/core/entities/aggregate-root.js.map +1 -0
- package/dist/core/entities/common-dto.cjs +19 -0
- package/dist/core/entities/common-dto.cjs.map +1 -0
- package/dist/core/entities/common-dto.d.cts +10 -0
- package/dist/core/entities/common-dto.d.ts +10 -0
- package/dist/core/entities/common-dto.js +1 -0
- package/dist/core/entities/common-dto.js.map +1 -0
- package/dist/core/entities/domain-event.cjs +19 -0
- package/dist/core/entities/domain-event.cjs.map +1 -0
- package/dist/core/entities/domain-event.d.cts +6 -0
- package/dist/core/entities/domain-event.d.ts +6 -0
- package/dist/core/entities/domain-event.js +1 -0
- package/dist/core/entities/domain-event.js.map +1 -0
- package/dist/core/entities/entity.cjs +92 -0
- package/dist/core/entities/entity.cjs.map +1 -0
- package/dist/core/entities/entity.d.cts +17 -0
- package/dist/core/entities/entity.d.ts +17 -0
- package/dist/core/entities/entity.js +67 -0
- package/dist/core/entities/entity.js.map +1 -0
- package/dist/core/entities/optional.cjs +19 -0
- package/dist/core/entities/optional.cjs.map +1 -0
- package/dist/core/entities/optional.d.cts +3 -0
- package/dist/core/entities/optional.d.ts +3 -0
- package/dist/core/entities/optional.js +1 -0
- package/dist/core/entities/optional.js.map +1 -0
- package/dist/core/entities/unique-entity-id.cjs +50 -0
- package/dist/core/entities/unique-entity-id.cjs.map +1 -0
- package/dist/core/entities/unique-entity-id.d.cts +9 -0
- package/dist/core/entities/unique-entity-id.d.ts +9 -0
- package/dist/core/entities/unique-entity-id.js +27 -0
- package/dist/core/entities/unique-entity-id.js.map +1 -0
- package/dist/core/entities/value-object.cjs +40 -0
- package/dist/core/entities/value-object.cjs.map +1 -0
- package/dist/core/entities/value-object.d.cts +6 -0
- package/dist/core/entities/value-object.d.ts +6 -0
- package/dist/core/entities/value-object.js +17 -0
- package/dist/core/entities/value-object.js.map +1 -0
- package/dist/core/entities/watched-list.cjs +121 -0
- package/dist/core/entities/watched-list.cjs.map +1 -0
- package/dist/core/entities/watched-list.d.cts +27 -0
- package/dist/core/entities/watched-list.d.ts +27 -0
- package/dist/core/entities/watched-list.js +98 -0
- package/dist/core/entities/watched-list.js.map +1 -0
- package/dist/core/entities/watched-list.test.cjs +186 -0
- package/dist/core/entities/watched-list.test.cjs.map +1 -0
- package/dist/core/entities/watched-list.test.d.cts +2 -0
- package/dist/core/entities/watched-list.test.d.ts +2 -0
- package/dist/core/entities/watched-list.test.js +185 -0
- package/dist/core/entities/watched-list.test.js.map +1 -0
- package/dist/core/errors/api-common-error.cjs +38 -0
- package/dist/core/errors/api-common-error.cjs.map +1 -0
- package/dist/core/errors/api-common-error.d.cts +28 -0
- package/dist/core/errors/api-common-error.d.ts +28 -0
- package/dist/core/errors/api-common-error.js +13 -0
- package/dist/core/errors/api-common-error.js.map +1 -0
- package/dist/core/errors/application-error.cjs +54 -0
- package/dist/core/errors/application-error.cjs.map +1 -0
- package/dist/core/errors/application-error.d.cts +8 -0
- package/dist/core/errors/application-error.d.ts +8 -0
- package/dist/core/errors/application-error.js +33 -0
- package/dist/core/errors/application-error.js.map +1 -0
- package/dist/core/errors/conflict-error.cjs +56 -0
- package/dist/core/errors/conflict-error.cjs.map +1 -0
- package/dist/core/errors/conflict-error.d.cts +13 -0
- package/dist/core/errors/conflict-error.d.ts +13 -0
- package/dist/core/errors/conflict-error.js +35 -0
- package/dist/core/errors/conflict-error.js.map +1 -0
- package/dist/core/errors/domain-error.cjs +54 -0
- package/dist/core/errors/domain-error.cjs.map +1 -0
- package/dist/core/errors/domain-error.d.cts +8 -0
- package/dist/core/errors/domain-error.d.ts +8 -0
- package/dist/core/errors/domain-error.js +33 -0
- package/dist/core/errors/domain-error.js.map +1 -0
- package/dist/core/errors/http-client-error.cjs +54 -0
- package/dist/core/errors/http-client-error.cjs.map +1 -0
- package/dist/core/errors/http-client-error.d.cts +8 -0
- package/dist/core/errors/http-client-error.d.ts +8 -0
- package/dist/core/errors/http-client-error.js +33 -0
- package/dist/core/errors/http-client-error.js.map +1 -0
- package/dist/core/errors/infra-error.cjs +54 -0
- package/dist/core/errors/infra-error.cjs.map +1 -0
- package/dist/core/errors/infra-error.d.cts +8 -0
- package/dist/core/errors/infra-error.d.ts +8 -0
- package/dist/core/errors/infra-error.js +33 -0
- package/dist/core/errors/infra-error.js.map +1 -0
- package/dist/core/errors/validation-error.cjs +55 -0
- package/dist/core/errors/validation-error.cjs.map +1 -0
- package/dist/core/errors/validation-error.d.cts +8 -0
- package/dist/core/errors/validation-error.d.ts +8 -0
- package/dist/core/errors/validation-error.js +34 -0
- package/dist/core/errors/validation-error.js.map +1 -0
- package/dist/core/http/base-controller.cjs +731 -0
- package/dist/core/http/base-controller.cjs.map +1 -0
- package/dist/core/http/base-controller.d.cts +1 -0
- package/dist/core/http/base-controller.d.ts +1 -0
- package/dist/core/http/base-controller.js +720 -0
- package/dist/core/http/base-controller.js.map +1 -0
- package/dist/core/http/dto-response.cjs +19 -0
- package/dist/core/http/dto-response.cjs.map +1 -0
- package/dist/core/http/dto-response.d.cts +10 -0
- package/dist/core/http/dto-response.d.ts +10 -0
- package/dist/core/http/dto-response.js +1 -0
- package/dist/core/http/dto-response.js.map +1 -0
- package/dist/core/http/error-notifier.cjs +19 -0
- package/dist/core/http/error-notifier.cjs.map +1 -0
- package/dist/core/http/error-notifier.d.cts +1 -0
- package/dist/core/http/error-notifier.d.ts +1 -0
- package/dist/core/http/error-notifier.js +1 -0
- package/dist/core/http/error-notifier.js.map +1 -0
- package/dist/core/http/get-take-and-skip.cjs +40 -0
- package/dist/core/http/get-take-and-skip.cjs.map +1 -0
- package/dist/core/http/get-take-and-skip.d.cts +6 -0
- package/dist/core/http/get-take-and-skip.d.ts +6 -0
- package/dist/core/http/get-take-and-skip.js +17 -0
- package/dist/core/http/get-take-and-skip.js.map +1 -0
- package/dist/core/http/health-connections.cjs +42 -0
- package/dist/core/http/health-connections.cjs.map +1 -0
- package/dist/core/http/health-connections.d.cts +16 -0
- package/dist/core/http/health-connections.d.ts +16 -0
- package/dist/core/http/health-connections.js +23 -0
- package/dist/core/http/health-connections.js.map +1 -0
- package/dist/core/http/http.cjs +19 -0
- package/dist/core/http/http.cjs.map +1 -0
- package/dist/core/http/http.d.cts +10 -0
- package/dist/core/http/http.d.ts +10 -0
- package/dist/core/http/http.js +1 -0
- package/dist/core/http/http.js.map +1 -0
- package/dist/core/http/pagination.cjs +19 -0
- package/dist/core/http/pagination.cjs.map +1 -0
- package/dist/core/http/pagination.d.cts +9 -0
- package/dist/core/http/pagination.d.ts +9 -0
- package/dist/core/http/pagination.js +1 -0
- package/dist/core/http/pagination.js.map +1 -0
- package/dist/core/http/validator.cjs +19 -0
- package/dist/core/http/validator.cjs.map +1 -0
- package/dist/core/http/validator.d.cts +11 -0
- package/dist/core/http/validator.d.ts +11 -0
- package/dist/core/http/validator.js +1 -0
- package/dist/core/http/validator.js.map +1 -0
- package/dist/core/index.cjs +957 -0
- package/dist/core/index.cjs.map +1 -0
- package/dist/core/index.d.cts +18 -0
- package/dist/core/index.d.ts +18 -0
- package/dist/core/index.js +933 -0
- package/dist/core/index.js.map +1 -0
- package/dist/infra/adapters/http/express-adapter.cjs +577 -0
- package/dist/infra/adapters/http/express-adapter.cjs.map +1 -0
- package/dist/infra/adapters/http/express-adapter.d.cts +15 -0
- package/dist/infra/adapters/http/express-adapter.d.ts +15 -0
- package/dist/infra/adapters/http/express-adapter.js +556 -0
- package/dist/infra/adapters/http/express-adapter.js.map +1 -0
- package/dist/infra/adapters/http/fastify-adapter.cjs +562 -0
- package/dist/infra/adapters/http/fastify-adapter.cjs.map +1 -0
- package/dist/infra/adapters/http/fastify-adapter.d.cts +14 -0
- package/dist/infra/adapters/http/fastify-adapter.d.ts +14 -0
- package/dist/infra/adapters/http/fastify-adapter.js +541 -0
- package/dist/infra/adapters/http/fastify-adapter.js.map +1 -0
- package/dist/infra/adapters/http/response-error-code.cjs +35 -0
- package/dist/infra/adapters/http/response-error-code.cjs.map +1 -0
- package/dist/infra/adapters/http/response-error-code.d.cts +6 -0
- package/dist/infra/adapters/http/response-error-code.d.ts +6 -0
- package/dist/infra/adapters/http/response-error-code.js +10 -0
- package/dist/infra/adapters/http/response-error-code.js.map +1 -0
- package/dist/infra/adapters/http/validate-controller-metadata.cjs +42 -0
- package/dist/infra/adapters/http/validate-controller-metadata.cjs.map +1 -0
- package/dist/infra/adapters/http/validate-controller-metadata.d.cts +11 -0
- package/dist/infra/adapters/http/validate-controller-metadata.d.ts +11 -0
- package/dist/infra/adapters/http/validate-controller-metadata.js +19 -0
- package/dist/infra/adapters/http/validate-controller-metadata.js.map +1 -0
- package/dist/infra/adapters/notifications/discord.cjs +86 -0
- package/dist/infra/adapters/notifications/discord.cjs.map +1 -0
- package/dist/infra/adapters/notifications/discord.d.cts +14 -0
- package/dist/infra/adapters/notifications/discord.d.ts +14 -0
- package/dist/infra/adapters/notifications/discord.js +65 -0
- package/dist/infra/adapters/notifications/discord.js.map +1 -0
- package/dist/infra/adapters/notifications/in-memory.cjs +40 -0
- package/dist/infra/adapters/notifications/in-memory.cjs.map +1 -0
- package/dist/infra/adapters/notifications/in-memory.d.cts +8 -0
- package/dist/infra/adapters/notifications/in-memory.d.ts +8 -0
- package/dist/infra/adapters/notifications/in-memory.js +21 -0
- package/dist/infra/adapters/notifications/in-memory.js.map +1 -0
- package/dist/infra/adapters/notifications/sentry.cjs +129 -0
- package/dist/infra/adapters/notifications/sentry.cjs.map +1 -0
- package/dist/infra/adapters/notifications/sentry.d.cts +13 -0
- package/dist/infra/adapters/notifications/sentry.d.ts +13 -0
- package/dist/infra/adapters/notifications/sentry.js +96 -0
- package/dist/infra/adapters/notifications/sentry.js.map +1 -0
- package/dist/infra/adapters/validators/zod/index.cjs +179 -0
- package/dist/infra/adapters/validators/zod/index.cjs.map +1 -0
- package/dist/infra/adapters/validators/zod/index.d.cts +19 -0
- package/dist/infra/adapters/validators/zod/index.d.ts +19 -0
- package/dist/infra/adapters/validators/zod/index.js +154 -0
- package/dist/infra/adapters/validators/zod/index.js.map +1 -0
- package/dist/infra/adapters/validators/zod/zod-map-error.cjs +79 -0
- package/dist/infra/adapters/validators/zod/zod-map-error.cjs.map +1 -0
- package/dist/infra/adapters/validators/zod/zod-map-error.d.cts +15 -0
- package/dist/infra/adapters/validators/zod/zod-map-error.d.ts +15 -0
- package/dist/infra/adapters/validators/zod/zod-map-error.js +60 -0
- package/dist/infra/adapters/validators/zod/zod-map-error.js.map +1 -0
- package/dist/infra/adapters/validators/zod/zod-validator.cjs +178 -0
- package/dist/infra/adapters/validators/zod/zod-validator.cjs.map +1 -0
- package/dist/infra/adapters/validators/zod/zod-validator.d.cts +13 -0
- package/dist/infra/adapters/validators/zod/zod-validator.d.ts +13 -0
- package/dist/infra/adapters/validators/zod/zod-validator.js +153 -0
- package/dist/infra/adapters/validators/zod/zod-validator.js.map +1 -0
- package/dist/infra/env/index.cjs +473 -0
- package/dist/infra/env/index.cjs.map +1 -0
- package/dist/infra/env/index.d.cts +10 -0
- package/dist/infra/env/index.d.ts +10 -0
- package/dist/infra/env/index.js +456 -0
- package/dist/infra/env/index.js.map +1 -0
- package/dist/infra/index.cjs +781 -0
- package/dist/infra/index.cjs.map +1 -0
- package/dist/infra/index.d.cts +5 -0
- package/dist/infra/index.d.ts +5 -0
- package/dist/infra/index.js +752 -0
- package/dist/infra/index.js.map +1 -0
- package/package.json +82 -0
- package/readme.md +56 -0
|
@@ -0,0 +1,752 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
8
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
9
|
+
};
|
|
10
|
+
var __export = (target, all) => {
|
|
11
|
+
for (var name in all)
|
|
12
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
13
|
+
};
|
|
14
|
+
var __copyProps = (to, from, except, desc) => {
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from))
|
|
17
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
18
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
|
+
|
|
24
|
+
// node_modules/dotenv/package.json
|
|
25
|
+
var require_package = __commonJS({
|
|
26
|
+
"node_modules/dotenv/package.json"(exports, module2) {
|
|
27
|
+
module2.exports = {
|
|
28
|
+
name: "dotenv",
|
|
29
|
+
version: "16.5.0",
|
|
30
|
+
description: "Loads environment variables from .env file",
|
|
31
|
+
main: "lib/main.js",
|
|
32
|
+
types: "lib/main.d.ts",
|
|
33
|
+
exports: {
|
|
34
|
+
".": {
|
|
35
|
+
types: "./lib/main.d.ts",
|
|
36
|
+
require: "./lib/main.js",
|
|
37
|
+
default: "./lib/main.js"
|
|
38
|
+
},
|
|
39
|
+
"./config": "./config.js",
|
|
40
|
+
"./config.js": "./config.js",
|
|
41
|
+
"./lib/env-options": "./lib/env-options.js",
|
|
42
|
+
"./lib/env-options.js": "./lib/env-options.js",
|
|
43
|
+
"./lib/cli-options": "./lib/cli-options.js",
|
|
44
|
+
"./lib/cli-options.js": "./lib/cli-options.js",
|
|
45
|
+
"./package.json": "./package.json"
|
|
46
|
+
},
|
|
47
|
+
scripts: {
|
|
48
|
+
"dts-check": "tsc --project tests/types/tsconfig.json",
|
|
49
|
+
lint: "standard",
|
|
50
|
+
pretest: "npm run lint && npm run dts-check",
|
|
51
|
+
test: "tap run --allow-empty-coverage --disable-coverage --timeout=60000",
|
|
52
|
+
"test:coverage": "tap run --show-full-coverage --timeout=60000 --coverage-report=lcov",
|
|
53
|
+
prerelease: "npm test",
|
|
54
|
+
release: "standard-version"
|
|
55
|
+
},
|
|
56
|
+
repository: {
|
|
57
|
+
type: "git",
|
|
58
|
+
url: "git://github.com/motdotla/dotenv.git"
|
|
59
|
+
},
|
|
60
|
+
homepage: "https://github.com/motdotla/dotenv#readme",
|
|
61
|
+
funding: "https://dotenvx.com",
|
|
62
|
+
keywords: [
|
|
63
|
+
"dotenv",
|
|
64
|
+
"env",
|
|
65
|
+
".env",
|
|
66
|
+
"environment",
|
|
67
|
+
"variables",
|
|
68
|
+
"config",
|
|
69
|
+
"settings"
|
|
70
|
+
],
|
|
71
|
+
readmeFilename: "README.md",
|
|
72
|
+
license: "BSD-2-Clause",
|
|
73
|
+
devDependencies: {
|
|
74
|
+
"@types/node": "^18.11.3",
|
|
75
|
+
decache: "^4.6.2",
|
|
76
|
+
sinon: "^14.0.1",
|
|
77
|
+
standard: "^17.0.0",
|
|
78
|
+
"standard-version": "^9.5.0",
|
|
79
|
+
tap: "^19.2.0",
|
|
80
|
+
typescript: "^4.8.4"
|
|
81
|
+
},
|
|
82
|
+
engines: {
|
|
83
|
+
node: ">=12"
|
|
84
|
+
},
|
|
85
|
+
browser: {
|
|
86
|
+
fs: false
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
// node_modules/dotenv/lib/main.js
|
|
93
|
+
var require_main = __commonJS({
|
|
94
|
+
"node_modules/dotenv/lib/main.js"(exports, module2) {
|
|
95
|
+
"use strict";
|
|
96
|
+
var fs = require("fs");
|
|
97
|
+
var path = require("path");
|
|
98
|
+
var os = require("os");
|
|
99
|
+
var crypto = require("crypto");
|
|
100
|
+
var packageJson = require_package();
|
|
101
|
+
var version = packageJson.version;
|
|
102
|
+
var LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
|
|
103
|
+
function parse(src) {
|
|
104
|
+
const obj = {};
|
|
105
|
+
let lines = src.toString();
|
|
106
|
+
lines = lines.replace(/\r\n?/mg, "\n");
|
|
107
|
+
let match;
|
|
108
|
+
while ((match = LINE.exec(lines)) != null) {
|
|
109
|
+
const key = match[1];
|
|
110
|
+
let value = match[2] || "";
|
|
111
|
+
value = value.trim();
|
|
112
|
+
const maybeQuote = value[0];
|
|
113
|
+
value = value.replace(/^(['"`])([\s\S]*)\1$/mg, "$2");
|
|
114
|
+
if (maybeQuote === '"') {
|
|
115
|
+
value = value.replace(/\\n/g, "\n");
|
|
116
|
+
value = value.replace(/\\r/g, "\r");
|
|
117
|
+
}
|
|
118
|
+
obj[key] = value;
|
|
119
|
+
}
|
|
120
|
+
return obj;
|
|
121
|
+
}
|
|
122
|
+
__name(parse, "parse");
|
|
123
|
+
function _parseVault(options) {
|
|
124
|
+
const vaultPath = _vaultPath(options);
|
|
125
|
+
const result = DotenvModule.configDotenv({
|
|
126
|
+
path: vaultPath
|
|
127
|
+
});
|
|
128
|
+
if (!result.parsed) {
|
|
129
|
+
const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
|
|
130
|
+
err.code = "MISSING_DATA";
|
|
131
|
+
throw err;
|
|
132
|
+
}
|
|
133
|
+
const keys = _dotenvKey(options).split(",");
|
|
134
|
+
const length = keys.length;
|
|
135
|
+
let decrypted;
|
|
136
|
+
for (let i = 0; i < length; i++) {
|
|
137
|
+
try {
|
|
138
|
+
const key = keys[i].trim();
|
|
139
|
+
const attrs = _instructions(result, key);
|
|
140
|
+
decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key);
|
|
141
|
+
break;
|
|
142
|
+
} catch (error) {
|
|
143
|
+
if (i + 1 >= length) {
|
|
144
|
+
throw error;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return DotenvModule.parse(decrypted);
|
|
149
|
+
}
|
|
150
|
+
__name(_parseVault, "_parseVault");
|
|
151
|
+
function _warn(message) {
|
|
152
|
+
console.log(`[dotenv@${version}][WARN] ${message}`);
|
|
153
|
+
}
|
|
154
|
+
__name(_warn, "_warn");
|
|
155
|
+
function _debug(message) {
|
|
156
|
+
console.log(`[dotenv@${version}][DEBUG] ${message}`);
|
|
157
|
+
}
|
|
158
|
+
__name(_debug, "_debug");
|
|
159
|
+
function _dotenvKey(options) {
|
|
160
|
+
if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) {
|
|
161
|
+
return options.DOTENV_KEY;
|
|
162
|
+
}
|
|
163
|
+
if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) {
|
|
164
|
+
return process.env.DOTENV_KEY;
|
|
165
|
+
}
|
|
166
|
+
return "";
|
|
167
|
+
}
|
|
168
|
+
__name(_dotenvKey, "_dotenvKey");
|
|
169
|
+
function _instructions(result, dotenvKey) {
|
|
170
|
+
let uri;
|
|
171
|
+
try {
|
|
172
|
+
uri = new URL(dotenvKey);
|
|
173
|
+
} catch (error) {
|
|
174
|
+
if (error.code === "ERR_INVALID_URL") {
|
|
175
|
+
const err = new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");
|
|
176
|
+
err.code = "INVALID_DOTENV_KEY";
|
|
177
|
+
throw err;
|
|
178
|
+
}
|
|
179
|
+
throw error;
|
|
180
|
+
}
|
|
181
|
+
const key = uri.password;
|
|
182
|
+
if (!key) {
|
|
183
|
+
const err = new Error("INVALID_DOTENV_KEY: Missing key part");
|
|
184
|
+
err.code = "INVALID_DOTENV_KEY";
|
|
185
|
+
throw err;
|
|
186
|
+
}
|
|
187
|
+
const environment = uri.searchParams.get("environment");
|
|
188
|
+
if (!environment) {
|
|
189
|
+
const err = new Error("INVALID_DOTENV_KEY: Missing environment part");
|
|
190
|
+
err.code = "INVALID_DOTENV_KEY";
|
|
191
|
+
throw err;
|
|
192
|
+
}
|
|
193
|
+
const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`;
|
|
194
|
+
const ciphertext = result.parsed[environmentKey];
|
|
195
|
+
if (!ciphertext) {
|
|
196
|
+
const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
|
|
197
|
+
err.code = "NOT_FOUND_DOTENV_ENVIRONMENT";
|
|
198
|
+
throw err;
|
|
199
|
+
}
|
|
200
|
+
return {
|
|
201
|
+
ciphertext,
|
|
202
|
+
key
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
__name(_instructions, "_instructions");
|
|
206
|
+
function _vaultPath(options) {
|
|
207
|
+
let possibleVaultPath = null;
|
|
208
|
+
if (options && options.path && options.path.length > 0) {
|
|
209
|
+
if (Array.isArray(options.path)) {
|
|
210
|
+
for (const filepath of options.path) {
|
|
211
|
+
if (fs.existsSync(filepath)) {
|
|
212
|
+
possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
} else {
|
|
216
|
+
possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
|
|
217
|
+
}
|
|
218
|
+
} else {
|
|
219
|
+
possibleVaultPath = path.resolve(process.cwd(), ".env.vault");
|
|
220
|
+
}
|
|
221
|
+
if (fs.existsSync(possibleVaultPath)) {
|
|
222
|
+
return possibleVaultPath;
|
|
223
|
+
}
|
|
224
|
+
return null;
|
|
225
|
+
}
|
|
226
|
+
__name(_vaultPath, "_vaultPath");
|
|
227
|
+
function _resolveHome(envPath) {
|
|
228
|
+
return envPath[0] === "~" ? path.join(os.homedir(), envPath.slice(1)) : envPath;
|
|
229
|
+
}
|
|
230
|
+
__name(_resolveHome, "_resolveHome");
|
|
231
|
+
function _configVault(options) {
|
|
232
|
+
const debug = Boolean(options && options.debug);
|
|
233
|
+
if (debug) {
|
|
234
|
+
_debug("Loading env from encrypted .env.vault");
|
|
235
|
+
}
|
|
236
|
+
const parsed = DotenvModule._parseVault(options);
|
|
237
|
+
let processEnv = process.env;
|
|
238
|
+
if (options && options.processEnv != null) {
|
|
239
|
+
processEnv = options.processEnv;
|
|
240
|
+
}
|
|
241
|
+
DotenvModule.populate(processEnv, parsed, options);
|
|
242
|
+
return {
|
|
243
|
+
parsed
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
__name(_configVault, "_configVault");
|
|
247
|
+
function configDotenv(options) {
|
|
248
|
+
const dotenvPath = path.resolve(process.cwd(), ".env");
|
|
249
|
+
let encoding = "utf8";
|
|
250
|
+
const debug = Boolean(options && options.debug);
|
|
251
|
+
if (options && options.encoding) {
|
|
252
|
+
encoding = options.encoding;
|
|
253
|
+
} else {
|
|
254
|
+
if (debug) {
|
|
255
|
+
_debug("No encoding is specified. UTF-8 is used by default");
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
let optionPaths = [
|
|
259
|
+
dotenvPath
|
|
260
|
+
];
|
|
261
|
+
if (options && options.path) {
|
|
262
|
+
if (!Array.isArray(options.path)) {
|
|
263
|
+
optionPaths = [
|
|
264
|
+
_resolveHome(options.path)
|
|
265
|
+
];
|
|
266
|
+
} else {
|
|
267
|
+
optionPaths = [];
|
|
268
|
+
for (const filepath of options.path) {
|
|
269
|
+
optionPaths.push(_resolveHome(filepath));
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
let lastError;
|
|
274
|
+
const parsedAll = {};
|
|
275
|
+
for (const path2 of optionPaths) {
|
|
276
|
+
try {
|
|
277
|
+
const parsed = DotenvModule.parse(fs.readFileSync(path2, {
|
|
278
|
+
encoding
|
|
279
|
+
}));
|
|
280
|
+
DotenvModule.populate(parsedAll, parsed, options);
|
|
281
|
+
} catch (e) {
|
|
282
|
+
if (debug) {
|
|
283
|
+
_debug(`Failed to load ${path2} ${e.message}`);
|
|
284
|
+
}
|
|
285
|
+
lastError = e;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
let processEnv = process.env;
|
|
289
|
+
if (options && options.processEnv != null) {
|
|
290
|
+
processEnv = options.processEnv;
|
|
291
|
+
}
|
|
292
|
+
DotenvModule.populate(processEnv, parsedAll, options);
|
|
293
|
+
if (lastError) {
|
|
294
|
+
return {
|
|
295
|
+
parsed: parsedAll,
|
|
296
|
+
error: lastError
|
|
297
|
+
};
|
|
298
|
+
} else {
|
|
299
|
+
return {
|
|
300
|
+
parsed: parsedAll
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
__name(configDotenv, "configDotenv");
|
|
305
|
+
function config(options) {
|
|
306
|
+
if (_dotenvKey(options).length === 0) {
|
|
307
|
+
return DotenvModule.configDotenv(options);
|
|
308
|
+
}
|
|
309
|
+
const vaultPath = _vaultPath(options);
|
|
310
|
+
if (!vaultPath) {
|
|
311
|
+
_warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`);
|
|
312
|
+
return DotenvModule.configDotenv(options);
|
|
313
|
+
}
|
|
314
|
+
return DotenvModule._configVault(options);
|
|
315
|
+
}
|
|
316
|
+
__name(config, "config");
|
|
317
|
+
function decrypt(encrypted, keyStr) {
|
|
318
|
+
const key = Buffer.from(keyStr.slice(-64), "hex");
|
|
319
|
+
let ciphertext = Buffer.from(encrypted, "base64");
|
|
320
|
+
const nonce = ciphertext.subarray(0, 12);
|
|
321
|
+
const authTag = ciphertext.subarray(-16);
|
|
322
|
+
ciphertext = ciphertext.subarray(12, -16);
|
|
323
|
+
try {
|
|
324
|
+
const aesgcm = crypto.createDecipheriv("aes-256-gcm", key, nonce);
|
|
325
|
+
aesgcm.setAuthTag(authTag);
|
|
326
|
+
return `${aesgcm.update(ciphertext)}${aesgcm.final()}`;
|
|
327
|
+
} catch (error) {
|
|
328
|
+
const isRange = error instanceof RangeError;
|
|
329
|
+
const invalidKeyLength = error.message === "Invalid key length";
|
|
330
|
+
const decryptionFailed = error.message === "Unsupported state or unable to authenticate data";
|
|
331
|
+
if (isRange || invalidKeyLength) {
|
|
332
|
+
const err = new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");
|
|
333
|
+
err.code = "INVALID_DOTENV_KEY";
|
|
334
|
+
throw err;
|
|
335
|
+
} else if (decryptionFailed) {
|
|
336
|
+
const err = new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");
|
|
337
|
+
err.code = "DECRYPTION_FAILED";
|
|
338
|
+
throw err;
|
|
339
|
+
} else {
|
|
340
|
+
throw error;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
__name(decrypt, "decrypt");
|
|
345
|
+
function populate(processEnv, parsed, options = {}) {
|
|
346
|
+
const debug = Boolean(options && options.debug);
|
|
347
|
+
const override = Boolean(options && options.override);
|
|
348
|
+
if (typeof parsed !== "object") {
|
|
349
|
+
const err = new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
|
|
350
|
+
err.code = "OBJECT_REQUIRED";
|
|
351
|
+
throw err;
|
|
352
|
+
}
|
|
353
|
+
for (const key of Object.keys(parsed)) {
|
|
354
|
+
if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
|
|
355
|
+
if (override === true) {
|
|
356
|
+
processEnv[key] = parsed[key];
|
|
357
|
+
}
|
|
358
|
+
if (debug) {
|
|
359
|
+
if (override === true) {
|
|
360
|
+
_debug(`"${key}" is already defined and WAS overwritten`);
|
|
361
|
+
} else {
|
|
362
|
+
_debug(`"${key}" is already defined and was NOT overwritten`);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
} else {
|
|
366
|
+
processEnv[key] = parsed[key];
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
__name(populate, "populate");
|
|
371
|
+
var DotenvModule = {
|
|
372
|
+
configDotenv,
|
|
373
|
+
_configVault,
|
|
374
|
+
_parseVault,
|
|
375
|
+
config,
|
|
376
|
+
decrypt,
|
|
377
|
+
parse,
|
|
378
|
+
populate
|
|
379
|
+
};
|
|
380
|
+
module2.exports.configDotenv = DotenvModule.configDotenv;
|
|
381
|
+
module2.exports._configVault = DotenvModule._configVault;
|
|
382
|
+
module2.exports._parseVault = DotenvModule._parseVault;
|
|
383
|
+
module2.exports.config = DotenvModule.config;
|
|
384
|
+
module2.exports.decrypt = DotenvModule.decrypt;
|
|
385
|
+
module2.exports.parse = DotenvModule.parse;
|
|
386
|
+
module2.exports.populate = DotenvModule.populate;
|
|
387
|
+
module2.exports = DotenvModule;
|
|
388
|
+
}
|
|
389
|
+
});
|
|
390
|
+
|
|
391
|
+
// node_modules/dotenv/lib/env-options.js
|
|
392
|
+
var require_env_options = __commonJS({
|
|
393
|
+
"node_modules/dotenv/lib/env-options.js"(exports, module2) {
|
|
394
|
+
"use strict";
|
|
395
|
+
var options = {};
|
|
396
|
+
if (process.env.DOTENV_CONFIG_ENCODING != null) {
|
|
397
|
+
options.encoding = process.env.DOTENV_CONFIG_ENCODING;
|
|
398
|
+
}
|
|
399
|
+
if (process.env.DOTENV_CONFIG_PATH != null) {
|
|
400
|
+
options.path = process.env.DOTENV_CONFIG_PATH;
|
|
401
|
+
}
|
|
402
|
+
if (process.env.DOTENV_CONFIG_DEBUG != null) {
|
|
403
|
+
options.debug = process.env.DOTENV_CONFIG_DEBUG;
|
|
404
|
+
}
|
|
405
|
+
if (process.env.DOTENV_CONFIG_OVERRIDE != null) {
|
|
406
|
+
options.override = process.env.DOTENV_CONFIG_OVERRIDE;
|
|
407
|
+
}
|
|
408
|
+
if (process.env.DOTENV_CONFIG_DOTENV_KEY != null) {
|
|
409
|
+
options.DOTENV_KEY = process.env.DOTENV_CONFIG_DOTENV_KEY;
|
|
410
|
+
}
|
|
411
|
+
module2.exports = options;
|
|
412
|
+
}
|
|
413
|
+
});
|
|
414
|
+
|
|
415
|
+
// node_modules/dotenv/lib/cli-options.js
|
|
416
|
+
var require_cli_options = __commonJS({
|
|
417
|
+
"node_modules/dotenv/lib/cli-options.js"(exports, module2) {
|
|
418
|
+
"use strict";
|
|
419
|
+
var re = /^dotenv_config_(encoding|path|debug|override|DOTENV_KEY)=(.+)$/;
|
|
420
|
+
module2.exports = /* @__PURE__ */ __name(function optionMatcher(args) {
|
|
421
|
+
return args.reduce(function(acc, cur) {
|
|
422
|
+
const matches = cur.match(re);
|
|
423
|
+
if (matches) {
|
|
424
|
+
acc[matches[1]] = matches[2];
|
|
425
|
+
}
|
|
426
|
+
return acc;
|
|
427
|
+
}, {});
|
|
428
|
+
}, "optionMatcher");
|
|
429
|
+
}
|
|
430
|
+
});
|
|
431
|
+
|
|
432
|
+
// src/core/decorators/controller-http-decorator.ts
|
|
433
|
+
var controller_http_decorator_exports = {};
|
|
434
|
+
__export(controller_http_decorator_exports, {
|
|
435
|
+
Controller: () => Controller
|
|
436
|
+
});
|
|
437
|
+
module.exports = __toCommonJS(controller_http_decorator_exports);
|
|
438
|
+
|
|
439
|
+
// src/core/http/base-controller.ts
|
|
440
|
+
var import_reflect_metadata2 = require("reflect-metadata");
|
|
441
|
+
|
|
442
|
+
// src/core/decorators/dependency-container.ts
|
|
443
|
+
var import_reflect_metadata = require("reflect-metadata");
|
|
444
|
+
var DependencyContainer = class {
|
|
445
|
+
static {
|
|
446
|
+
__name(this, "DependencyContainer");
|
|
447
|
+
}
|
|
448
|
+
static registry = /* @__PURE__ */ new Map();
|
|
449
|
+
static singletons = /* @__PURE__ */ new Map();
|
|
450
|
+
static register(token, myClass, options) {
|
|
451
|
+
this.registry.set(token, {
|
|
452
|
+
type: "class",
|
|
453
|
+
myClass,
|
|
454
|
+
singleton: options.singleton
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
static registerValue(token, value) {
|
|
458
|
+
this.registry.set(token, {
|
|
459
|
+
type: "value",
|
|
460
|
+
value
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
static resolve(target) {
|
|
464
|
+
const paramTypes = Reflect.getMetadata("design:paramtypes", target) || [];
|
|
465
|
+
const injectMetadata = Reflect.getOwnMetadata("inject:params", target) || {};
|
|
466
|
+
const params = paramTypes.map((_, index) => {
|
|
467
|
+
const token = injectMetadata[index];
|
|
468
|
+
if (!token) {
|
|
469
|
+
throw new Error(`Missing @Inject token for parameter index ${index} in ${target.name}`);
|
|
470
|
+
}
|
|
471
|
+
return this.resolveToken(token);
|
|
472
|
+
});
|
|
473
|
+
return new target(...params);
|
|
474
|
+
}
|
|
475
|
+
static resolveToken(token) {
|
|
476
|
+
const registration = this.registry.get(token);
|
|
477
|
+
if (!registration) {
|
|
478
|
+
throw new Error(`"${token}" not registered. Please register it in the container.`);
|
|
479
|
+
}
|
|
480
|
+
if (registration.type === "value") {
|
|
481
|
+
return registration.value;
|
|
482
|
+
}
|
|
483
|
+
const { myClass, singleton } = registration;
|
|
484
|
+
if (singleton) {
|
|
485
|
+
if (!this.singletons.has(token)) {
|
|
486
|
+
const instance = this.resolve(myClass);
|
|
487
|
+
this.singletons.set(token, instance);
|
|
488
|
+
}
|
|
489
|
+
return this.singletons.get(token);
|
|
490
|
+
}
|
|
491
|
+
return this.resolve(myClass);
|
|
492
|
+
}
|
|
493
|
+
};
|
|
494
|
+
|
|
495
|
+
// src/core/errors/api-common-error.ts
|
|
496
|
+
var ApiErrorEnum = /* @__PURE__ */ function(ApiErrorEnum2) {
|
|
497
|
+
ApiErrorEnum2["DOMAIN"] = "ERR001";
|
|
498
|
+
ApiErrorEnum2["APPLICATION"] = "ERR002";
|
|
499
|
+
ApiErrorEnum2["INFRA"] = "ERR003";
|
|
500
|
+
ApiErrorEnum2["HTTP_CLIENT"] = "ERR004";
|
|
501
|
+
ApiErrorEnum2["VALIDATOR"] = "ERR005";
|
|
502
|
+
return ApiErrorEnum2;
|
|
503
|
+
}({});
|
|
504
|
+
|
|
505
|
+
// src/core/errors/application-error.ts
|
|
506
|
+
var ApplicationError = class extends Error {
|
|
507
|
+
static {
|
|
508
|
+
__name(this, "ApplicationError");
|
|
509
|
+
}
|
|
510
|
+
props;
|
|
511
|
+
constructor(message) {
|
|
512
|
+
super(message);
|
|
513
|
+
this.props = {
|
|
514
|
+
code: 400,
|
|
515
|
+
errorCode: ApiErrorEnum.APPLICATION,
|
|
516
|
+
message,
|
|
517
|
+
occurredAt: /* @__PURE__ */ new Date()
|
|
518
|
+
};
|
|
519
|
+
}
|
|
520
|
+
};
|
|
521
|
+
|
|
522
|
+
// src/core/errors/conflict-error.ts
|
|
523
|
+
var ConflictError = class extends Error {
|
|
524
|
+
static {
|
|
525
|
+
__name(this, "ConflictError");
|
|
526
|
+
}
|
|
527
|
+
props;
|
|
528
|
+
conflictProps;
|
|
529
|
+
constructor(conflictProps) {
|
|
530
|
+
super("Resource already exists.");
|
|
531
|
+
this.conflictProps = conflictProps;
|
|
532
|
+
this.props = {
|
|
533
|
+
code: 409,
|
|
534
|
+
errorCode: ApiErrorEnum.APPLICATION,
|
|
535
|
+
message: this.message,
|
|
536
|
+
occurredAt: /* @__PURE__ */ new Date()
|
|
537
|
+
};
|
|
538
|
+
}
|
|
539
|
+
};
|
|
540
|
+
|
|
541
|
+
// src/core/errors/domain-error.ts
|
|
542
|
+
var DomainError = class extends Error {
|
|
543
|
+
static {
|
|
544
|
+
__name(this, "DomainError");
|
|
545
|
+
}
|
|
546
|
+
props;
|
|
547
|
+
constructor(message) {
|
|
548
|
+
super(message);
|
|
549
|
+
this.props = {
|
|
550
|
+
code: 400,
|
|
551
|
+
errorCode: ApiErrorEnum.DOMAIN,
|
|
552
|
+
message,
|
|
553
|
+
occurredAt: /* @__PURE__ */ new Date()
|
|
554
|
+
};
|
|
555
|
+
}
|
|
556
|
+
};
|
|
557
|
+
|
|
558
|
+
// src/core/errors/infra-error.ts
|
|
559
|
+
var InfraError = class extends Error {
|
|
560
|
+
static {
|
|
561
|
+
__name(this, "InfraError");
|
|
562
|
+
}
|
|
563
|
+
props;
|
|
564
|
+
constructor(message) {
|
|
565
|
+
super(message);
|
|
566
|
+
this.props = {
|
|
567
|
+
code: 400,
|
|
568
|
+
errorCode: ApiErrorEnum.INFRA,
|
|
569
|
+
message,
|
|
570
|
+
occurredAt: /* @__PURE__ */ new Date()
|
|
571
|
+
};
|
|
572
|
+
}
|
|
573
|
+
};
|
|
574
|
+
|
|
575
|
+
// src/core/errors/validation-error.ts
|
|
576
|
+
var ValidationError = class extends Error {
|
|
577
|
+
static {
|
|
578
|
+
__name(this, "ValidationError");
|
|
579
|
+
}
|
|
580
|
+
props;
|
|
581
|
+
constructor(errors) {
|
|
582
|
+
super("Validation Error");
|
|
583
|
+
this.props = {
|
|
584
|
+
code: 400,
|
|
585
|
+
errorCode: ApiErrorEnum.VALIDATOR,
|
|
586
|
+
message: "Validation Error",
|
|
587
|
+
occurredAt: /* @__PURE__ */ new Date(),
|
|
588
|
+
errors
|
|
589
|
+
};
|
|
590
|
+
}
|
|
591
|
+
};
|
|
592
|
+
|
|
593
|
+
// node_modules/dotenv/config.js
|
|
594
|
+
(function() {
|
|
595
|
+
require_main().config(Object.assign({}, require_env_options(), require_cli_options()(process.argv)));
|
|
596
|
+
})();
|
|
597
|
+
|
|
598
|
+
// src/infra/env/index.ts
|
|
599
|
+
var import_zod = require("zod");
|
|
600
|
+
var envSchema = import_zod.z.object({
|
|
601
|
+
NODE_ENV: import_zod.z.enum([
|
|
602
|
+
"test",
|
|
603
|
+
"development",
|
|
604
|
+
"production"
|
|
605
|
+
]).default("production"),
|
|
606
|
+
ENVIRONMENT: import_zod.z.enum([
|
|
607
|
+
"test",
|
|
608
|
+
"development",
|
|
609
|
+
"staging",
|
|
610
|
+
"production"
|
|
611
|
+
]).default("development"),
|
|
612
|
+
PORT: import_zod.z.coerce.number().default(3333),
|
|
613
|
+
SHOULD_NOTIFY_ERROR: import_zod.z.coerce.boolean().default(true),
|
|
614
|
+
SENTRY_DSN: import_zod.z.string().optional(),
|
|
615
|
+
DISCORD_WEBHOOK_URL: import_zod.z.string().optional()
|
|
616
|
+
});
|
|
617
|
+
var _env = envSchema.safeParse(process.env);
|
|
618
|
+
if (_env.success === false) {
|
|
619
|
+
console.error("\u274C Invalid environment variables.", _env.error.format());
|
|
620
|
+
throw new Error("Invalid environment variables.");
|
|
621
|
+
}
|
|
622
|
+
var env = _env.data;
|
|
623
|
+
|
|
624
|
+
// src/core/http/base-controller.ts
|
|
625
|
+
var BaseController = class {
|
|
626
|
+
static {
|
|
627
|
+
__name(this, "BaseController");
|
|
628
|
+
}
|
|
629
|
+
errorNotifier;
|
|
630
|
+
constructor() {
|
|
631
|
+
this.errorNotifier = DependencyContainer.resolveToken("IErrorNotifier");
|
|
632
|
+
}
|
|
633
|
+
success(dto) {
|
|
634
|
+
return {
|
|
635
|
+
code: 200,
|
|
636
|
+
data: {
|
|
637
|
+
data: dto
|
|
638
|
+
}
|
|
639
|
+
};
|
|
640
|
+
}
|
|
641
|
+
noContent() {
|
|
642
|
+
return {
|
|
643
|
+
code: 204,
|
|
644
|
+
data: void 0
|
|
645
|
+
};
|
|
646
|
+
}
|
|
647
|
+
created(dto) {
|
|
648
|
+
return {
|
|
649
|
+
code: 201,
|
|
650
|
+
data: dto ? {
|
|
651
|
+
data: dto
|
|
652
|
+
} : void 0
|
|
653
|
+
};
|
|
654
|
+
}
|
|
655
|
+
paginated(dto) {
|
|
656
|
+
return {
|
|
657
|
+
code: 200,
|
|
658
|
+
data: dto
|
|
659
|
+
};
|
|
660
|
+
}
|
|
661
|
+
buildContextError(request) {
|
|
662
|
+
return {
|
|
663
|
+
env: env.ENVIRONMENT,
|
|
664
|
+
request: {
|
|
665
|
+
body: request.body,
|
|
666
|
+
headers: request.headers,
|
|
667
|
+
params: request.params,
|
|
668
|
+
query: request.query
|
|
669
|
+
}
|
|
670
|
+
};
|
|
671
|
+
}
|
|
672
|
+
async failure(error, context) {
|
|
673
|
+
if (error instanceof ConflictError) {
|
|
674
|
+
return {
|
|
675
|
+
code: error.props.code,
|
|
676
|
+
data: {
|
|
677
|
+
message: error.message,
|
|
678
|
+
errorCode: error.props.errorCode,
|
|
679
|
+
occurredAt: error.props.occurredAt,
|
|
680
|
+
items: Array.isArray(error.conflictProps) ? error.conflictProps : [
|
|
681
|
+
error.conflictProps
|
|
682
|
+
]
|
|
683
|
+
}
|
|
684
|
+
};
|
|
685
|
+
}
|
|
686
|
+
if (error instanceof DomainError || error instanceof ApplicationError || error instanceof InfraError) {
|
|
687
|
+
return {
|
|
688
|
+
code: error.props.code,
|
|
689
|
+
data: {
|
|
690
|
+
message: error.message,
|
|
691
|
+
errorCode: error.props.errorCode,
|
|
692
|
+
occurredAt: error.props.occurredAt
|
|
693
|
+
}
|
|
694
|
+
};
|
|
695
|
+
}
|
|
696
|
+
if (error instanceof ValidationError) {
|
|
697
|
+
return {
|
|
698
|
+
code: error.props.code,
|
|
699
|
+
data: {
|
|
700
|
+
message: error.props.message,
|
|
701
|
+
errorCode: error.props.errorCode,
|
|
702
|
+
occurredAt: error.props.occurredAt,
|
|
703
|
+
errors: error.props.errors
|
|
704
|
+
}
|
|
705
|
+
};
|
|
706
|
+
}
|
|
707
|
+
if (env.SHOULD_NOTIFY_ERROR) {
|
|
708
|
+
await this.errorNotifier.notify(error, context);
|
|
709
|
+
}
|
|
710
|
+
return {
|
|
711
|
+
code: 500,
|
|
712
|
+
data: {
|
|
713
|
+
code: 500,
|
|
714
|
+
message: "Server failed. Contact the administrator!"
|
|
715
|
+
}
|
|
716
|
+
};
|
|
717
|
+
}
|
|
718
|
+
async execute(request) {
|
|
719
|
+
const routeMetadata = Reflect.getMetadata("route", this.constructor);
|
|
720
|
+
if (!routeMetadata) {
|
|
721
|
+
throw new InfraError("Route metadata not found.");
|
|
722
|
+
}
|
|
723
|
+
const middlewares = routeMetadata.middlewares || [];
|
|
724
|
+
let processedRequest = request;
|
|
725
|
+
if (middlewares.length) {
|
|
726
|
+
for (const middleware of middlewares) {
|
|
727
|
+
processedRequest = await middleware(processedRequest);
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
return await this.handle(processedRequest);
|
|
731
|
+
}
|
|
732
|
+
};
|
|
733
|
+
|
|
734
|
+
// src/core/decorators/controller-http-decorator.ts
|
|
735
|
+
function Controller({ method, path, middlewares = [] }) {
|
|
736
|
+
return (target) => {
|
|
737
|
+
if (!(target.prototype instanceof BaseController)) {
|
|
738
|
+
throw new Error(`The class ${target.name} should extends abstract class BaseController`);
|
|
739
|
+
}
|
|
740
|
+
Reflect.defineMetadata("route", {
|
|
741
|
+
method,
|
|
742
|
+
path: `/api/${path}`,
|
|
743
|
+
middlewares
|
|
744
|
+
}, target);
|
|
745
|
+
};
|
|
746
|
+
}
|
|
747
|
+
__name(Controller, "Controller");
|
|
748
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
749
|
+
0 && (module.exports = {
|
|
750
|
+
Controller
|
|
751
|
+
});
|
|
752
|
+
//# sourceMappingURL=controller-http-decorator.cjs.map
|