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