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